Skip to content

lappiahnuamah/argocd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deploying a Kubernetes Voting App on AWS EC2 using Kind and ArgoCD

Introduction

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.

Prerequisites

  • AWS EC2 instance (Ubuntu 22.04)
  • Docker installed
  • Kubectl installed
  • Kind installed
  • Helm installed

Step 1: Install Dependencies

Update the Package List and Install Docker

sudo apt update && sudo apt-get install -y docker.io

Start and Enable Docker

sudo systemctl start docker
sudo systemctl enable docker

Verify Docker Installation

sudo docker --version
sudo systemctl status docker

NB:To avoid using sudo with every Docker command:

sudo usermod -aG docker $USER && newgrp docker

Step 2: Install Kind and Kubectl

Install Kind

curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

Install Kubectl

curl -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/kubectl

Verify Installations

kind --version
kubectl version --client

Step 3: Create a Kubernetes Cluster with Kind

Create a Configuration File (config.yml)

kubectl create namespace kind-cluster

Create config.yml with the following content:

kind: 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.0

Create the Cluster

kind create cluster --config=config.yml

Verify the Cluster

kubectl cluster-info
kubectl get nodes

cluster-info

Step 4: Installing and Configuring Argo CD

In this step, we will install and configure Argo CD, a declarative GitOps continuous delivery tool for Kubernetes.

Create and ArgoCD Namespace

kubectl create namespace argocd

Install ArgoCD

Now, install ArgoCD by applying the installation YAML file:

kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

argo-install

Check Argo CD Services

Verify that the sevices for Argo CD is created and running

kubectl get svc -n argocd

argo-service

The 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 Using NodePort

Expose the Argo CD server via NodePort

kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'

Now you should see the output has changed

argo-nodeport

Access the Argo CD Server

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>:8443

In the browser, you should the below page:

argo-webpage

Login to ArgoCD

Get the initial ArgoCD admin password:

kubectl get secret argocd-initial-admin-secret -n argocd -o jsonpath="{.data.password}" | base64 -d

the output of which is as:

argo-admin-password

argo-login-page

Step 5: Deploy the Voting App

Create an ArgoCD Application

  • 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
  • Revision: main
  • Path: k8s-specifications
  • For the Destination section:
  • After configuring the application click Create

argo-create


argo-create

Synchronize the Application

  • 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.

argo-sync

Step 6: Verify Deployment

kubectl get pods  

argo-sync

Step 7: Access the Voting App

Now we want to access the Voting App so what we will do is to expose the services

Verify Services

kubectl get svc

voting-app-services

Port Forward to Access Services

Forward port for the vote service:

kubectl port-forward svc/vote 5000:5000 --address=0.0.0.0 &

Forward port for the result service:

kubectl port-forward svc/result 5001:5001 --address=0.0.0.0 &
NB: Make sure to allow those ports on your inbound traffic.

Access the Application

Once the services are port forwarding, you can access them here:

  • Voting UI: http://:5000
  • Result UI: http://:5001

voting-ui

result-ui

Conclusion

Your Kubernetes Voting App is now deployed on AWS EC2 using Kind and ArgoCD. 🎉

About

Deploying a Kubernetes Voting App on AWS EC2 Using Kind and ArgoCD

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors