Project: Automating delivery of a highly scalable application - Kubernetes Ingress

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

  1. GitHub

  2. Docker

  3. DockerHub

  4. Kubernetes

  5. Minikube

  6. Reddit Clone Application

Pre-requisites

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

  2. Install Docker on both servers.

     $ apt-get update
    
     $ apt install docker.io
    
  3. 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

  1. Write the docker file.

  2. Build the image out of the docker file.

    $ docker build . -t bandank/reddit-clone

    DockerHub

    1. Push the image created to DockerHub.

      $ docker login

      $ docker push bandank/reddit-clone:latest

  1. Check the pushed image in DockerHub.

    Kubernetes

    1. Write the deployment file.

    2. Run the deployment file using below command.

      $ kubectl apply -f deployment.yml

    3. Write the service file.

    4. Run the service yaml file using below command.

      $ kubectl apply -f service.yml

    5. You can access the application now through URL.

      Kubernetes Ingress

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

        File upload limit in Kubernetes & Nginx

      2. It is not installed by default. So, use the below command.

        $ minikube addons enable ingress

      3. Write the Ingress yaml file.

Testing the application

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