Monday, January 24, 2022

Steps to Install Minikube on Ubuntu for kubernets practice

In this article we are going to basic practice of kubernets with the help of minikube.

Minikube is an open source tool that allows you to set up a single-node Kubernetes cluster on your local machine. The cluster is run inside a virtual machine and includes Docker, allowing you to run containers inside the node.

kubectl allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.


Step 1) Install Docker On Linux Machine

$ sudo su
$ sudo apt update && apt -y install docker.io


- Install Kubectl

$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
$ sudo touch /etc/apt/sources.list.d/kubernetes.list
$ echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
$ sudo apt-get update
$ sudo apt-get install -y kubectl


- Install Minikube

$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

$ apt install conntrack 

$ minikube start --vm-driver=none
$ minikube status
$ kubectl version


Step 2) Write Manifest For Creating Pod

- vim demopod1.yml

kind: Pod                             
apiVersion: v1                     
metadata:                           
  name: demopod           
spec:                                   
  containers:                     
    - name: container1                     
      image: ubuntu             
      command: ["/bin/bash", "-c", "while true; do echo My-Demo-Container1-Running; sleep 5 ; done"]
  restartPolicy: Never         # Defaults to Always

  

 - Run Below command to execute manifest.

$ kubectl apply -f demopod1.yml


Step 3) Basic Commands Kubernets

- To Check Available Pods

$ kubectl get pods


- To Check Where My Pods are Running

$ kubectl get pods -o wide


- To Check Details For Node

$ kubectl describe node ip-10.0.10.10


- To know more about our pod (ex: demopod)

$ kubectl describe pods demopod


- To check logs what is running inside the pod 

$ kubectl logs -f demopod


- Check the logs of container

$ kubectl logs -f demopod -c container1


- To check the ip address of POD

$ kubectl exec demopod -c container1 -- hostname -i


- To login into pod container

 $ kubectl exec -it demopod -c container1 -- /bin/bash


- To delete the pod

$ kubectl delete pod demopod


- To Check Available Pods

$ kubectl get pods


No comments:

Post a Comment

testing