Using Minikube for Local Deplyment of single node Kubernetes cluster
Kubernetes is an open source container orchestration platform that automates many of the manual processes involved in deploying, managing, and scaling containerized applications. It is also known as k8s.
Kubernetes was originally developed and designed by at Google and was open sourced in 2014.
Advantage of Kubernetes :
- Orchestrate containers across multiple hosts.
- Control and automate application deployments and updates.
- Mount and add storage to run apps.
- Scale containerized applications and their resources.
- Manage services which guarantees the deployed applications are always running the way you intended them to run.
- Health-check and self-heal your apps with auto-placement, auto-restart, auto-replication, and auto-scaling.
Kubernetes is significantly more complex than Swarm, and requires more work to deploy. For development work, and smaller container clusters, Docker Swarm presents a simpler choice.
Kubernetes architecture: How Kubernetes works
Master Components :
Kubernetes is an API server which provides all the operation on cluster using the API.Its basically the entry point .
This component is responsible for most of the collectors that regulates the state of cluster and performs a task.
This is one of the key components of Kubernetes master. It is a service in master responsible for distributing the workload. It is responsible for tracking utilization of working load on cluster nodes.
Worker Node Components :
- Kubelet: Kubelet ensures that all containers in the node are running and are in the healthy state. Its also responsible for communication between master and worker nodes.
- Container: Containers are the lowest level of Microservice, placed inside the pod and needs external IP address to view the outside process.
- Kube Proxy: It acts as a network proxy and a load balancer. It forwards the request to the correct pods across isolated networks in a cluster.
So lets begin with installation . In this pdf I have added all the commands to install docker, kubectl and minikube.
For those who are working on Virtual Machines :
There is a problem with minikube on VirtualBox VM : minikube uses VirtualBox hypervisor for virtualization and thus requires VT-X support on host. However VirtualBox doesn’t support VT-X/AMD-v. That could be solved by using vm-driver=none option and Docker on host and also minimum 2 cores of cpu is allocated .
We need to install conntrack as prerequisite using
sudo apt-get install conntrack
Minikube is an indispensable tool for developing applications targeted for Kubernetes.
To launch minikube use
sudo minikube start --vm-driver=none
For non Virtual Machine Users :
- You can type kubectl, if you’ll see all the commands available that means “kubectl” is working.
2. Verify Minikube is running.
sudo kubectl get node
3. Now we start the Deployment on Kubernetes Cluster. We are deploying a docker image available publically on docker hub
sudo kubectl create deployment <Deployment_Name> --image=<Image_Name>
4. To get Information of running deployments
sudo kubectl get deployments
5. To get full description of running deployments
sudo kubectl describe deployments magicalnginx
6. Make the NGINX container accessible via the internet.
kubectl create service nodeport <deployment_name> --tcp=80:80
7. Run below command to get URL of exposed service
sudo kubectl get svc
8. Use curl command to view content of web page
9. Kubectl commands:
- To list deployments : sudo kubectl get deployments
- To delete a service : sudo kubectl delete service magicalnginx
- To delete a particular deployment : sudo kubectl delete deployment magicalnginx
- Delete the local Minikube cluster
sudo minikube delete
In the next post I will be