
How to Build Infrastructure Continuous Delivery in ArgoCD
a day ago
3 min read
0
9
In this tutorial, we will demonstrate how GitHub can be used as the single source of truth for Kubernetes Deployments using ArgoCD. The high level diagram below shows what we will be building. We will build 4 manifest files 1 at a time, each time we built a manifest file, we are going to update our CD to deploy the manifest to Kubernetes Cluster. After completing the four manifest, we are to show that any changes in the manifest file will automatically be synch by ArgoCD to our Kubernetes Cluster.

Step 1: Create the Namespace Manifest File
create the namespace manifest
kubectl create ns 02 -o yaml --dry-run=client > namespace.yamlsave the namespace manifest to GitHub
# git add .
# git commit -m "checkin namespace"
# git push -u origin main
Step 2: Create the remaining Manifest
For our deployment manifest, we will use NGIX image for simplicity.
create the deployment manifest
# kubectl create deployment nginx --image=nginx --port=80 --replicas=3 -o yaml -n 02 --dry-run=client > deployment.yamlStep 3: Create the Service Manifest File in the Continuous Delivery Pipeline
create the service manifest
# kubectl expose deployment nginx --port=8080 --target-port=80 --type=ClusterIP -n 02 -o yaml --dry-run=client > service.yamlStep 4: Create the Ingress Manifest File in the Continuous Delivery Pipeline
create the ingress manifest
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
namespace: "02"
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: "nginx.cloudlet.io"
http:
paths:
- pathType: Prefix
path: "/home"
backend:
service:
name: nginx
port:
number: 8080Step 3: Test all the Manifest
We need to test that all manifest are working before submitting to GitHub repository.
provision each manifest file in cluster
# kubectl apply -f namespace.yaml
# kubectl apply -f deployment.yaml
# kubectl apply -f service.yaml
# kubectl apply -f ingress.yamlcheck if resources were provisioned
# kubectl get pods -n <namespace>
check ingress controller is working
Seeing hostname and IP Address in our ingress controller means it is likely working
# kubectl get ingress -n <namespace>
test the ingress endpoint
# curl nginx.cloudlet.io:80/home
Step 4: Save Manifest to GitHub
Now that we've tested that our manifest are working. It is time to save it to GitHub. We will use GitHub as the source repository of our ArgoCD.
save manifest to GitHub
# git add .
# git commit -m "checkin all the manifests"
# git push -u origin mainYou should see something similar below if you've successfully checked-in your manifest to GitHub.

Visiting your GitHub repository will show the newly created manifests

Step 5: Create the ArgoCD Continuous Deployment Pipeline
Step 5.1: Create the ArgoCD Repository
Before we can sync and deploy apps to Kubernetes using ArgoCD. A repository has to be created first in ArgoCD. This is where we link the GitHub repository we created earlier.
It is important to note that the password use here is the "token" generated from GitHub. Follow this blog to learn how to generate GitHub token. The video below shows how to create a repository in ArgoCD.
Step 5.2: Create the ArgoCD Application
Creating an app in the ArgoCD is like creating a Continuous Deployment pipeline.
The application can be created using the repository that we've just made in step 5.1. Follow the video below to create ArgoCD app. For simplicity, we have not enabled auto-sync in this demonstration of ArgoCD to manifest file.
Conclusion
In this blog, we've demonstrated how to build a Continuous Deployment pipeline using ArgoCD and Manifest file. I will be creating a blog in the succeeding days where both GitHub Continuous Integration and ArgoCD Continuous Deployment are combined creating DevSecOps + GitOps.