In this guide, we will walk through the step-by-step process of deploying the Kubernetes-based Voting App on an AWS EC2 instance. This deployment is based on the k8s-kind-voting-app GitHub project and leverages kind to run a Kubernetes cluster locally and ArgoCD for GitOps-driven continuous deployment.
- AWS EC2 instance (Ubuntu 22.04)
- Docker installed
- Kubectl installed
- Kind installed
- Helm installed
sudo apt update && sudo apt-get install -y docker.iosudo systemctl start docker
sudo systemctl enable dockersudo docker --version
sudo systemctl status dockersudo usermod -aG docker $USER && newgrp dockercurl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kindcurl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectlkind --version
kubectl version --clientkubectl create namespace kind-clusterkind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.31.0
- role: worker
image: kindest/node:v1.31.0
- role: worker
image: kindest/node:v1.31.0kind create cluster --config=config.ymlkubectl cluster-info
kubectl get nodesIn this step, we will install and configure Argo CD, a declarative GitOps continuous delivery tool for Kubernetes.
kubectl create namespace argocdNow, install ArgoCD by applying the installation YAML file:
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlVerify that the sevices for Argo CD is created and running
kubectl get svc -n argocdThe output show the services created by Argo CD, including the argocd-server. By default, the argocd-server Service will be of type ClusterIP. We will make change it to NodePort so that we can access it from outside the cluster.
Expose the Argo CD server via NodePort
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'Forward the Argo CD server port to your local machine to access the Argo CD UI:
kubectl port-forward svc/argocd-server -n argocd 8080:443 &Now access the Argo CD web interface by entering this address:
http://<EC2_PUBLIC_IP>:8443Get the initial ArgoCD admin password:
kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d- Open the ArgoCD UI and navigate to Applications > Create Application
- Fill in the fields:
- Application Name: voting-app
- Project: default
- Sync Policy: Manual or Automated
- Under Source, provide
- Repository URL: https://github.com/LondheShubham153/k8s-kind-voting-app.git
- Revision: main
- Path: k8s-specifications
- For the Destination section:
- Cluster URL: https://kubernetes.default.svc
- Namespace: default
- After configuring the application click Create
- Go the Applications
- You should see the voting-app. Click on it to view the status
- Sync the application manually by clicking Sync or if you selected automated sync for the continuous deployment it will be sync automatically like in our case. Argo CD will deploy the Voting App to the kubernetes cluster.
kubectl get pods Now we want to access the Voting App so what we will do is to expose the services
kubectl get svckubectl port-forward svc/vote 5000:5000 --address=0.0.0.0 &kubectl port-forward svc/result 5001:5001 --address=0.0.0.0 &Once the services are port forwarding, you can access them here:
- Voting UI: http://:5000
- Result UI: http://:5001
Your Kubernetes Voting App is now deployed on AWS EC2 using Kind and ArgoCD. 🎉