DEV Community

Aravind kumar TS
Aravind kumar TS

Posted on

Kubernetes — Kubectl- Minikube — Single Node

How to work with Kubernetes using Kubectl in a Ubuntu Server?

To install Kubernetes on your Ubuntu Server, follow the below steps in your OS

Containerisation
Host+OS+Hypervisor (Virtual box) + OS +Application = Traditional VMs (old concept)
Host + OS + Docker file + Docker Image + Docker Registry + Containers + Application+ Application = Containers concept (New but turned as an old concept)
Kubernetes, microservices concepts derived from Docker containers concept ( Trending now)

Kubernetes in an Orchestration tool, it manages the container based work loads
Kubernetes Master consists of API Server, DNS, Kubelet
Kubelet runs on Worker nodes
Kubernetes Master and Kubelet works together.
Kubernetes involves YAML
A Pod is to run a simple container in worker node
A node can have multiple Pods
Every Pod has an ip address
Service Registry, Service Discovery comes in built in Kubernetes
Kubernetes can be also known as “K8s”
In K8s — Service can be accessed inside the cluster
Kubectl is a command line tool, its used to deploy applications in Cluster resources. I

Step -1 — Install Docker
.sudo apt-get update
.sudo apt-get install \ca-certificates \curl \gnupg \sb-release
.sudo echo \ “deb [arch=$(dpkg — print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable” | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
.sudo apt-get update
.sudo apt-get install docker-ce docker-ce-cli containerd.io
.sudo docker — version
.sudo docker run hello-world
.sudo server docker status

Refer — https://docs.docker.com/engine/install/ubuntu/

Step — 2 — Install Minikube — Start Minikube
minikube is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes.
All you need is Docker (or similarly compatible) container or a Virtual Machine environment, and Kubernetes is a single command away:
minikube start

. sudo .curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
. sudo install minikube-linux-amd64 /usr/local/bin/minikube
. sudo apt-get upgrade -y
. sudo apt install virtualbox virtualbox-ext-pack
. wget https://github.com/kubernetes/minikube/releases/tag/v1.25.1
. minikube start
. sudo cp minikube-linux-amd64 /usr/local/bin/minikube
. minikube version

Step -3 — Install Kubectl

. sudo cd /usr/local/bin
. sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl
. chmod +x ./kubectl #( to make this executable)
. sudo mv ./kubectl /usr/local/bin/kubectl
. sudo apt-get install -y apt-transport-https
. sudo swapoff -a
. sudo nano /etc/fstab
. In the fstab file, comment out the swap entry (by adding a leading # character):
/swap.img none swap sw 0 0
. kubectl version — client
. sudo kubectl cluster-info

Image description

Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
kubernetes-dashboard is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy

kubectl run hello-node — image=gcr.io/qwiklabs-gcp-3a79f26c2b47893f/hello-node:v1 — port=8080

output: pod/hello-node created

kubectl describe nodes | head or kubectl get nodes

kubectl get nodes

Output — shiva@hypo-cloudeva:/usr/local/bin$ kubectl get nodes
NAME STATUS AGE
minikube Ready 2h

If you face error its because “The minikube version and kubectl version should be equal”

shiva@hypo-cloudeva:/usr/local/bin$ kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-node 0/1 ImagePullBackOff 0 58m

sudo snap install kubeadm — classic

shiva@hypo-cloudeva:/usr/local/bin$ kubectl run nginx — image=nginx:1.10.0
output: deployment “nginx” created

sudo minikube dashboard

Image description

… To be edited (continued)

(Since medium blog is not free, I have replicated my medium blog here)

Top comments (0)