
Implementing GitOps for a Cloud Connect Application Using AWS EKS and Argo CD
How to implement GitOps-based application deployment using AWS EKS, Docker, Kubernetes, and Argo CD. This practical guide covers containerization, Amazon ECR, automated synchronization, Kubernetes deployments, and monitoring using a dummy CloudConnect project.
1. Introduction
In real-world projects, deploying frontend and backend applications separately can create operational challenges. Developers frequently release new features, fix bugs, and update application configurations. Managing these deployments manually can lead to configuration errors, downtime, and inconsistent environments.
In this practical implementation, we will take an example of a Cloud Connect application and implement a GitOps-based deployment strategy using AWS EKS, Docker, Amazon ECR, Kubernetes, and Argo CD.
The Cloud Connect application will contain:
- Frontend Application
- Backend Application
- PostgreSQL Database
- Nginx Ingress Controller
- Argo CD for GitOps-based deployment
- Amazon ECR for Docker image storage
- AWS EKS for Kubernetes orchestration
Our objective is to maintain Kubernetes deployment configurations in Git and allow Argo CD to automatically synchronize changes with the Kubernetes cluster.
2. Project Architecture
The application will use the following architecture:
Developers | v Application Code | +-------+-------+ | | v v Frontend Backend | | +-------+-------+ | v Docker Images | v Amazon ECR | v GitOps Configuration Repo | v Argo CD | v AWS EKS | +----------+----------+ | | v v Frontend Pods Backend Pods | | v v Frontend Service Backend Service | v PostgreSQL RDSDeployment workflow:
- Developers update application source code.
- New Docker images are built and pushed to Amazon ECR.
- The image tags are updated in the GitOps repository.
- Argo CD detects changes in the repository.
- Argo CD synchronizes Kubernetes manifests.
- Kubernetes deploys the updated frontend and backend.
- The application communicates with PostgreSQL through a secure database connection.
Note: Argo CD handles continuous delivery and reconciliation. Image building and pushing to ECR are separate CI activities. This practical guide performs those steps manually to keep the GitOps deployment process easy to understand.
3. Prerequisites
Before starting, prepare the following:
Component | Purpose |
|---|---|
AWS EC2 / AWS Account | Infrastructure management |
AWS EKS | Kubernetes cluster |
Amazon ECR | Docker image registry |
Docker | Application containerization |
kubectl | Kubernetes management |
GitHub | Source code and GitOps repository |
Argo CD | GitOps continuous delivery |
PostgreSQL RDS | Application database |
Nginx Ingress | Application traffic routing |
You should have an operational EKS cluster and kubectl access before proceeding.
4. Create Docker Images for Cloud-Connect Services
We will maintain separate Docker images for the frontend and backend.
Step 1: Build the Frontend Image
Navigate to the Cloud-Connect frontend project directory.
cd Cloud-Connect-application-frontendBuild the Docker image:
docker build -t Cloud-Connect-frontend:v1 .Step 2: Build the Backend Image
Navigate to the backend project directory:
cd Cloud-Connect-application-backendBuild the backend image:
docker build -t Connect-backend:v1 .Step 3: Verify Images
docker imagesYou should see both Cloud-Connect application images.
5. Push Docker Images to Amazon ECR
Create two repositories in Amazon ECR:
- Cloud-Connect-application-frontend
- Cloud-Connect-application-backend
Authenticate Docker with Amazon ECR:
aws ecr get-login-password \--region ap-south-1 | docker login \--username AWS \--password-stdin ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.comTag the frontend image:
docker tag Cloud-Connect-frontend:v1 \ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/Cloud-Connect-frontend:v1Push the frontend image:
docker push ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/Connect-frontend:v1Tag the backend image:
docker tag Connect-backend:v1 \ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/Connect-backend:v1Push the backend image:
docker push ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/Connect-backend:v1Replace ACCOUNT_ID with your AWS account ID.
6. Create the GitOps Repository
Create a separate GitHub repository named:
Cloud-Connect-application-gitops This repository will contain Kubernetes deployment configurations.
Recommended folder structure:
Cloud-Connect-application-gitops/│├── Cloud-Connect/│ ││ ├── namespace.yaml│ ││ ├── frontend/│ │ ├── deployment.yaml│ │ └── service.yaml│ ││ ├── backend/│ │ ├── deployment.yaml│ │ └── service.yaml│ ││ └── ingress.yaml│└── argocd/ └── Cloud-Connect-application.yamlThe repository will act as the single source of truth for Cloud Connect Application Kubernetes configurations.
7. Create Kubernetes Namespace
Create
namespace.yaml .apiVersion: v1kind: Namespacemetadata: name: Cloud-ConnectThis namespace will contain all Cloud Connect application resources.
8. Configure Frontend Deployment
Create
frontend/deployment.yaml .apiVersion: apps/v1kind: Deployment
metadata: name: Cloud-Connect-frontend namespace: Cloud-Connect
spec: replicas: 2
selector: matchLabels: app: Cloud-Connect-frontend
template: metadata: labels: app: Cloud-Connect-frontend
spec: containers: - name: frontend image: ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/Cloud-Connect-frontend:v1
ports: - containerPort: 80
resources: requests: cpu: "100m" memory: "128Mi"
limits: cpu: "500m" memory: "512Mi"Create
frontend/service.yaml .apiVersion: v1kind: Service
metadata: name: Cloud-Connect-frontend-service namespace: Cloud-Connect
spec: type: ClusterIP
selector: app: Cloud-Connect-frontend
ports: - port: 80 targetPort: 80The frontend service provides internal communication within Kubernetes.
9. Configure Backend Deployment
Create
backend/deployment.yaml .apiVersion: apps/v1kind: Deployment
metadata: name: Cloud-Connect-backend namespace: Cloud-Connect
spec: replicas: 2
selector: matchLabels: app: Cloud-Connect-backend
template: metadata: labels: app: Cloud-Connect-backend
spec: containers: - name: backend
image: ACCOUNT_ID.dkr.ecr.ap-south-1.amazonaws.com/Cloud-Connect-backend:v1
ports: - containerPort: 5000
env: - name: ASPNETCORE_URLS value: "http://+:5000"
- name: ConnectionStrings__DefaultConnection valueFrom: secretKeyRef: name: Cloud-Connect-db-secret key: connection-string
resources: requests: cpu: "200m" memory: "256Mi"
limits: cpu: "1000m" memory: "1Gi"This example assumes an ASP.NET Core backend listening on port 5000. Adjust the container port and environment variable names according to the actual Cloud-Connect backend.
Create
backend/service.yaml .apiVersion: v1kind: Service
metadata: name: Cloud-Connect-backend-service namespace: Cloud-Connect
spec: type: ClusterIP
selector: app: Cloud-Connect ports: - port: 5000 targetPort: 5000Database configuration: Create the
Cloud-Connect-db-secret through a secure secret-management process. Do not commit database passwords or connection strings to Git. For production, integrate AWS Secrets Manager with External Secrets Operator.10. Configure Nginx Ingress
Create
ingress.yaml .apiVersion: networking.k8s.io/v1kind: Ingress
metadata: name: Cloud-Connect-ingress namespace: Cloud-Connect
spec: ingressClassName: nginx
rules: - host: Cloud-Connect.example.com
http: paths:
- path: / pathType: Prefix
backend: service: name: Cloud-Connect-frontend-service port: number: 80
- path: /api pathType: Prefix
backend: service: name: Cloud-Connect-backend-service port: number: 5000Replace
Cloud-Connect.example.com with your actual application domain.Make sure an Nginx Ingress Controller is installed and its load balancer has been configured with the required DNS record.
11. Install Argo CD on AWS EKS
Connect kubectl to your EKS cluster:
aws eks update-kubeconfig \--region ap-south-1 \--name Cloud-Connect-eksCreate the Argo CD namespace:
kubectl create namespace argocdInstall Argo CD:
kubectl apply -n argocd \-f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlVerify the installation:
kubectl get pods -n argocdWait until the Argo CD components are running.
Access the dashboard using port forwarding:
kubectl port-forward svc/argocd-server \-n argocd 8080:443Open:
https://localhost:8080 Retrieve the initial admin password:
kubectl get secret argocd-initial-admin-secret \-n argocd \-o jsonpath="{.data.password}" | base64 -dLogin using:
- Username: admin
- Password: Retrieved from the command above.
Change the initial password and configure secure access.
12. Connect the GitOps Repository to Argo CD
Open the Argo CD dashboard.
Navigate to:
Settings → Repositories → Connect Repo.
Select HTTPS and provide:
- Repository URL: YourCloud Connect GitOps repository.
- Username: Your GitHub username.
- Password: GitHub Personal Access Token, if required for a private repository.
For production, prefer a dedicated read-only repository credential or deploy key.
13. Create the Argo CD Application
Create
argocd/ Cloud-Connect -application.yaml .apiVersion: argoproj.io/v1alpha1kind: Application
metadata: name: Cloud-Connect-onboard namespace: argocd
spec: project: default
source: repoURL: https://github.com/YOUR_USERNAME/Cloud-Connect-gitops.git targetRevision: main path: Cloud-Connect
destination: server: https://kubernetes.default.svc namespace: Cloud-Connect
syncPolicy: automated: prune: true selfHeal: true
syncOptions: - CreateNamespace=trueReplace the repository URL with your actual GitHub repository.
Apply the configuration:
kubectl apply -f argocd/Cloud-Connect-application.yamlCheck the Argo CD application:
kubectl get applications -n argocdArgo CD will now monitor the GitOps repository and synchronize the Kubernetes resources.
14. Test Automated GitOps Deployment
Now let's perform a real deployment update.
Suppose the Cloud-Connect Onboard frontend requires an additional replica because of increased application traffic.
Open:
frontend/deployment.yaml Change:
replicas: 2To:
replicas: 3Commit and push the updated configuration:
git add .git commit -m "Scale Cloud-Connect frontend to three replicas"git push origin mainArgo CD detects the updated configuration and synchronizes the cluster.
Verify the deployment:
kubectl get deployments -n Cloud-ConnectCheck the pods:
kubectl get pods -n Cloud-ConnectYou should now see three frontend replicas.
15. Test Argo CD Self-Healing
One of the major advantages of GitOps is self-healing.
Try manually scaling the frontend deployment:
kubectl scale deployment Cloud-Connect-frontend \--replicas=1 -n Cloud-ConnectCheck the replica count:
kubectl get deployment Cloud-Connect-frontend \-n Cloud-ConnectSince Argo CD has automated synchronization and self-healing enabled, it will detect the difference between Git's desired configuration and the live cluster state.
It will restore the frontend deployment to three replicas.
This demonstrates how Argo CD continuously maintains the desired application state.
16. Verify the Cloud-Connect Application
Check all application resources:
kubectl get all -n Cloud-ConnectCheck ingress:
kubectl get ingress -n Cloud-ConnectCheck backend logs:
kubectl logs deployment/Cloud-Connect-backend \-n Cloud-ConnectCheck frontend logs:
kubectl logs deployment/Cloud-Connect-frontend \-n Cloud-ConnectFinally, access the configured Cloud-Connect domain and verify that:
- The frontend loads successfully.
- Backend API requests are working.
- PostgreSQL connectivity is successful.
- The application is accessible through the configured domain.
17. Production-Level Improvements
For a production Cloud-Connect deployment, implement these additional improvements:
- Horizontal Pod Autoscaler: Automatically scale frontend and backend pods based on resource utilization.
- AWS Secrets Manager: Securely manage PostgreSQL credentials and application secrets.
- Amazon ECR Image Scanning: Scan container images for security vulnerabilities.
- Prometheus and Grafana: Monitor Kubernetes nodes, pods, and application metrics.
- TLS Certificates: Enable HTTPS using AWS Certificate Manager or cert-manager, depending on the ingress architecture.
- Environment Separation: Maintain independent Development, Staging, and Production configurations.
- Git Branch Protection: Require pull request reviews before production configuration changes are merged.
- Deployment Rollback: Revert to a previous Git commit and synchronize the previous configuration.
- Network Security: Restrict database access to authorized application workloads and private network paths.
- High Availability: Configure multiple EKS worker nodes across availability zones.
18. Conclusion
In this practical implementation, we deployed a Cloud-Connect application using AWS EKS and Argo CD.
We created separate frontend and backend deployments, configured PostgreSQL connectivity, stored Docker images in Amazon ECR, and implemented GitOps-based continuous delivery.
The main advantage of this architecture is that Git becomes the source of truth for application deployment configurations. Any approved configuration change can be tracked, reviewed, synchronized, and reverted through Git.
This approach helps DevOps engineers build consistent, scalable, and maintainable Kubernetes deployment environments.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article