This repository demonstrates a GitOps workflow using ArgoCD, Terraform, and Kubernetes. The demo includes deployment of Nginx and Prometheus monitoring stack in a local Kind cluster.
git clone https://github.com/markbosire/gitops-repo.git
cd gitops-repo
kind create cluster --name gitops-demo
Verify the cluster is running:
kubectl cluster-info --context kind-gitops-demo
Navigate to the Terraform directory:
cd terraform
Initialize Terraform:
terraform init
This will download the necessary providers and modules.
Apply the Terraform configuration:
terraform apply
Review the planned changes and type yes
when prompted to proceed.
The deployment will:
- Install ArgoCD in your Kind cluster
- Configure ArgoCD to monitor your GitOps repository
- Deploy Nginx application
- Deploy Prometheus monitoring stack (kube-prometheus-stack)
First, list the services in the ArgoCD namespace to find the server service name:
kubectl get svc -n argocd
Port-forward the ArgoCD server (in my case, the service name is argo-cd-argocd-server):
kubectl port-forward svc/argo-cd-argocd-server -n argocd 8080:443
Access the ArgoCD UI at: https://localhost:8080
Default login credentials (unless changed):
- Username: admin
- Password: (Get the password by running the command below)
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
Wait for all the applications to finish deploying. Check that your applications are successfully deployed:
kubectl get applications -n argocd
Access Nginx:
kubectl port-forward svc/nginx 8090:80
Then visit http://localhost:8090 in your browser.
Access Prometheus:
First, list the services in the monitoring namespace to find the server service name:
kubectl get svc -n monitoring | grep 9090
Port-forward the prometheus (in my case, the service name is kube-prometheus-stack-gito-prometheus):
# Port-forward the prometheus service (adjust service name if needed)
kubectl port-forward svc/kube-prometheus-stack-prometheus -n monitoring 9090:9090
Then visit http://localhost:9090 in your browser.
Access Grafana:
# First check the service name
kubectl get svc -n monitoring | grep grafana
# Port-forward the Grafana service (adjust service name if needed)
kubectl port-forward svc/kube-prometheus-stack-grafana -n monitoring 3000:80
Then visit http://localhost:3000 in your browser.
Default Grafana credentials (unless changed):
- Username: admin
- Password: prom-operator
You could check the resource metrics by searching kubernetes and clicking the resource you want to monitor
gitops-repo/
├── apps/
│ ├── nginx.yaml # ArgoCD Application for Nginx
│ └── addons.yaml # ArgoCD ApplicationSet for addons
├── addons/ # GitOps configuration for addons
├── terraform/ # Terraform configuration
│ └── main.tf # Main Terraform configuration
└── README.md # This file
To customize the deployment, modify the following files:
terraform/main.tf
: Update the locals section to change configurationapps/*.yaml
: Modify ArgoCD application definitionsaddons/
: Update addon configurations
To delete all resources and the Kind cluster:
terraform destroy
kind delete cluster --name gitops-demo