A real-world DevOps implementation built on the Weaveworks Sock Shop microservices demo application. This project demonstrates end-to-end CI/CD, GitOps, security scanning, and Kubernetes failure scenario debugging — skills directly applicable to production DevOps roles.
Developer pushes code to front-end repo
↓
Jenkins CI Pipeline (on EC2)
├── Build Docker image
├── Trivy security scan (CRITICAL CVE gate)
├── Push to Docker Hub (only if scan passes)
└── Update image tag in sockshop-gitops repo
↓
Argo CD detects change in sockshop-gitops
↓
Argo CD deploys to Kubernetes (sock-shop namespace)
↓
Rolling update with zero downtime
↓
Prometheus scrapes pod metrics
↓
Grafana displays real-time dashboards
| Component | Technology | Details |
|---|---|---|
| Kubernetes Cluster | kubeadm on AWS EC2 | 1 Master + 1 Worker, t2.medium, Ubuntu 22.04 |
| Container Runtime | containerd | v1.29 |
| CNI Plugin | Calico | Pod network CIDR 192.168.0.0/16 |
| CI Pipeline | Jenkins | v2.541.3, running on master node |
| CD Pipeline | Argo CD | v3.3.4, GitOps continuous delivery |
| Image Registry | Docker Hub | Public registry |
| Security Scanning | Trivy | CRITICAL CVE gate in pipeline |
| Metrics | metrics-server | Required for HPA |
| Monitoring | Prometheus + Grafana | kube-prometheus-stack v61.x via Helm |
sockshop-gitops/ ← This repo (GitOps manifests)
├── manifests/
│ └── front-end/
│ └── deployment.yaml ← Raw Kubernetes deployment manifest
└── helm/
└── front-end/
├── Chart.yaml ← Helm chart metadata
├── values.yaml ← Default values
├── values-dev.yaml ← Dev environment overrides
├── values-prod.yaml ← Prod environment overrides
└── templates/
└── deployment.yaml ← Parameterized Helm template
front-end/ ← Separate repo (application source)
├── Dockerfile ← Hardened, production-grade
├── Jenkinsfile ← CI pipeline definition
├── package.json ← Dependencies with security resolutions
└── .dockerignore ← Prevents sensitive file inclusion
| Repo | Purpose | Watched By |
|---|---|---|
front-end |
Source code, Dockerfile, Jenkinsfile | Jenkins |
sockshop-gitops |
Kubernetes manifests | Argo CD |
This separation ensures:
- Git is the single source of truth for cluster state
- Every deployment is a traceable git commit
- Rollback =
git revert, not re-running a pipeline - Argo CD continuously reconciles cluster state with repo
Checkout → Unit Tests → Build Docker Image → Trivy Scan → Push to Docker Hub → Update GitOps Repo → Cleanup
| Stage | Description |
|---|---|
| Checkout | Pulls latest code from front-end repo |
| Unit Tests | Runs 22 mocha tests with istanbul coverage — fails pipeline if any test fails |
| Build Docker Image | Builds image tagged with Jenkins build number e.g. v1.15 |
| Trivy Scan | Scans for CRITICAL CVEs — pipeline fails and blocks push if found |
| Push to Docker Hub | Pushes clean image only after scan passes |
| Update GitOps Repo | Updates deployment.yaml AND helm/front-end/values.yaml image tag automatically via sed + git push |
| Cleanup | Removes local image to free disk space |
The Trivy scan stage uses --exit-code 1 which fails the pipeline on any CRITICAL vulnerability. This means:
- No CRITICAL CVE image ever reaches the cluster
- The push stage is completely blocked until the image is clean
- Every build has a documented security scan result
The original Sock Shop front-end Dockerfile had multiple production issues. All were identified and fixed:
| Issue | Original | Fixed |
|---|---|---|
| Base image | node:10-alpine (EOL April 2021) |
node:22-alpine3.22 (LTS) |
| ENV syntax | Legacy ENV key value |
Modern ENV key="value" |
| Package manager | Mixed yarn/npm | Consistent yarn throughout |
| Health check | None | HEALTHCHECK with proper intervals |
| Build context | No .dockerignore |
.dockerignore excludes node_modules, .git, .env |
Initial Trivy scan found 13 CRITICAL vulnerabilities in node_modules dependencies.
| Package | CVE | Type | Fix |
|---|---|---|---|
morgan 1.7.0 |
CVE-2019-5413 | Unescaped input injection | Upgraded to 1.9.1 in package.json |
bson 1.0.9 |
CVE-2020-7610 | Code injection via deserialization | Pinned to 1.1.4 via yarn resolutions |
handlebars 4.5.1 |
CVE-2021-23369 | Remote code execution | Pinned to 4.7.7 via yarn resolutions |
minimist 0.0.10 |
CVE-2021-44906 | Prototype pollution | Pinned to 1.2.6 via yarn resolutions |
growl 1.9.2 |
CVE-2017-16042 | Command injection | Pinned to 1.10.0 via yarn resolutions |
json-schema 0.2.3 |
CVE-2021-3918 | Prototype pollution | Pinned to 0.4.0 via yarn resolutions |
form-data 1.0.0 |
CVE-2025-7783 | Unsafe random function | Pinned to 4.0.4 via yarn resolutions |
Result: 13 CRITICAL → 0 CRITICAL
Each scenario was deliberately triggered, debugged, and resolved to demonstrate real-world troubleshooting competency.
What was broken:
Removed resources.requests.cpu from the front-end deployment directly via kubectl edit.
Symptom:
kubectl get hpa -n sock-shop
# TARGETS shows <unknown>/50% instead of actual CPU%Root cause:
HPA calculates CPU utilization as actual usage / requested CPU × 100. Without requests.cpu defined, the denominator is zero — HPA cannot calculate utilization and makes no scaling decisions regardless of actual CPU load.
Debug commands used:
kubectl get hpa -n sock-shop
kubectl describe hpa front-end -n sock-shop # Check Conditions section
kubectl describe deployment front-end -n sock-shop | grep -A5 RequestsFix:
Restored resources.requests.cpu: 100m via Argo CD sync from GitOps repo.
Bonus — Argo CD Drift Detection:
The direct kubectl edit change caused Argo CD to show OutOfSync — demonstrating that any manual cluster change is automatically detected. Fix was applied by syncing through Argo CD, not by running another kubectl command.
What was broken:
Injected command: ["/bin/sh", "-c", "exit 1"] into deployment.yaml and pushed via GitOps.
Symptom:
kubectl get pods -n sock-shop
# front-end showing CrashLoopBackOff with increasing restart countRoot cause: Container was instructed to exit immediately with error code 1 on every startup. Kubernetes kept restarting it — each restart hit the same exit — creating the CrashLoopBackOff loop.
Debug commands used:
kubectl describe pod <pod-name> -n sock-shop # Showed bad command + Exit Code 1
kubectl logs <pod-name> -n sock-shop # Empty — container exits too fast
kubectl logs <pod-name> -n sock-shop --previous # Previous container instance logsKey insight:
kubectl logs --previous is critical for CrashLoopBackOff debugging — current logs are often empty because the container has already crashed. Always check previous container logs.
Fix:
Removed bad command from deployment.yaml, pushed to GitOps repo. Argo CD auto-synced and redeployed clean version.
What was broken:
Set memory limit to 10Mi and request to 8Mi in deployment.yaml.
Symptom:
kubectl describe pod <pod-name> -n sock-shop
# Last State: Terminated
# Reason: OOMKilled
# Exit Code: 137Root cause: Node.js requires significantly more than 10Mi to run. The moment the process tried to allocate memory beyond the limit, the Linux kernel OOM killer terminated the container. Kubernetes restarted it — same result — CrashLoopBackOff.
Debug commands used:
kubectl describe pod <pod-name> -n sock-shop | grep -A5 "Last State"
kubectl top pod -n sock-shop # Check actual memory consumptionHow to distinguish OOMKilled from other crashes:
| Exit Code | Reason | Cause |
|---|---|---|
| 137 | OOMKilled | Memory limit exceeded |
| 1 | Error | Application crash or bad command |
| 0 | Completed | App exited cleanly (wrong for a server) |
Fix:
Restored memory limit to 256Mi — 2x observed actual usage of ~120Mi. Pushed via GitOps, Argo CD synced.
What was broken:
Deployment manifest referenced v1.1 but only v1.2 existed on Docker Hub (build v1.1 had failed in Jenkins).
Symptom:
kubectl describe pod <pod-name> -n sock-shop
# Events: Failed to pull image — not foundRoot cause:
Tag mismatch between manifest and registry. imagePullPolicy: IfNotPresent with a non-existent tag will always fail — the image simply doesn't exist to pull.
Fix:
Updated image tag in deployment.yaml to match the actual pushed tag. Automated this permanently by adding an Update GitOps Repo stage to the Jenkins pipeline that uses sed to update the tag automatically after every successful build.
The raw deployment.yaml in manifests/ has hardcoded values — one file, one environment. Helm converts it into a parameterized template, allowing the same chart to deploy with different configurations per environment.
helm/front-end/
├── Chart.yaml ← Chart metadata (name, version, description)
├── values.yaml ← Default values — used as base
├── values-dev.yaml ← Dev overrides — lower resources, 1 replica
├── values-prod.yaml ← Prod overrides — higher resources, 3 replicas
└── templates/
└── deployment.yaml ← Template with {{ .Values.x }} placeholders
| Setting | Dev | Prod |
|---|---|---|
replicaCount |
1 | 3 |
resources.requests.cpu |
100m | 200m |
resources.requests.memory |
128Mi | 256Mi |
resources.limits.cpu |
300m | 500m |
resources.limits.memory |
256Mi | 512Mi |
image.pullPolicy |
Always | Always |
Helm merges values files in order — values.yaml provides defaults, environment-specific files override them:
values.yaml (defaults)
+
values-dev.yaml (overrides)
=
Final rendered manifest
Example template syntax:
spec:
replicas: {{ .Values.replicaCount }} # Replaced with 1 (dev) or 3 (prod)
containers:
- image: {{ .Values.image.repository }}:{{ .Values.image.tag }} # Replaced with actual image
resources:
limits:
memory: {{ .Values.resources.limits.memory }} # 256Mi (dev) or 512Mi (prod)# Preview dev deployment
helm template front-end helm/front-end -f helm/front-end/values-dev.yaml
# Preview prod deployment
helm template front-end helm/front-end -f helm/front-end/values-prod.yamlArgo CD automatically detects Helm charts by finding Chart.yaml in the source path. The front-end-dev Argo CD application is configured to:
- Source:
helm/front-endpath in this repo - Values file:
values-dev.yaml - Auto-sync: enabled — deploys automatically on every git push
Every Jenkins build automatically updates the image tag in both files:
manifests/front-end/deployment.yaml— raw manifesthelm/front-end/values.yaml— Helm default values
This ensures both deployment methods always use the latest built and scanned image.
Installed using the kube-prometheus-stack Helm chart — the industry standard monitoring stack for Kubernetes.
| Component | Role |
|---|---|
| Prometheus | Scrapes and stores metrics from all pods and Kubernetes components as time-series data |
| Grafana | Queries Prometheus and visualizes metrics as dashboards and graphs |
| AlertManager | Handles alerts triggered by Prometheus rules |
| Node Exporter | Collects node-level metrics — CPU, memory, disk per EC2 instance |
| kube-state-metrics | Collects Kubernetes object metrics — pod restarts, deployment status, HPA state |
Prometheus uses a pull model — it scrapes metrics from configured endpoints at regular intervals:
Prometheus
├── scrapes /metrics endpoint on each pod
├── scrapes Kubernetes API for cluster metrics
├── scrapes Node Exporter for node metrics
└── stores everything as time-series data with timestamps
This is different from metrics-server which only stores current values in memory with no history.
Built a custom Grafana dashboard with 4 panels specifically for the front-end service:
| Panel | PromQL Query | Purpose |
|---|---|---|
| CPU Usage | rate(container_cpu_usage_seconds_total{namespace="sock-shop", pod=~"front-end.*"}[5m]) |
Real-time CPU consumption |
| Memory Usage | container_memory_working_set_bytes{namespace="sock-shop", pod=~"front-end.*"} |
Memory in bytes — same metric Kubernetes uses for OOMKilled |
| Pod Restarts | kube_pod_container_status_restarts_total{namespace="sock-shop", pod=~"front-end.*"} |
Restart count — rising number means CrashLoopBackOff or OOMKilled |
| Pod Health | kube_pod_status_ready{namespace="sock-shop"} |
1 = ready, 0 = not ready — instant health overview |
- Memory panel uses
container_memory_working_set_bytes— this is exactly what Kubernetes checks against the memory limit. If it exceeds256Mi, OOMKilled happens - Restart count panel is the most important production alert — a rising number means the pod is crashing repeatedly before you even notice in kubectl
- CPU Usage showed ~0.001 cores for front-end at idle — confirming
requests.cpu: 100mis appropriately sized
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus-stack prometheus-community/kube-prometheus-stack \
--namespace monitoring \
--set grafana.adminPassword=admin123 \
--set prometheus.prometheusSpec.retention=24hAccess Grafana:
kubectl patch svc prometheus-stack-grafana -n monitoring -p '{"spec": {"type": "NodePort"}}'
kubectl get svc -n monitoring | grep grafana
# Access via http://<node-ip>:<nodeport>- Resource requests are mandatory for HPA — without them HPA is completely blind
kubectl logs --previousis the most important CrashLoopBackOff debug command- OOMKilled = Exit Code 137 — always check Last State in describe output
- GitOps drift detection — any manual kubectl change is automatically flagged by Argo CD
- Trivy in CI — security scanning belongs in the pipeline as a gate, not as a post-incident tool
- Two-repo strategy — separating app code from manifests gives clean audit trail and proper separation of concerns
- Helm values hierarchy —
values.yamlsets defaults, environment files override — never duplicate what you can parameterize helm templatebefore deploy — always dry-run to catch errors before they reach the cluster- Prometheus pull model — Prometheus scrapes endpoints, it does not receive pushed metrics — this affects how you configure exporters
- sed quoting in Jenkins — single quotes prevent variable expansion, use
'string'${VAR}'string'pattern for mixed quoting inside shell blocks
| Tool | Version |
|---|---|
| Kubernetes | v1.29.15 |
| kubeadm | v1.29.15 |
| Jenkins | v2.541.3 |
| Argo CD | v3.3.4 |
| Helm | v3.20.1 |
| Trivy | Latest |
| Docker | v28.x |
| Node.js | v22 (LTS) |
| Calico CNI | v3.26.0 |
| metrics-server | Latest |
| Prometheus | kube-prometheus-stack |
| Grafana | kube-prometheus-stack |
Sandeep Charan DevOps Engineer | AWS | Kubernetes | Jenkins | Argo CD | Docker | Terraform | Grafana GitHub