Lab: Building a Complete CI/CD Pipeline
Goal
Build a continuous integration pipeline using GitHub Actions that builds a Docker image, scans it for vulnerabilities, and updates a deployment manifest. Then, configure ArgoCD to automatically deploy the new version.
Prerequisites
- A GitHub account
- A Docker Hub account
- A running Kubernetes cluster (e.g., Minikube, kind)
kubectlinstalled
Environment Setup
- Fork the sample application repository provided in the course materials.
- Generate a Docker Hub access token and store it as a GitHub Secret (
DOCKER_USERNAME,DOCKER_PASSWORD).
Step-by-step instructions
Step 1: Create the CI Pipeline
- In your repository, create
.github/workflows/ci.yaml. - Configure it to run on pushes to the
mainbranch. - Add a step to build the Docker image and tag it with the commit SHA.
- Add a step to push the image to Docker Hub.
- Add a step to update the
deployment.yamlfile in your repository with the new image tag.
Step 2: Install ArgoCD
- Install ArgoCD in your Kubernetes cluster:
kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Step 3: Configure ArgoCD Application
- Forward the ArgoCD UI port to access it locally.
- Login using the initial admin password.
- Create a new Application pointing to your Git repository’s manifest folder.
- Set the sync policy to Automated.
Verification
Push a code change to your application. Watch the GitHub Action run. Once complete, observe ArgoCD detecting the new manifest version and syncing the changes to the cluster.
Cleanup
Delete the ArgoCD namespace and the application namespace.