🚢Reddit Clone Deployment on Kubernetes with Ingress Enabled

🚢Reddit Clone Deployment on Kubernetes with Ingress Enabled

Prerequisites:

  1. EC2 ( AMI- Ubuntu, Type- t2.medium )

  2. Docker

  3. Minikube

  4. kubectl

You can Install all this by doing the below steps one by one. and these steps are for Ubuntu AMI.

# Steps:-

# For Docker Installation
sudo apt-get update
sudo apt-get install docker.io -y
sudo usermod -aG docker $USER && newgrp docker

# For Minikube & Kubectl
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube 

sudo snap install kubectl --classic
minikube start --driver=docker

Great! You're all set for the project. Your Minikube cluster is now prepared for deploying the Reddit clone application.

Step 1: Clone the source code

The first step is to clone the source code for the app. You can do this by using this command git clone https://github.com/LondheShubham153/reddit-clone-k8s-ingress.git

Step 2: Containerize the Application using Docker

Step 3) Building Docker-Image

Step 4) Push the Image To DockerHub

Step 5) Kubernetes Cluster

  1. Write Deployment.yml file and Service.yml file

Step 6) Deploy the app to Kubernetes & Create a Service For It

Now, we have a deployment file for our app and we have a running Kubernetes cluster, we can deploy the app to Kubernetes. To deploy the app you need to run following the command: kubectl apply -f Deployment.yml Just Like this create a Service using kubectl apply -f Service.yml

If You want to check your deployment & Service use the command kubectl get deployment & kubectl get services

Step 6) Configure Ingress

Minikube doesn't enable ingress by default; we have to enable it first using minikube addons enable ingress command.

write ingress.yml and put the following code in it:

Now you can able to create ingress for your service. kubectl apply -f ingress.yml use this command to apply ingress settings.

Curl to request a response from our deployed application.

Step 8) Expose the app

  1. First We need to expose our deployment so use kubectl expose deployment reddit-clone-deployment --type=NodePort command.

  2. You can test your deployment using curl -L http://192.168.49.2:31000. 192.168.49.2 is a minikube ip & Port 31000 is defined in Service.yml

  3. Then We have to expose our app service kubectl port-forward svc/reddit-clone-service 3000:3000 --address 0.0.0.0 &

    You can also see the deployed application on Ec2_ip:3000

    Also open port 3000 in your security group of your instance.

📍Conclusion

Successfully Deployed a Reddit Copy on Kubernetes with Ingress Enabled.