deploy-using-helm

Deploy a static web page using helm and traefik

The purpose of this lab is to develop a full provisioned pipeline to deploy a static web page.

You can clone this repository to get some of the files that are we going to use during the lab.

Objectives

  1. Build your own Docker image that can serve a static “Hello World” HTML page

  2. Deploy that image as a container in a Kubernetes cluster running locally on your machine using helm and writing your own chart

  3. Deploy a Traefik container in the same local Kubernetes cluster using helm

  4. Make Traefik an ingress point to access the “Hello World” page

  5. Make the “Hello World” page accessible locally at http://hello-world.local

Requirements

For the purpose of this lab we are going to use a CentOS 7.

Pre-requisite tools

We are going to use the following tools (click in the link to see how to install each tool):

Build of the components

All required files and scripts for this deployment are included in this project.

Deploy the app (manual steps)

References:

These are the required steps, assuming you already have all required tools already installed.

  1. Clone this project in an empty directory

     git clone https://github.com/rjrpaz/deploy-using-helm.git
    
  2. Change location to the new directory

     cd deploy-using-helm
    
  3. Assure that ingress addon for minikube is already installed

     minikube addons enable ingress
    
  4. Create a namespace

     kubectl create namespace tr-webapp-ns
    
  5. Install the app:

    1. Add helm repo for the app

       helm repo add tr-webapp https://www.robertopaz.com.ar/deploy-using-helm/
      
    2. If required, update helm

       helm repo update
      
    3. Install traefik

       helm install tr-webapp tr-webapp/tr-webapp --namespace tr-webapp-ns
      
  6. Install traefik

    1. Add helm repo for traefik

       helm repo add traefik https://helm.traefik.io/traefik
      
    2. If required, update helm

       helm repo update
      
    3. Install traefik

       helm install traefik traefik/traefik --namespace tr-webapp-ns
      
  7. List pods in the namespace to check status

     kubectl get pods --namespace tr-webapp-ns
    

    It should return at least two running pods (our app and traefik service):

     NAME                         READY   STATUS    RESTARTS   AGE
     tr-webapp-86b97d69cc-znpvl   1/1     Running   0          4m6s
     traefik-7594596bbc-6mzg9     1/1     Running   0          39s
    

    Wait until both containers are in Running STATUS.

  8. Apply the ingress file:

     kubectl apply -f helm/ingress.yaml --namespace tr-webapp-ns
    
  9. Check service resources

     kubectl get svc --namespace tr-webapp-ns
    

    It should return something like this:

     NAME        TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                      AGE
     tr-webapp   NodePort       10.103.93.206   <none>        8080:32422/TCP               9m53s
     traefik     LoadBalancer   10.96.143.228   <pending>     80:31004/TCP,443:31250/TCP   8m16s
    
  10. Check ingress resources

     kubectl get ingress --namespace tr-webapp-ns
    

    It should return something like this:

     NAME        CLASS    HOSTS               ADDRESS        PORTS   AGE
     myingress   <none>   hello-world.local   192.168.49.2   80      6m24s
    

    (you should wait a few seconds until “ADDRESS” list an IP address for the ingress resource)

  11. Create a static entry in /etc/hosts to point to the new hostname hello-world.local

     echo "$(minikube ip) hello-world.local" | sudo tee -a /etc/hosts
    
  12. Check reachability to the url:

     curl hello-world.local
    

    You should get a “Hello World” message

Deploy the app using terraform

References:

  1. You should have terraform installed. You can install terraform in CentOS using packet manager:

     sudo yum -y install terraform
    
  2. Assure that ingress addon for minikube is already installed

     minikube addons enable ingress
    
  3. Clone this project in an empty directory

     git clone https://github.com/rjrpaz/deploy-using-helm.git
    
  4. Change location where terraform code is located:

     cd deploy-using-helm/terraform
    
  5. Init terraform

     terraform init
    
  6. Apply terraform code

     terraform apply --auto-approve
    
  7. Check ingress resources

     kubectl get ingress --namespace tr-webapp-ns
    

    It should return something like this:

     NAME        CLASS    HOSTS               ADDRESS        PORTS   AGE
     myingress   <none>   hello-world.local   192.168.49.2   80      6m24s
    

    (you should wait a few seconds until “ADDRESS” list an IP address for the ingress resource)

  8. Create a static entry in /etc/hosts to point to the new hostname hello-world.local

     echo "$(minikube ip) hello-world.local" | sudo tee -a /etc/hosts
    
  9. Check reachability to the url:

     curl hello-world.local
    

    You should get a “Hello World” message

Alternative solutions to apply ingress entry point

While I was investigating this, I tried some alternative solutions listed below:

Next steps