Introduction
GitOps transforms infrastructure management by placing Git at the center of operations. With ArgoCD, code changes automatically trigger deployments on Kubernetes. This approach ensures traceability, reproducibility, and instant rollbacks. In 2026, DevOps teams are widely adopting GitOps to reduce manual errors and improve security. This tutorial guides you step by step through a solid intermediate implementation.
Prerequisites
- Kubernetes 1.28+ with a configured cluster
- kubectl and Helm installed
- Access to a Git repository (GitHub or GitLab)
- Basic knowledge of Kubernetes manifests
Installing ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'This command creates the namespace and deploys ArgoCD. The patch exposes the service via LoadBalancer for initial access. Wait for all pods to be ready before continuing.
Retrieving the Admin Password
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -dArgoCD generates an initial password stored in a secret. This command retrieves it for the first login via the web interface.
Creating the GitOps Repository
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/votre-org/gitops-repo.git
targetRevision: HEAD
path: manifests
destination:
server: https://kubernetes.default.svc
namespace: production
syncPolicy:
automated:
prune: true
selfHeal: trueThis manifest declares an ArgoCD Application that automatically syncs the manifests folder from the Git repository to the production namespace.
Deploying a Sample Application
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: production
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80This Deployment file is versioned in Git. ArgoCD detects it and automatically deploys it to the cluster.
Configuring the Service
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: production
spec:
selector:
app: nginx
ports:
- port: 80
targetPort: 80
type: ClusterIPThe Service exposes the Deployment inside the cluster. It is synced at the same time as the Deployment through the same ArgoCD Application.
Best Practices
- Always enable prune and selfHeal in the syncPolicy
- Use protected branches and pull requests for changes
- Separate environments by folders (dev, staging, prod)
- Add custom health checks in Applications
- Version Helm charts rather than inline values
Common Mistakes to Avoid
- Forgetting to configure the Git webhook to trigger syncs
- Leaving secrets in plain text in the Git repository
- Not enabling automated mode on critical production environments
- Ignoring merge conflicts during simultaneous updates
Going Further
Explore our advanced GitOps and ArgoCD courses: https://example.com/advanced-trainings