Using ingress to deploy a Node.js application on Kubernetes and ngrok to test application on a browser. Build Kubernetes using Minikube and manage Docker Container using Pods, Deployment, Services, and ingress manifest files
Here's important point of this assignment: Using ingress to deploy a Node.js application on Kubernetes and with ngrok test application on a browse. Build Kubernetes using Minikube and manage Docker Container using Pods, Deployment, Services, and ingress manifest files
To get a local copy up and running follow these simple example steps.
-
AWS EC2 instance.
-
Docker.
-
Minikube.
-
K8s Manifest Files. (Deployment ,service ,ingress)
-
Create AWS EC2 instance of ubuntu OS image.
-
Install Docker on Ubuntu.
-
Install Minikube which uses Docker as driver.
-
Minikube runs as a Docker Container to server the purpose of K8s.
-
Github url: https://github.com/sanjanathamke/Kubernet_Project.git
kubectl create namespace <namespace-name>
kubectl get namespaces
2. Create one Deployment file to deploy a sample app on K8s using “Auto-healing” and “Auto-Scaling” feature
add a deployment.yaml file use namespace as kubeproject apply the deployment to your k8s (minikube) cluster by command kubectl apply -f deployment.yaml
kubectl apply -f deployment.yaml -n <namespace-name>
Apply the LoadBalancer Service definition to your K8s (minikube) cluster using the below command
kubectl apply -f load-balancer-service.yaml -n <namespace-name>
4. Verify that the LoadBalancer Service is working by accessing the todo-app from outside the cluster in your Namespace.
Get the LoadBalancer IP service:
The minikube service command is used to interact with services in a Minikube cluster. The — url option will return the URL that you can use to access the Service in your browser.
minikube service <service_name> -n=<namespace> --url
Note the LoadBalancer IP address of the LoadBalancer Service you want to verify.
Access the todo-app from outside the cluster using the LoadBalancer IP and the exposed port:
curl -L <load-balancer-ip>:<service-port>
curl -L http://http://192.168.49.2:31188
If the LoadBalancer Service is working correctly, you should see the response from the app
5. An Ingress is an API object that defines rules which allow external access to services in a cluster
To enable the NGINX Ingress controller, run the following command:
minikube addons enable ingresss
create ingress.yaml file and apply ingress file
Create the Ingress object by running the following command
kubectl apply -f ingress.yaml -n <namespace-name>
Note the LoadBalancer IP address of the LoadBalancer Service
minikube service <service-name> -n <namespace-name> --url
Add the following line to the bottom of the /etc/hosts file on your computer (you will need administrator access):
192.168.49.2 nodejs-todo-app.info
Verify that the Ingress controller is directing traffic:
curl -L http://nodejs-todo-app.info
ngrok is a cross-platform application that enables developers to expose a local development server to the Internet with minimal effort. It creates a secure tunnel from the public internet to a local web server on your computer, making it possible to access the local web server from anywhere in the world.
Go to ngrok site, In that right click on Linux and copy link address
Create a new folder for ngrok setup, inside folder use command wget <copied_linux_address> this command will download ngrok.
wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-386.tgz
unzip downloaded file using :
tar -xvzf <file_name>
Add authentication — Running below command will add your authtoken to the default ngrok.yml configuration file
./ngrok config add-authtoken 2N5jh4oJTnp0xM4z3ktc1JYeaAF_7agSW56UrMKSVNCshmBdu
Use command :
./ngrok http 192.168.49.2:31188
./ngrok http 192.168.49.2:31188 to make a tunnel. Here http 192.168.49.2:31188 is url of a service given by minikube service.
above command creates a tunnel and gives IP address which is ended with ngrok.io Copy and paste that ip in your browser. click on visit site and your website will visible
Sanjana Thamke - www.linkedin.com/in/sanjana-thamke-68827417b - My LinkedIn
Project Link: https://medium.com/@sanjuthamke9699/kubernetes-project-c1faded2499f