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.pem
ssh -i /home/paacyber/Downloads/<keypair.pem> ubuntu@PublicIP
sudo apt update && sudo apt upgrade -y
sudo apt install docker.io -y
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
docker run hello-world
docker version
systemctl status docker
sudo snap install kubectl --classic
kubectl version --client
curl -LO https://github.com/kubernetes/minikube/releases/latest/download/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
minikube version
minikube start --driver=docker
kubectl get nodes
minikube 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.git
mkdir .github
cd .github
mkdir 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 argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl get pods -n argocd
kubectl get svc -n argocd
First, add port 8080 to Inbound Rules for the EC2 Instance
kubectl port-forward --address 0.0.0.0 svc/argocd-server 8080:443 -n argocd
kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d && echo
On your browser:
PublicIP:8080
ARGOCD_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/argocd
argocd version
kubectl get svc -n argocd
kubectl edit svc argocd-server -n argocd
and
kubectl port-forward --address 0.0.0.0 svc/argocd-server 30007:80 -n argocd
kubectl port-forward --address 0.0.0.0 svc/argocd-server 30008:443 -n argocd
First,
- 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 argocd
kubectl 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 -y
The App has a page on /hello:
cat app.js
node app.js
On your browser:
PublicIP:3000/hello
kubectl get svc -n argocd
kubectl port-forward --address 0.0.0.0 svc/myapp-service 8080:80 -n argocd
On your browser:
PublicIP:8080/hello
kubectl delete ns argocd
minikube stop
minikube delete --all
Terminate the EC2 Instance on AWS
Thanks for Watching
Please Like, Comment, and Subscribe to iQuant on YouTube