Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ jobs:
--tag ${REPO_NAME}:$IMAGE_TAG_BRANCH \
--tag ${REPO_NAME}:latest \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--build-arg is_kubernetes=True \
--build-arg vpc_agent_commit_hash=${{ github.sha }} \
--file Dockerfile \
$EXPORT_FLAG \
.
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ COPY nginx.default /etc/nginx/sites-available/default
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

# Accept build arguments
ARG is_kubernetes
ARG vpc_agent_commit_hash

# Set environment variables
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV IS_KUBERNETES=${is_kubernetes}
ENV VPC_AGENT_COMMIT_HASH=${vpc_agent_commit_hash}

# Install Rust for building dependencies
ENV PATH="/root/.cargo/bin:${PATH}"
Expand Down
9 changes: 9 additions & 0 deletions agent.docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ services:
build:
context: .
dockerfile: Dockerfile
args:
- is_kubernetes=${IS_KUBERNETES:-False}
- vpc_agent_commit_hash=${COMMIT_HASH:-}
image: drd_agent
command: ./start-celery-worker.sh
environment:
Expand All @@ -29,6 +32,8 @@ services:
- "REDIS_URL=redis://redis:6379/0"
- DRD_CLOUD_API_TOKEN=${DRD_CLOUD_API_TOKEN}
- VPC_AGENT_COMMIT_HASH=${COMMIT_HASH:-unknown}
- IS_KUBERNETES=${IS_KUBERNETES:-False}
- vpc_agent_commit_hash=${COMMIT_HASH:-}
depends_on:
- redis
- fluentd
Expand All @@ -45,6 +50,9 @@ services:
build:
context: .
dockerfile: Dockerfile
args:
- is_kubernetes=${IS_KUBERNETES:-False}
- vpc_agent_commit_hash=${COMMIT_HASH:-unknown}
image: drd_agent
command: ./start-celery-beat.sh
environment:
Expand All @@ -54,6 +62,7 @@ services:
- "REDIS_URL=redis://redis:6379/0"
- DRD_CLOUD_API_TOKEN=${DRD_CLOUD_API_TOKEN}
- VPC_AGENT_COMMIT_HASH=${COMMIT_HASH:-unknown}
- IS_KUBERNETES=${IS_KUBERNETES:-False}
depends_on:
- redis
- fluentd
Expand Down
1 change: 1 addition & 0 deletions agent/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def load_yaml(filepath, native_k8s_connector_mode=False):
DRD_CLOUD_API_TOKEN = env.str("DRD_CLOUD_API_TOKEN")
DRD_CLOUD_API_HOST = env.str("DRD_CLOUD_API_HOST", default="https://agent-api.drdroid.io")
VPC_AGENT_COMMIT_HASH = env.str("VPC_AGENT_COMMIT_HASH", default="unknown")
IS_KUBERNETES = env.str("IS_KUBERNETES", default="False")

NATIVE_KUBERNETES_API_MODE = env.bool("NATIVE_KUBERNETES_API_MODE", default=False)

Expand Down
9 changes: 8 additions & 1 deletion agent/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ def send_ping_to_drd_cloud():
drd_cloud_host = settings.DRD_CLOUD_API_HOST
drd_cloud_api_token = settings.DRD_CLOUD_API_TOKEN
commit_hash = settings.VPC_AGENT_COMMIT_HASH
is_kubernetes = settings.IS_KUBERNETES
current_epoch = current_epoch_timestamp()

# Prepare query parameters
params = {
'commit_hash': commit_hash,
'is_kubernetes': is_kubernetes,
}

# Establish reachability with DRD Cloud
response = requests.get(f'{drd_cloud_host}/connectors/proxy/ping',
headers={'Authorization': f'Bearer {drd_cloud_api_token}'},
params={'commit_hash': commit_hash})
params=params)

if response.status_code != 200:
logger.error(f'Failed to connect to DRD Cloud at {current_epoch} with code: {response.status_code} '
Expand Down
2 changes: 1 addition & 1 deletion deploy_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ echo "📝 Capturing current commit hash..."
COMMIT_HASH=$(git rev-parse HEAD)

echo "🚀 Starting Docker Compose with new deployment... with commit hash: $COMMIT_HASH"
DRD_CLOUD_API_TOKEN="$DRD_CLOUD_API_TOKEN" COMMIT_HASH="$COMMIT_HASH" docker-compose -f agent.docker-compose.yaml up -d
DRD_CLOUD_API_TOKEN="$DRD_CLOUD_API_TOKEN" COMMIT_HASH="$COMMIT_HASH" IS_KUBERNETES="False" docker-compose -f agent.docker-compose.yaml up -d

echo "✅ Deployment complete."