Project: Automating delivery of a highly scalable application - Kubernetes Ingress
As part of a project, I have designed and implemented CI/CD pipeline for Reddit clone application.
This pipeline uses the below tools:-
GitHub
Docker
DockerHub
Kubernetes
Minikube
Reddit Clone Application
Pre-requisites
Create two AWS EC2 instances.
a. Create a t2.micro for the Continous Integration server.
b. Create a t2.medium for the Continous Deployment server.
Install Docker on both servers.
$ apt-get update $ apt install docker.io
Install Minikube and Kubectl in the deployment server.
$ 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
Let's see step by step how the above tools are used.
GitHub
Let's clone the code from the GitHub repository to the AWS EC2 instance
$ git clone <github repo url>
Docker
Write the docker file.
Build the image out of the docker file.
$ docker build . -t bandank/reddit-clone
DockerHub
Push the image created to DockerHub.
$ docker login
$ docker push bandank/reddit-clone:latest
Check the pushed image in DockerHub.
Kubernetes
Write the deployment file.
Run the deployment file using below command.
$ kubectl apply -f deployment.yml
Write the service file.
Run the service yaml file using below command.
$ kubectl apply -f service.yml
You can access the application now through URL.
Kubernetes Ingress
What is it?
Through the service.yml file, we expose the node to external IP which as a result accessible from outside. However, there is no stability of Node, it comes and goes. So, it is not advisable to assign this static IP to external service.
Here comes Ingress, Ingress defines a set of rules that allows the inbound connection to access Kubernetes cluster services.
When the external Ip hits, the Ingress controller routes to kubernetes end points.
It is not installed by default. So, use the below command.
$ minikube addons enable ingress
Write the Ingress yaml file.
Testing the application
Use CURL command to check the application.
Reference
I found an informative blog on Kubernetes ingress which describes how to deal with external access to the Kubernetes cluster. The blog demonstrates how the traffic can be routed between applications and be accessible to the outer world. The servers used here are hosted on Azure. You can refer to the blog using the below link.
https://spacelift.io/blog/kubernetes-ingress
Thank you very much for witnessing the magic of DevOps.
See you again with another project.
Thank you.