Introduction
Automating the deployment of applications helps organizations manage their infrastructure more efficiently and scale quickly. AWS EC2 provides flexible cloud servers, while Kubernetes helps automate the deployment, scaling, and management of containerized applications. Argo CD, a GitOps tool, simplifies continuous deployment by syncing your application from a Git repository to Kubernetes clusters. Together, these tools allow teams to build and deploy scalable applications quickly and reliably, minimizing manual intervention.
Let's dive in
What Is Argo CD ?
Argo CD is a continuous delivery tool for Kubernetes that follows the GitOps approach. It uses Git repositories as the source of truth for application configurations, ensuring that the deployed applications match the desired state defined in Git. Argo CD automatically syncs changes from Git to the Kubernetes cluster, providing a visual dashboard for monitoring and managing deployments. It supports multi-cluster environments, role-based access control, and health checks, making it an efficient, automated solution for Kubernetes application management and deployment.
Step 1: Launch an ec2 instance with the following configuration
AMI: ubuntu
Instance type:t2 medium
make sure that port 22, 80,443,1000-11000, 500-1000 are opened
storage: 15 GiB
Step 2: Install Docker and Kind
Execute the commands in the provided order to ensure proper setup/configuration
Install docker
sudo apt-get update
sudo apt-get install docker.io
sudo usermod -aG docker $USER && newgrp docker
Install kind
mkdir k8s-kind
cd k8s-kind
vim install-kind.sh
#!/bin/bash # For AMD64 / x86_64 [ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64 chmod +x ./kind sudo cp ./kind /usr/local/bin/kind rm -rf kind
chmod +x install-kind.sh
./install-kind.sh
kind --version
Step 3: Create a Kubernetes cluster using Kind.
vim config.yml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: kindest/node:v1.30.0
- role: worker
image: kindest/node:v1.30.0
- role: worker
image: kindest/node:v1.30.0
kind create cluster --config=config.yml --name=my-cluster
Step 4:Install and access kubectl.
vim install-kubectl.sh
#!/bin/bash
# Variables
VERSION="v1.30.0"
URL="https://dl.k8s.io/release/${VERSION}/bin/linux/amd64/kubectl"
INSTALL_DIR="/usr/local/bin"
# Download and install kubectl
curl -LO "$URL"
chmod +x kubectl
sudo mv kubectl $INSTALL_DIR/
kubectl version --client
# Clean up
rm -f kubectl
echo "kubectl installation complete."
chmod +x install-kubectl.sh
./install-kubectl.sh
Step 5:Set up Argo CD on created cluster.
Execute the commands in the provided order to ensure proper setup/configuration
kubectl create namespace argocd
kubectl get namespace
kubectl apply -n argocd -f
https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
kubectl get pods -n argocd
kubectl get svc -n argocd
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'
kubectl port-forward -n argocd service/argocd-server 8443:443 --address=0.0.0.0 &
access the Argocd serverhttp://13.201.86.83:8443
default username is admin and Retrieve Argo CD admin password using below
kubectl get secret -n argocd argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d && echo
TSG3rF--uFZtffa7
Step 6: Set up the Kubernetes Dashboard.
Go to application โ> new app and create app
kubectl port-forward svc/vote 5000:5000 --address 0.0.0.0 &
kubectl port-forward svc/result 5001:5001 --address 0.0.0.0 &
access application on
Get Voting Result on
Step 7: Install Kubernetes Dashboard
Deploy Kubernetes dashboard:
kubectl apply -f
https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
vim dashborad.yml
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
kubectl apply -f dashborad.yml
Create a token for dashboard access:
kubectl -n kubernetes-dashboard create token admin-user
kubectl get svc -n kubernetes-dashboard
kubectl port-forward svc/kubernetes-dashboard -n kubernetes-dashboard 8080:443 --address=0.0.0.0 &
Access the kubernetes dashboard
add the token which we create before
Summary:
The combination of AWS EC2, Kubernetes, and Argo CD enables automated, scalable application deployment. AWS EC2 offers the infrastructure needed to run applications, while Kubernetes handles container management and scaling. Argo CD automates the deployment process, ensuring consistency and efficiency by syncing from Git repositories. This setup streamlines workflows, reduces errors, and enhances scalability, allowing businesses to deliver applications faster and more reliably.
Your support means a lot. Stay curious, keep learning, and feel free to share your thoughts in the comments. Until next time!