A complete implementation of GitOps workflow using ArgoCD on Kubernetes (k3s) running on AWS EC2 Ubuntu instance.
- Features
- Architecture
- Prerequisites
- Setup Guide
- Usage
- Testing GitOps
- Troubleshooting
- Contributing
- License
- Git as Single Source of Truth - All Kubernetes manifests stored in Git
- Automated Synchronization - ArgoCD auto-syncs changes from Git to cluster
- Self-Healing - Automatic drift correction
- Declarative Infrastructure - Everything defined as code
- Easy Rollbacks - Git history enables version control
graph TD
A[GitHub Repository] -->|Manifests| B(ArgoCD)
B -->|Applies| C[Kubernetes Cluster]
C -->|Status| B
B -->|Visualization| D[ArgoCD Dashboard]
- AWS account with EC2 access
- Ubuntu 22.04 EC2 instance (t2.medium recommended) -GitHub account -Basic knowledge of Kubernetes and Git
-
- Launch EC2 Instance
-
Ubuntu 22.04 LTS
-
t2.medium instance type
-
Security groups allowing:
-
SSH (22)
-
HTTP (80)
-
HTTPS (443)
-
NodePort (30000-32767)
-
- Install Dependencies
ssh -i "your-key.pem" ubuntu@<EC2_PUBLIC_IP>
sudo apt update && sudo apt upgrade -y
sudo apt install -y docker.io git curl
-
- Install k3s (Lightweight Kubernetes)
curl -sfL https://get.k3s.io | sh -
sudo kubectl get nodes # Verify installation
-
- Deploy ArgoCD
sudo kubectl create namespace argocd
sudo kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
-
- Access ArgoCD UI
sudo kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
echo "Username: admin"
sudo kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
Access dashboard at: http://<EC2_PUBLIC_IP>
- Clone this repository
git clone https://github.com/your-username/gitops-apps.git
cd gitops-apps
Configure ArgoCD Application
In ArgoCD UI, create new application:
Application Name: nginx-app
Project: default
Sync Policy: Automatic
Repository URL: Your Git repo URL
Path: nginx-deployment/
Cluster: https://kubernetes.default.svc
Namespace: default
Verify Deployment
sudo kubectl get pods
sudo kubectl get svc nginx-service
Access Nginx at: http://<NGINX_SERVICE_IP>
- Make changes to manifests in Git
vim nginx-deployment/deployment.yaml
- Commit and push changes
git add .
git commit -m "Update nginx version"
git push origin main
- Watch ArgoCD automatically sync changes!
- Issue: ArgoCD pods not starting
sudo kubectl get pods -n argocd
sudo kubectl describe pod <pod-name> -n argocd
sudo kubectl logs <pod-name> -n argocd
- Issue: Cannot access ArgoCD UI
sudo kubectl get svc -n argocd
🤝 Contributing Contributions are welcome! Please open an issue or submit a PR.
Fork the repository
Create your feature branch (git checkout -b feature/fooBar)
Commit your changes (git commit -am 'Add some fooBar')
Push to the branch (git push origin feature/fooBar)
Create a new Pull Request
📜 License Distributed under the MIT License. See LICENSE for more information.
Made with ❤️ by H Sareen Kumar