Kubernetes is a orchestration tool for microservices. It helps to scale the deployment services according to the need of the users.
-> Scale on demand
-> Self-heal of deployment
-> Support zero-downtime rolling updates
-> Run anywhere
And Kubernetes provides all of them. It is called the OS of the cloud.
This can be AWS. You can just swap out the underlying architecture if you use Kubernetes. For Beginners with NodeJS Express Application that's why it's so popular and powerful.
A Kubernetes cluster is a collection of machines that have kubernetes installed. The machines can be a computer, a VM, a raspberry PI and so on.
We can install kubernetes on the machines and connecting them creates a Kubernetes cluster. And each of the machines are called Nodes
There are 2 kinds of nodes.
- Master nodes (Masters)
- Worker nodes (Nodes)
Masters host the control pane and Nodes host user applications. You want to maintain high availability for the master nodes.
The Nodes (aka Workers) run 2 main services.
- Kubelet
- Container runtime
The kubelet is the main kubernetes agent. It communicates with the control pane.
- Create a Docker Image for a NodeJS application
- Publish that Image to DockerHub
- Create a minikube Kubernetes Cluster
- Install Kubectl on our local machine
- Deploy our application into Kubernetes cluster
By the help of docker documentation, We have install docker with the latest version.
- For root permission sudo su
So let's clone it first!
check the node-hello project cloned in the local machine
- ls mv node-hello nodeapp
Now, login to the docker account
- docker login
- username
- password
- docker build -t samarthagarwal9/nodeapp .
to check the docker image
- docker images
- docker run -d -p 3000:3000 samarthagarwal9/nodeapp
- docker ps
To config the IP at which the node-hello app deploy as a container
- ip addr
- docker ps
Remove the container from the docker
- docker rm -f container_id
- docker ps
- docker login
- username:
- Password:
- docker push samarthagarwal9/nodeapp:latest
Docker successfully push the image which is conatinerized.
Now, we have to create two YAML files.
- Deployment.yml
- Service.yml
- vi Deployment.yml
- vi Service.yml
Install MINIKUBE by the help of kubernetes docs.
To check the minikube status
- minikube status
To start the pods on the cluster
- kubectl get pods
To start the deployment
- kubectl get deployment
- kubectl get svc
- kubectl apply -f deployment.yml
- kubectl get deployement
- kubectl get pods
To start the service on Kubernetes cluster
- kubectl apply -f service.yml
- kubectl get svc
- minikube service nodeapp-service
Ip generate at which the deployment of any application can be done
- By following the abobe steps we successfully deploy the Node App on Kubernetes as well as on Docker!!!!..