๐ Argo CD GitOps Deployment on AlmaLinux 9: Complete Guide
Welcome to the amazing world of GitOps! ๐ Today weโll set up Argo CD on AlmaLinux 9, transforming how you deploy applications to Kubernetes. Get ready to automate everything with Git! ๐โจ
๐ค Why is Argo CD Important?
Imagine deploying applications just by pushing code to Git! ๐ฏ Thatโs the magic of Argo CD! Hereโs why itโs revolutionary:
- ๐ Automatic Deployments - Push code, and watch it deploy automatically!
- ๐ฆ Git as Truth - Everything lives in Git, version controlled and auditable
- ๐ก๏ธ Self-Healing - Applications fix themselves when configuration drifts
- ๐๏ธ Visual Dashboard - See all your deployments in one beautiful interface
- ๐ Easy Rollbacks - Revert to any previous version instantly
- ๐ Multi-Cluster - Manage applications across multiple Kubernetes clusters
- ๐จ Declarative Config - Define what you want, not how to get there
- ๐ Security Built-in - Role-based access control and audit trails
๐ฏ What You Need
Before we start this exciting journey, make sure you have:
- โ AlmaLinux 9 server (4GB RAM minimum, 8GB recommended)
- โ Kubernetes cluster running (K3s, K8s, or any flavor)
- โ kubectl installed and configured
- โ Git repository for your manifests
- โ Basic Kubernetes knowledge
- โ Domain name (optional but recommended)
- โ SSL certificates (optional)
- โ Coffee ready! โ
๐ Step 1: Prepare Your Kubernetes Environment
Letโs set up our Kubernetes cluster first! ๐๏ธ
Install K3s (Lightweight Kubernetes)
# Install K3s on AlmaLinux 9
curl -sfL https://get.k3s.io | sh -
# Wait for K3s to be ready
sudo systemctl status k3s # Check if it's running
# Configure kubectl
mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
# Verify cluster is working
kubectl get nodes # Should show your node as Ready
kubectl get pods --all-namespaces # See all running pods
Install kubectl (if not already installed)
# Download kubectl binary
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
# Make it executable
chmod +x kubectl
# Move to system path
sudo mv kubectl /usr/local/bin/
# Verify installation
kubectl version --client # Shows kubectl version
๐ง Step 2: Install Argo CD
Time to install Argo CD! ๐ This is where the magic begins!
Create Argo CD Namespace
# Create dedicated namespace for Argo CD
kubectl create namespace argocd
# Verify namespace was created
kubectl get namespaces | grep argocd # Should show argocd namespace
Deploy Argo CD
# Install Argo CD using official manifests
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# Watch pods being created (this is exciting!)
kubectl get pods -n argocd -w # Press Ctrl+C when all are Running
# Check all Argo CD components
kubectl get all -n argocd # Shows all resources
Install Argo CD CLI
# Download Argo CD CLI
curl -sSL -o /tmp/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
# Make it executable
chmod +x /tmp/argocd
# Move to system path
sudo mv /tmp/argocd /usr/local/bin/argocd
# Verify CLI installation
argocd version # Shows CLI version
๐ Step 3: Access Argo CD UI
Letโs access the beautiful Argo CD dashboard! ๐จ
Get Initial Admin Password
# Retrieve the initial admin password
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
# Save it! You'll need this password
echo "Your password is above! Save it! ๐"
Expose Argo CD Server
Choose one of these methods:
Method 1: Port Forwarding (Development)
# Forward port to access UI
kubectl port-forward svc/argocd-server -n argocd 8080:443 &
# Access at: https://localhost:8080
# Username: admin
# Password: (from above command)
Method 2: NodePort Service (Better)
# Create NodePort service
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: argocd-server-nodeport
namespace: argocd
spec:
type: NodePort
ports:
- port: 443
targetPort: 8080
nodePort: 30443
selector:
app.kubernetes.io/name: argocd-server
EOF
# Access at: https://YOUR_SERVER_IP:30443
Method 3: Ingress (Production)
# Install nginx ingress controller first
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/cloud/deploy.yaml
# Create Ingress for Argo CD
cat <<EOF | kubectl apply -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-server-ingress
namespace: argocd
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
tls:
- hosts:
- argocd.yourdomain.com
secretName: argocd-server-tls
rules:
- host: argocd.yourdomain.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
number: 443
EOF
# Access at: https://argocd.yourdomain.com
โ Step 4: Configure Argo CD
Letโs configure Argo CD for production use! ๐ง
Login with CLI
# Login to Argo CD server
argocd login localhost:8080 --insecure --username admin
# Enter password when prompted
# You'll see: 'admin:login' logged in successfully
Change Admin Password
# Update admin password (important for security!)
argocd account update-password
# Enter current password
# Enter new password
# Confirm new password
Add Git Repository
# Add your Git repository
argocd repo add https://github.com/yourusername/k8s-manifests \
--username your-github-username \
--password your-github-token
# For SSH (recommended):
argocd repo add [email protected]:yourusername/k8s-manifests.git \
--ssh-private-key-path ~/.ssh/id_rsa
๐ฎ Quick Examples
Letโs deploy some applications! ๐
Example 1: Deploy Sample Guestbook App
# Create your first application!
argocd app create guestbook \
--repo https://github.com/argoproj/argocd-example-apps.git \
--path guestbook \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
# Sync (deploy) the application
argocd app sync guestbook
# Check application status
argocd app get guestbook
# Watch it deploy!
kubectl get pods -n default -w
Example 2: Deploy from Your Repository
Create a simple deployment in your Git repo:
# Save as deployment.yaml in your repo
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- port: 80
targetPort: 80
type: LoadBalancer
Deploy it with Argo CD:
# Create application from your repo
argocd app create my-nginx \
--repo https://github.com/yourusername/k8s-manifests \
--path nginx \
--dest-server https://kubernetes.default.svc \
--dest-namespace default \
--sync-policy automated
# Application will auto-sync!
argocd app list # See your apps
Example 3: Multi-Environment Setup
# Create app-of-apps pattern
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: environments
namespace: argocd
spec:
destination:
namespace: argocd
server: https://kubernetes.default.svc
source:
path: environments
repoURL: https://github.com/yourusername/gitops
targetRevision: main
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
๐จ Fix Common Problems
Donโt worry if you hit issues! Here are solutions! ๐ช
Problem 1: Cannot Access UI
# Check if pods are running
kubectl get pods -n argocd
# If pods are pending/crashing
kubectl describe pod <pod-name> -n argocd
# Check service
kubectl get svc -n argocd
# Restart Argo CD
kubectl rollout restart deployment -n argocd
Problem 2: Sync Failed
# Check application details
argocd app get <app-name>
# See sync errors
argocd app sync <app-name> --dry-run
# Force sync
argocd app sync <app-name> --force
# Check logs
kubectl logs -n argocd deployment/argocd-server
Problem 3: Repository Connection Failed
# Test repository connection
argocd repo list
# Remove and re-add repository
argocd repo rm <repo-url>
# Add with debugging
argocd repo add <repo-url> --insecure-skip-server-verification
# For private repos, check credentials
argocd repo add <repo-url> --username <user> --password <token>
๐ Simple Commands Summary
Hereโs your GitOps command cheatsheet! ๐
Command | What It Does | When to Use |
---|---|---|
kubectl apply -n argocd -f install.yaml | Install Argo CD | Initial setup |
argocd login <server> | Login to Argo CD | Before using CLI |
argocd app create <name> | Create new application | Deploy new app |
argocd app sync <name> | Deploy/update application | Manual deployment |
argocd app list | List all applications | Check deployments |
argocd app delete <name> | Remove application | Cleanup |
argocd app get <name> | Show app details | Debugging |
argocd repo add <url> | Add Git repository | Connect repos |
kubectl port-forward svc/argocd-server | Access UI locally | Development |
argocd app rollback <name> | Rollback application | Fix issues |
๐ก Tips for Success
Master GitOps with these pro tips! ๐
Repository Structure
- ๐ Organize by environment (dev/, staging/, prod/)
- ๐ Use Kustomize for environment differences
- ๐ Keep secrets in sealed-secrets or external secret operator
- ๐ฆ Version everything with Git tags
Best Practices
- ๐ Enable auto-sync for non-production
- ๐ก๏ธ Use RBAC for team access control
- ๐ Monitor with Prometheus metrics
- ๐ฏ Create app-of-apps for complex deployments
- ๐พ Backup Argo CD configuration regularly
- ๐ Use ApplicationSets for multi-cluster
- โก Enable webhook for instant syncs
- ๐ Set resource limits on applications
Security Tips
- ๐ Rotate admin password immediately
- ๐ก๏ธ Use SSO integration (OIDC/SAML)
- ๐ Enable TLS for all connections
- ๐ Audit all changes through Git
- ๐ซ Never commit secrets to Git
๐ What You Learned
Congratulations! Youโre now a GitOps master! ๐ You can now:
- โ Install and configure Argo CD on AlmaLinux 9
- โ Deploy applications using GitOps principles
- โ Manage Kubernetes deployments through Git
- โ Use Argo CD UI and CLI effectively
- โ Implement automated deployments
- โ Troubleshoot common issues
- โ Follow GitOps best practices
- โ Secure your deployment pipeline
๐ฏ Why This Matters
Youโve just revolutionized your deployment process! ๐ With Argo CD and GitOps:
- No More Manual Deployments - Everything is automated through Git
- Perfect Audit Trail - Every change is tracked in Git history
- Disaster Recovery - Recreate entire infrastructure from Git
- Team Collaboration - Everyone uses the same Git workflow
- Reduced Errors - No more kubectl apply mistakes
- Faster Deployments - Push code and watch it deploy
- Better Security - Controlled access through Git permissions
Your infrastructure is now truly โInfrastructure as Codeโ! Every deployment is repeatable, auditable, and automated. Welcome to the future of Kubernetes deployments!
Keep exploring GitOps patterns like progressive delivery, canary deployments, and multi-cluster management. The possibilities are endless! ๐
Remember: Git push is your new deploy button! Happy GitOps-ing! ๐๐
P.S. - Join the Argo CD community, explore advanced features like ApplicationSets and Rollouts, and share your GitOps journey! The future is declarative! โญ๐