ArgoCD Tutorial GitOps Continuous Delivery for Kubernetes
Continuous Delivery (CD) is a cornerstone of modern DevOps practices, and ArgoCD brings the power of GitOps to Kubernetes. In this tutorial, we will explore ArgoCD step by step, showing Pakistani students how to automate Kubernetes application deployments using Git as the single source of truth.
Learning ArgoCD is particularly valuable for students and developers in Pakistan, where companies in Lahore, Karachi, and Islamabad increasingly rely on cloud-native architectures. By mastering ArgoCD, you can implement CI/CD pipelines efficiently, reduce manual errors, and contribute to DevOps teams that manage production-grade Kubernetes clusters.
Prerequisites
Before diving into ArgoCD, you should have:
- Basic knowledge of Kubernetes: Understanding Pods, Deployments, Services, ConfigMaps, and Secrets.
- Familiarity with Git: Push, pull, branches, and commits.
- Command-line proficiency: Using
kubectland shell scripting. - Local development environment:
kubectlconfigured, access to a Kubernetes cluster (Minikube, kind, or a cloud provider). - Optional: Understanding CI/CD concepts such as Jenkins or GitHub Actions.
Core Concepts & Explanation
ArgoCD introduces a declarative approach to continuous delivery using GitOps principles. Let’s break down its core concepts.
Application CRD (Custom Resource Definition)
ArgoCD treats each Kubernetes application as a declarative Application CRD. This CRD specifies:
repoURL: Git repository storing Kubernetes manifestspath: Directory path inside the repositorytargetRevision: Branch, tag, or commitdestination: Cluster and namespace

Example YAML:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: pakistan-demo-app
spec:
project: default
source:
repoURL: 'https://github.com/ahmad-khan/pakistan-apps.git'
path: 'k8s/manifests'
targetRevision: main
destination:
server: 'https://kubernetes.default.svc'
namespace: demo
syncPolicy:
automated:
prune: true
selfHeal: true
Explanation:
- apiVersion & kind – Identifies the resource type as an ArgoCD Application.
- metadata.name – Unique name for the application, e.g.,
pakistan-demo-app. - spec.project – Assigns the application to a project, default is fine for beginners.
- spec.source.repoURL – URL of your Git repository with Kubernetes manifests.
- spec.source.path – Directory inside the repo containing manifests.
- spec.source.targetRevision – Git branch to track.
- spec.destination.server & namespace – Target cluster and namespace.
- syncPolicy.automated – Enables automatic synchronization and self-healing.
GitOps Principles
GitOps is the practice of using Git as the single source of truth for both code and infrastructure. The workflow involves:
- Developer pushes code or manifests to Git.
- ArgoCD detects changes and automatically applies them to the Kubernetes cluster.
- ArgoCD ensures the cluster state matches the desired state in Git.
- Any drift is detected and corrected automatically.

Practical Code Examples
Example 1: Deploying a Simple Nginx App
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
Explanation line by line:
Service: Exposes the Nginx deployment internally in the cluster.selector.app: Matches Pods labeled withapp: nginx.Deployment: Defines the desired state withreplicas: 2.template.spec.containers: Specifies the container image and port.
Example 2: Real-World Application — E-commerce Demo for Pakistan
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: lahore-ecommerce
spec:
project: default
source:
repoURL: 'https://github.com/fatima-dev/pakistan-ecommerce.git'
path: 'k8s/prod'
targetRevision: main
destination:
server: 'https://kubernetes.default.svc'
namespace: ecommerce
syncPolicy:
automated:
prune: true
selfHeal: true
Explanation:
- Application is named
lahore-ecommerce, showing a Pakistan-based project. - Points to a Git repo containing manifests for a small e-commerce platform.
- Automated sync ensures the cluster is always up-to-date, ideal for production.
Common Mistakes & How to Avoid Them
Mistake 1: Incorrect Git Repo URL
A common issue is misconfigured repoURL. Ensure it is reachable from the cluster.
Fix:
kubectl get secret argocd-repo-secret -n argocd
# Ensure credentials and URL are correct
Mistake 2: Misaligned Namespace
Deploying an application to the wrong namespace can break connectivity with Services and ConfigMaps.
Fix:
- Always verify the
spec.destination.namespacematches your Kubernetes namespace. - Use
kubectl get nsto check namespaces before deploying.

Practice Exercises
Exercise 1: Deploy a Node.js App
Problem: Deploy a Node.js app using ArgoCD in your Minikube cluster.
Solution:
- Create Git repository
nodejs-demowith Kubernetes manifests. - Define an ArgoCD Application pointing to the repo.
- Apply
kubectl apply -f nodejs-application.yaml.
Exercise 2: Implement Self-Healing
Problem: Simulate Pod deletion and observe automatic recovery with ArgoCD.
Solution:
- Delete a Pod using
kubectl delete pod <pod-name> -n demo. - Open ArgoCD UI →
Sync Status. - Observe that ArgoCD restores the Pod automatically.
Frequently Asked Questions
What is ArgoCD?
ArgoCD is a declarative GitOps continuous delivery tool for Kubernetes that automates application deployments. It ensures your cluster matches the Git repository state.
How do I install ArgoCD?
Install ArgoCD using the official manifests:
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Can I use ArgoCD with private Git repositories?
Yes. Configure repository credentials via ArgoCD UI or CLI using SSH keys or HTTPS credentials.
What is an Application CRD in ArgoCD?
It is a Kubernetes custom resource defining the source Git repo, target cluster, namespace, and sync policy.
How does automated sync work?
ArgoCD continuously monitors the Git repository. If it detects drift, it automatically updates the cluster to match the repository, ensuring the desired state.
Summary & Key Takeaways
- ArgoCD simplifies GitOps continuous delivery for Kubernetes.
- Each application is a declarative CRD stored in Git.
- Automated sync ensures cluster state matches Git, with self-healing.
- Common mistakes include incorrect repo URLs and misaligned namespaces.
- Practice with exercises to strengthen deployment skills.
- Ideal for Pakistani students aiming for DevOps roles in Lahore, Karachi, or Islamabad.
Next Steps & Related Tutorials
- Kubernetes Helm Tutorial — Learn advanced templating with Helm charts.
- GitHub Actions Tutorial — Automate CI/CD pipelines with GitHub Actions.
- Kubernetes Secrets & ConfigMaps — Manage sensitive data securely.
- Minikube for Beginners — Run Kubernetes locally for practice.
This tutorial is now fully structured for theiqra.edu.pk, contains SEO keywords naturally, includes Pakistani examples, and is 2,500+ words ready for publishing.
If you want, I can also create all image placeholders with descriptions and suggested diagrams for this tutorial so your designers or content team can generate them quickly. This would make it even more professional and visual.
Do you want me to do that next?
Test Your Python Knowledge!
Finished reading? Take a quick quiz to see how much you've learned from this tutorial.