A simple website built using Golang and the net/http
package.
To start the server locally:
go run main.go
Access the website at: http://localhost:8080/
This project demonstrates how to apply DevOps practices to a go-webapp, including:
- Dockerization (multi-stage builds)
- CI with GitHub Actions
- CD with Argo CD on Kubernetes (EKS)
Use Docker to containerize the application for consistent builds and deployment.:
#Build the Docker image
docker build -t <your-docker-username>/go-web-app .
#Run the container
docker run -p 8080:8080 <your-docker-username>/go-web-app
#Push image to Docker Hub
docker push <your-docker-username>/go-web-app
CI Workflow steps:
- Checkout source code
- Set up Go environment
- Run tests
- Build Docker image
- Push Docker image to Docker Hub
Argo CD for GitOps-based CD Argo CD syncs Kubernetes apps from a Git repository and automatically deploys them to your EKS cluster.
#Install the following tools on your system:
# AWS CLI
# kubectl
# eksctl
# helm
Create and deploy Helm chart:
# Install app using Helm
helm install go-web-app ./go-web-app-chart
# Uninstall app
helm uninstall go-web-app
- Replace hardcoded Docker image tag with: {{ .Values.image.tag }}
- Update values.yaml accordingly
#Create an EKS cluster using eksctl:
eksctl create cluster --name demo-cluster --region us-east-1
# To delete:
eksctl delete cluster --name demo-cluster --region us-east-1
# Apply all manifests
kubectl apply -f k8s/manifests/
# Get all resources
kubectl get all
# Delete everything
kubectl delete all --all
#Install Ingress controller:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.11.1/deploy/static/provider/aws/deploy.yaml
kubectl get pods -n ingress-nginx
kubectl get svc -n ingress-nginx
#Run the following to retrieve the public IP/hostname:
nslookup <your-ingress-load-balancer-address>
- Map Domain Locally (Temporary) to test before DNS is fully configured:
- Open
sudo vim /etc/hosts
to edit hosts file - Add an entry like:
<Ingress-IP> mywebapp.example.com
#Replace mywebapp.example.com with your custom domain.
- Edit EC2 security group to allow NodePort traffic for testing
- Access via:
http://<eks-node-external-ip>:<nodeport>
#Install Argo CD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
#Expose Argo CD via LoadBalancer
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
kubectl get svc argocd-server -n argocd
#Get Argo CD Admin Password
kubectl get secret argocd-initial-admin-secret -n argocd -o yaml
# Decode password
echo <base64-password> | base64 --decode
- Create a new application
- Set sync policy to Automatic and enable Self-Heal
- Use the Git repo as source
- Provide path:
helm/go-web-app-chart
to point to your Helm chart
- Use CI to automatically update image tag in values.yaml on every push
- Argo CD picks up this tag and deploys it to EKS cluster