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.
-
Build your own Docker image that can serve a static "Hello World" HTML page
-
Deploy that image as a container in a Kubernetes cluster running locally on your machine using helm and writing your own chart
-
Deploy a Traefik container in the same local Kubernetes cluster using helm
-
Make Traefik an ingress point to access the "Hello World" page
-
Make the "Hello World" page accessible locally at
http://hello-world.local
For the purpose of this lab we are going to use a CentOS 7.
We are going to use the following tools (click in the link to see how to install each tool):
All required files and scripts for this deployment are included in this project.
-
How to create the docker image: ./docker/README.md
-
How to create the helm chart: ./helm/README.md
References:
-
https://doc.traefik.io/traefik/v2.3/routing/providers/kubernetes-ingress/
-
https://doc.traefik.io/traefik/v1.7/user-guide/kubernetes/ (this is from a previous version of trafik but the idea is basically the same)
These are the required steps, assuming you already have all required tools already installed.
-
Clone this project in an empty directory
git clone https://github.com/rjrpaz/deploy-using-helm.git
-
Change location to the new directory
cd deploy-using-helm
-
Assure that ingress addon for minikube is already installed
minikube addons enable ingress
-
Create a namespace
kubectl create namespace tr-webapp-ns
-
Install the app:
-
Add helm repo for the app
helm repo add tr-webapp https://www.robertopaz.com.ar/deploy-using-helm/
-
If required, update helm
helm repo update
-
Install the app
helm install tr-webapp tr-webapp/tr-webapp --namespace tr-webapp-ns
-
-
Install traefik
-
Add helm repo for traefik
helm repo add traefik https://helm.traefik.io/traefik
-
If required, update helm
helm repo update
-
Install traefik
helm install traefik traefik/traefik --namespace tr-webapp-ns
-
-
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.
-
Apply the ingress file:
kubectl apply -f helm/ingress.yaml --namespace tr-webapp-ns
-
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
-
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)
-
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
-
Check reachability to the url:
curl hello-world.local
You should get a "Hello World" message
References:
-
https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs
-
https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release
-
https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/ingress
-
You should have terraform installed. You can install terraform in CentOS using packet manager:
sudo yum -y install terraform
-
Assure that ingress addon for minikube is already installed
minikube addons enable ingress
-
Clone this project in an empty directory
git clone https://github.com/rjrpaz/deploy-using-helm.git
-
Change location where terraform code is located:
cd deploy-using-helm/terraform
-
Init terraform
terraform init
-
Apply terraform code
terraform apply --auto-approve
-
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)
-
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
-
Check reachability to the url:
curl hello-world.local
You should get a "Hello World" message
While I was investigating this, I tried some alternative solutions listed below:
-
Get ingress plugin to work with a newest version of minikube (Current version: 1.23.0).
-
Configure all services using a custom helm chart (remove yaml content).