TL;DR: This guide shows how to replace push-based CI/CD pipelines with a pull-based GitOps setup on AWS EKS using Argo CD and Kustomize. You will learn how to structure isolated manifest repositories, enforce cluster state using an ArgoCD
ApplicationCRD withselfHeal: true, connect GitHub Actions to AWS ECR using OIDC, and add Argo Rollouts canaries with automated analysis.
Key Takeaways
- Separate application source code from Kubernetes manifests using Kustomize directory structures (
base/andoverlays/) so application commits and deployment changes have separate histories and permissions. - Deploy Argo CD in High Availability mode via Helm by enabling
redis-haand running two replicas of the server, repo server and ApplicationSet controller (HA needs at least 3 nodes). - Prevent configuration drift and manual
kubectloverrides by enablingselfHeal: truein your ArgoCDApplicationmanifest. - Configure GitHub Actions to update the image tag directly in
kustomization.yamlafter pushing to ECR, allowing ArgoCD to pull the changes automatically. - Secure your CI/CD boundary by authenticating GitHub Actions to AWS using OpenID Connect (OIDC) rather than storing long-lived IAM user credentials.
A green deployment pipeline does not always mean a healthy release.
In a traditional push-based CI/CD setup, a GitHub Action or Jenkins job authenticates with your Kubernetes cluster and executes kubectl set image or helm upgrade. The pipeline turns green, and your team assumes the release was successful. Meanwhile, inside the cluster, your new pods are stuck in a CrashLoopBackOff state due to a missing environment variable.
Worse, when an engineer manually hotfixes the cluster via the CLI to resolve an outage, you introduce Configuration Drift. The cluster state no longer matches your Git repository. The next time the pipeline runs, it overwrites the hotfix, re-introducing the outage.
Push-based deployments also need cluster credentials in CI and have no built-in way to detect or correct drift.
GitOps addresses this by reversing the flow from push to pull, so Git is the source of truth for what runs in the cluster. In this guide, we build a deployment pipeline using AWS EKS, GitHub Actions, Argo CD, and Argo Rollouts for automated canary releases.
The Architecture of Pull-Based GitOps
In a GitOps model, your CI pipeline does not communicate with your Kubernetes cluster. It only interacts with your container registry (like AWS ECR) and a Git repository.
We separate the codebase into two repositories (or clearly separated directories):
- The Application Repository: Contains the source code (e.g., Node.js), Dockerfile, and unit tests.
- The Manifest Repository: Contains pure Kubernetes YAML manifests managed via Helm or Kustomize.
Production Note: The Argo CD documentation recommends keeping manifests in a separate Git repository from application source. It gives you a clean audit log of deployment changes, lets you restrict who can change production, and avoids CI loops where the manifest commit triggers another build.
Here is the architectural directory structure of our Manifest Repository using Kustomize:
infrastructure-manifests/
├── overlays/
│ ├── production/
│ │ ├── kustomization.yaml
│ │ ├── rollout-patch.yaml
│ │ └── ingress.yaml
│ └── staging/
│ ├── kustomization.yaml
│ └── ...
└── base/
├── kustomization.yaml
├── rollout.yaml
├── service.yaml
└── configmap.yaml
When a developer merges a Pull Request, the CI pipeline builds the Docker image, pushes it to ECR, and commits the new image tag directly to the kustomization.yaml file in the Manifest Repository. Argo CD, running inside EKS, polls this repository (every 3 minutes by default, or immediately if you configure a Git webhook). When it detects a new commit, it reconciles the cluster to match.
Provisioning ArgoCD on AWS EKS
To set up the GitOps controller, install Argo CD on the EKS cluster. We will use Helm for the initial bootstrap.
First, create a dedicated namespace and deploy the Argo CD Helm chart. The chart installs a non-HA setup by default; the values below follow the chart's HA example without autoscaling. Pin --version to the chart release you have tested.
# Add the ArgoCD Helm repository
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
# Create namespace
kubectl create namespace argocd
# Install Argo CD in HA mode (requires at least 3 worker nodes)
helm install argocd argo/argo-cd \
--namespace argocd \
--set redis-ha.enabled=true \
--set controller.replicas=1 \
--set server.replicas=2 \
--set repoServer.replicas=2 \
--set applicationSet.replicas=2
If TLS terminates at your ingress or load balancer, you can additionally set configs.params."server\.insecure"=true so the Argo CD server serves plain HTTP behind it. Do not expose an insecure server directly.
Once installed, Argo CD needs to know which repository to monitor. We define this with an Argo CD Application resource. Apply the following manifest to your cluster to instruct ArgoCD to watch your production overlay:
# argocd-app.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: nodejs-microservice-production
namespace: argocd
spec:
project: default
source:
repoURL: '[email protected]:your-org/infrastructure-manifests.git'
targetRevision: HEAD
path: overlays/production
destination:
server: 'https://kubernetes.default.svc'
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: true
The selfHeal: true flag handles configuration drift. If someone deletes a Deployment or edits a ConfigMap with kubectl, Argo CD detects that the live state differs from Git and syncs it back, usually within seconds of noticing. prune: true also deletes resources that were removed from Git. Emergency hotfixes therefore have to go through Git too, which is the point.
Bridging the Gap: GitHub Actions to EKS
With Argo CD watching the manifest repository, the CI pipeline only builds the image and updates the manifests.
Avoid long-lived IAM user access keys in CI. GitHub Actions can authenticate to AWS with OpenID Connect (OIDC): the workflow requests a short-lived token, and an IAM role whose trust policy is restricted to your repository and branch exchanges it for temporary credentials. If you want help designing this pipeline, see our cloud deployment services.
Here is the GitHub Actions workflow (.github/workflows/deploy.yml) that builds the Docker image, pushes it to ECR, and updates the Kustomize manifests. Action versions are the current major versions at the time of writing; pin them (ideally to commit SHAs):
name: Build and Update Manifests
on:
push:
branches:
- main
permissions:
id-token: write
contents: read
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Application Code
uses: actions/checkout@v7
- name: Configure AWS Credentials via OIDC
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::123456789012:role/GitHubActionsECRRole
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: nodejs-microservice
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Checkout Manifest Repository
uses: actions/checkout@v7
with:
repository: your-org/infrastructure-manifests
# Fine-grained token or GitHub App token scoped to this repo only
token: ${{ secrets.GITOPS_TOKEN }}
path: manifests
- name: Update Kustomize Image Tag
run: |
cd manifests/overlays/production
kustomize edit set image backend-api=${{ steps.login-ecr.outputs.registry }}/nodejs-microservice:${{ github.sha }}
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add kustomization.yaml
git commit -m "chore: update production image to ${{ github.sha }}"
git pull --rebase
git push
kustomize edit set image updates the images: entry in kustomization.yaml without hand-written sed replacements (kustomize is preinstalled on GitHub-hosted Ubuntu runners). The git pull --rebase avoids a rejected push when two builds finish close together. The token for the manifest repository should be a fine-grained personal access token or a GitHub App installation token (for example via actions/create-github-app-token) with write access to that one repository. Once the commit lands, Argo CD detects it and starts the deployment.
Implementing Automated Canary Rollouts with Argo Rollouts
A standard Kubernetes Deployment uses a RollingUpdate strategy, replacing old pods with new pods incrementally. It offers limited control: you cannot gate progress on metrics, and traffic split follows the ratio of old to new pods rather than a weight you choose.
Argo Rollouts adds a Rollout resource, a Kubernetes controller for progressive delivery strategies like Canary and Blue-Green.
First, install the Argo Rollouts controller on your EKS cluster, pinned to a specific release (v1.10.2 at the time of writing) rather than latest:
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/download/v1.10.2/install.yaml
Next, in your manifest repository, change kind: Deployment to kind: Rollout. We will configure a canary strategy that sends 10% of traffic to the new version using weighted target groups in the AWS Load Balancer Controller. ALB traffic routing requires two Services, one for stable pods and one for canary pods; Argo Rollouts manages their selectors.
# rollout.yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: nodejs-microservice
namespace: production
spec:
replicas: 5
revisionHistoryLimit: 2
selector:
matchLabels:
app: nodejs-microservice
template:
metadata:
labels:
app: nodejs-microservice
spec:
containers:
- name: backend-api
image: backend-api # Name only; Kustomize sets the registry and tag
ports:
- containerPort: 3000
strategy:
canary:
# Services that select stable and canary pods (both required for ALB)
stableService: nodejs-service-stable
canaryService: nodejs-service-canary
# Traffic routing using AWS ALB weighted target groups
trafficRouting:
alb:
ingress: microservice-ingress
servicePort: 80
steps:
- setWeight: 10
- pause: { duration: 15m } # Sit at 10% traffic for 15 mins
- setWeight: 50
- pause: { duration: 5m } # Move to 50% for 5 mins
- setWeight: 100
With this configuration, when Argo CD syncs a new image tag, Argo Rollouts creates canary pods and updates the Ingress annotations so the AWS Load Balancer Controller sets the ALB listener rule to weight 10% of requests to the canary target group. The Ingress must route to the stable Service. The rollout pauses for 15 minutes, giving your team (or your automated monitoring tools) time to verify application health.
Handling Node.js Graceful Shutdowns in Kubernetes
A canary strategy loses much of its value if your application drops in-flight requests when old pods are scaled down.
When Kubernetes terminates a pod, it sends SIGTERM to the container. Node.js's default action for SIGTERM is to exit immediately, cutting off in-flight HTTP requests.
Here is a basic graceful shutdown pattern:
// server.js
const express = require('express');
const app = express();
app.get('/healthz', (req, res) => {
res.status(200).send('OK');
});
// ... your API routes ...
const server = app.listen(3000, () => {
console.log('Server listening on port 3000');
});
// Handle Kubernetes SIGTERM for graceful shutdown
process.on('SIGTERM', () => {
console.log('SIGTERM received. Initiating graceful shutdown.');
// server.close stops accepting new connections and waits for open ones to finish.
// Endpoint removal happens in parallel, so pair this with a preStop sleep.
server.close((err) => {
if (err) {
console.error(err);
process.exit(1);
}
console.log('All active connections gracefully closed. Exiting.');
process.exit(0);
});
});
Tip: Because the ALB and kube-proxy stop routing to a terminating pod asynchronously, add a short
preStopsleep (5 to 10 seconds) so new requests stop arriving beforeserver.close()runs, and keep the ALB target group deregistration delay belowterminationGracePeriodSeconds. Point thereadinessProbeat/healthzso canary pods only receive traffic once ready, and keep the liveness probe cheap so it does not restart pods under load.
Monitoring and Automated Rollbacks
Argo Rollouts can also evaluate metrics during a canary release. Instead of manually watching dashboards, we can automate rollbacks using an AnalysisTemplate.
By integrating Argo Rollouts with Prometheus, we can continuously monitor the new canary version. If the canary's 5xx error rate crosses a threshold, Argo Rollouts aborts the rollout and shifts traffic back to the stable version.
Here is an AnalysisTemplate definition that queries Prometheus for error rates:
# analysis-template.yaml
apiVersion: argoproj.io/v1alpha1
kind: AnalysisTemplate
metadata:
name: error-rate-check
spec:
args:
- name: service-name
metrics:
- name: http-5xx-errors
interval: 1m
count: 5 # Take 5 measurements, one per minute
failureLimit: 1 # Abort after more than one failed measurement
# Treat "no traffic yet" (NaN) as passing; fail above 5% errors
successCondition: isNaN(result[0]) || result[0] < 0.05
provider:
prometheus:
address: http://prometheus-server.monitoring.svc.cluster.local:9090
query: |
sum(rate(http_requests_total{status=~"5.*", service="{{args.service-name}}"}[1m]))
/
sum(rate(http_requests_total{service="{{args.service-name}}"}[1m]))
The query assumes your service exports an http_requests_total counter with status and service labels; adjust it to your metric names. To scope it to canary pods only, add a label that distinguishes canary pods (for example via canaryMetadata). To bind this analysis to your Rollout, add an analysis step to your strategy:
steps:
- setWeight: 10
- analysis:
templates:
- templateName: error-rate-check
args:
- name: service-name
value: nodejs-microservice
- pause: { duration: 15m }
The flow is now: a developer merges code to main, GitHub Actions builds the image and updates the manifest, Argo CD applies it to EKS, Argo Rollouts starts a 10% canary, and Prometheus analysis decides whether to continue.
If the error rate is too high, the rollout aborts and traffic returns to the stable version; set up notifications (for example Argo Rollouts notifications to Slack) so someone sees it. If the analysis passes, the rollout proceeds to 100%. This catches errors visible in metrics; it does not replace tests, and bugs that do not raise the error rate will still reach full traffic. Note that after an abort, Git still points to the bad image, so revert the manifest commit to bring Git and the cluster back in line.
Sources
- Argo CD Helm chart README (HA values,
server.insecure) - Argo Rollouts documentation: AWS Load Balancer Controller traffic routing (required
stableServiceandcanaryService) - Argo Rollouts documentation: Analysis (
count,failureLimit, handling NaN results) - GitHub Docs: Configuring OpenID Connect in Amazon Web Services
Need help building this in production?
SoftwareCrafting is a full-stack dev agency - we ship fast, scalable React, Next.js, Node.js, React Native & Flutter apps for global clients.
Get a Free ConsultationFrequently Asked Questions
What is pull-based GitOps?
An agent in the cluster, such as Argo CD, watches a Git repository and applies whatever it describes. CI never needs cluster credentials; it only commits a new image tag, and Git becomes the record of what is deployed.
How does a canary rollout work with Argo Rollouts?
The new version receives a small share of traffic first, then more in steps. At each step, metrics such as error rate and latency are checked, and the rollout continues only if they stay within limits.
How are bad releases rolled back automatically?
Argo Rollouts runs an analysis against your metrics provider during the canary. If the analysis fails, it shifts traffic back to the stable version without anyone having to act.
Why does graceful shutdown matter for canary deployments?
Pods are created and removed many times during a rollout. If Node.js services do not finish in-flight requests on SIGTERM, every traffic shift produces errors that can fail the analysis and trigger a false rollback.
