rss feed Twitter Page Facebook Page Github Page Stack Over Flow Page

Kubernetes Commands

Kubernetes includes simple and yet powerful commands for anyone getting started with Kubernetes. The complete list of Kubectl commands can be found at https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands.

Make sure your minikube service is running.

minikube

minikube start

Start a local Kubernetes cluster

minikube get-k8s-versions

Get the available Kubernetes versions for the localkube bootstrapper.

minikube ip

Get the IP address of your cluster.

minikube dashboard

Open the dashboard

minikube addons list

List addons

minikube ssh

ssh to minikube

kubectl basic commands

kubectl version

Find the version of the Kubectl command line.

kubectl version

Get the Client and Server Version.

kubectl cluster-info

Get cluster info and IP addresses of master and services

kubectl cluster-info dump --namespaces

List all the namespace used in Kubernetes.

kubectl config view

Get configuration

kubectl get componentstatus

Get component status

kubectl describe node

Get node status

kubectl get svc

Get services for current namespace

kubectl get service --all-namespaces

Get all services for all namespace

kubectl -n kube-system get cm kubeadm-config -oyaml

Get system configuration

kubectl Pod commands

kubectl get pods

List all pods

kubectl get pod -o wide

List pods with node info attached

kubectl get pods --show-labels

List all pods with labels

kubectl get services

List all services

kubectl get -n kube-system pods -a

List all critical pods

kubectl describe pod <my-pod>

Get pod info

kubectl Pod commands

kubectl exec -it <my-pod> -- bash

Open a bash terminal in a pod

kubectl exec <my-pod> env

Check pod environment variables

kubectl delete pod <my-pod>

Delete pod

kubectl run hello --image=<my-image>g --port=80

Start a service

kubectl get nodes

Similar to docker ps

kubectl describe pod <my-pod>

Similar to docker inspect

kubectl logs

Similar to docker logs

kubectl exec

Similar to docker exec

kubectl get events

View cluster events

kubectl get deploy

Get deployment info

Namespace and Security

kubectl config get-contexts

List authenticated contexts

kubectl config use-context <my-context-name>

Set the context to interact with

kubectl get namespaces

List all namespaces defined

Volume

kubectl exec <my-storage> ls /data

Check the mounted volumes

kubectl describe pv <my-pv>

Check persist volume

Want more? Visit https://kubernetes.io/docs/reference/kubectl/cheatsheet/