In this video, we take DevOps to the next level by building a complete GitOps-driven CI/CD pipeline using GitHub Actions and ArgoCD, deployed on Kubernetes! π₯
YouTube Link: https://youtu.be/TZuNSMTWAcY?si=ZP5Sc7RbtQ0bFsgE
- GitHub Actions
- ArgoCD:
- Expose ArgoCD via Public Tunnel (For Dev ENV) e.g., ngrok, inlets
- Deploy ArgoCD on Public Cloud (For Prod ENV w/ TLS Certs) e.g., EC2, EKS, GKE, etc
- Cloud Linux Instance (since GitHub Actions runs in the cloud) - AWS EC2 Ubuntu - t3.medium
- Docker
- Kubernetes cluster (Minikube)
- Kubectl
chmod 600 keypair.pemssh -i /home/paacyber/Downloads/<keypair.pem> ubuntu@PublicIPsudo apt update && sudo apt upgrade -ysudo apt install docker.io -ysudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
docker run hello-worlddocker versionsystemctl status dockersudo snap install kubectl --classickubectl version --clientcurl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64minikube versionminikube start --driver=dockerkubectl get nodesminikube addons enable ingress- Click on the User Account
- Click on Settings
- Developer settings, and select Personal access tokens and Click Tokens (classic)
- Generate new token, and select Generate new token (classic)
- Note: actions-argocd-gitops00, Expiration: 30 days, and
- Scopes (select the following):
- repo
- workflow (For GitHub Actions)
- admin:repo_hook (For Webhooks)
- Generate token & save it somewhere safe
git clone https://github.com/iQuantC/GitHubActions-ArgoCD-GitOps.gitmkdir .github
cd .githubmkdir workflows
cd workflow
touch argocd-actions.yml- Sign in to your DockerHub Account
- Click "Create a repository"
- Repository Name: gitHubActions-ArgoCD-00, Visibility: Public
- Click Create.
- Click on the User Account, Click on "Account settings", Click on "Personal access tokens"
- Click "Generate new token", Expiration: 30 days, Access permissions: RWD.
- Click Generate & save it somewhere safe
-
Click on the GitOps Repository and click on "Settings"
-
Click on "Secrets and variables" and select "Actions"
-
Under Repository secrets, click on "New repository secret"
Name: DOCKERHUB_USERNAME Secret: <dockerhub username> Add secret Name: DOCKERHUB_TOKEN Secret: <dockerhub token here> Add secret
kubectl create namespace argocdkubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlkubectl get pods -n argocdkubectl get svc -n argocdFirst, add port 8080 to Inbound Rules for the EC2 Instance
kubectl port-forward --address 0.0.0.0 svc/argocd-server 8080:443 -n argocdkubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d && echoOn your browser:
PublicIP:8080ARGOCD_USERNAME: admin
ARGOCD_PASSWORD: <argocd init password>curl -sSL -o argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
chmod +x argocd
sudo mv argocd /usr/local/bin/argocdargocd versionkubectl get svc -n argocdkubectl edit svc argocd-server -n argocdand
kubectl port-forward --address 0.0.0.0 svc/argocd-server 30007:80 -n argocdkubectl port-forward --address 0.0.0.0 svc/argocd-server 30008:443 -n argocdFirst,
- Click Settings
- Secrets and variables
- Actions
- New repository secret, to create new secrets for
Name: ARGOCD_SERVER
Value: PublicIP:30008
Add secret Name: ARGOCD_USERNAME
Value: admin
Add secret Name: ARGOCD_PASSWORD
Value: <argocd init password>
Add secret- Go to Settings
- Click on Repositories, and Connect Repo
- Connection Method: Via HTTPS
- Type: git
- Project: default
- Repository URL:
- Username (optional):
- Password (optional):
- TLS Client Certificate (optional):
- The remaining stuff optional. Leave as default and click CONNECT.
- Click on Applications
- Click New App
- Application Name: argocd-github-actions
- Project Name: default
- Sync Policy: Automatic
- Check Prune Resources & Self Heal
- Repo URL: Click and select the Repo you attached earlier
- Revision: main (this is the branch from which app is deployed)
- Path: manifest
- Cluster URL: Click and select the kubernetes.default.svc
- Namespace: argocd
- Leave the rest as default or Set them up if you want to.
argocd app create my-app \
--repo https://github.com/your-username/your-repo.git \
--path manifest \
--dest-server https://kubernetes.default.svc \
--dest-namespace argocd- Replace the Image with the Latest image built
- ArgoCD UI will automatically Sync it & Deem it healthy
kubectl get deploy -n argocdkubectl get svc -n argocd- Add "argocd app sync argocd-github-actions" block to the pipeline
- Commit changes and verify sync in the ArgoCD UI with Deploy, Svc, Pods, etc.
- Inspect a Pod to see the port it listens. On EC2 Inbound rules, allow the port 3000 - AnywhereIPv4 - node app
- Install NPM Modules on terminal & run the app
sudo apt install npm -y
sudo npm install -yThe App has a page on /hello:
cat app.jsnode app.jsOn your browser:
PublicIP:3000/hellokubectl get svc -n argocdkubectl port-forward --address 0.0.0.0 svc/myapp-service 8080:80 -n argocdOn your browser:
PublicIP:8080/hellokubectl delete ns argocdminikube stopminikube delete --allTerminate the EC2 Instance on AWS
Thanks for Watching
Please Like, Comment, and Subscribe to iQuant on YouTube