Kubernetes is an open-source system for automating the deployment, scaling, and management of containerized applications. It is also known as k8s. It will assist in deploying containerized applications and managing containerized applications. The main difference between docker and Kubernetes is in Kubernetes. It can communicate between different containers, while docker cannot. The main feature of Kubernetes is scaling the resource. We can set the minimum and maximum resources (CPU and memory).
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube start
minikube pause
To stop the minikube, we have to run the command:
minikube stop
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/release/$(curl -LO https://dl.k8s.io/release/v1.25.0/bin/linux/amd64/kubectl)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl get pod
Kubectl get pod -o wide
kubectl apply -f [file name]
kubectl logs [pod name]
This command is used to get the log of the corresponding pod.
kubectl replace -f [file name]
kubectl options
kubectl cluster-info
This command is used to display endpoint information of master and service in the cluster.
kubectl get node
This command is used to get the details of nodes.
kubectl get node -o wide
This command is used to get more information about the node
kubectl cp [file source] [file dest]
This command is used to copy a file from source to destination.
kubectl create -f [file name]
This command is used to create a resource from a file
kubectl edit -f [file name]
This command is used to edit and update the definition.
kubectl delete -f [file name]
This command is used to delete a resource from a file.
kubectl api-resources
This command is used to get the complete list of supported resources.
Kubectl describe [type]
This command is used to get the detailed state of one or more resources.
To deploy an application
kubectl create deployment hello-minikube --image=docker.io/nginx:1.23
kubectl expose deployment hello-minikube --type=NodePort --port=80
By running this command we can create a sample deployment in Kubernetes and expose it to port 80.
minikube service hello-minikube
By running this command, our browser will open the service hello-minikube.
These are some basic commands in kubectl. In order to run kubectl in our local, we need to configure a minikube that acts as a Kubernetes. Then we can deploy resources to Kubernetes and check our development works.