Kubectl is a Kubernetes command-line configuration tool that interfaces with a Kubernetes API server. You can use Kubectl to create, inspect, update, and destroy Kubernetes objects.
This post will serve as a quick reference for running commands on a variety of common Kubernetes components and resources.
To view the configurations
kubectl config view
To display all the contexts
kubectl config get-contexts
To change/get into the context
kubectl config use-context <cluster-name>
To display the current context
kubectl config current-context
To display endpoint information about the master and services in the cluster
kubectl cluster-info
To check the namespaces inside the cluster
kubectl get namespace
List all pods in the namespace
kubectl get pods
List all pods in all namespaces
kubectl get pods –all-namespaces
List all pods in the current namespace, with more details
kubectl get pods -o wide
Get the details of the available nodes
(their resources (CPU, Memory, etc) consumption)
kubectl describe nodes
Get the details of the specific node,
(it’s last heartbeat and transition time, internal IP, Hostname, etc.)
kubectl describe nodes <nodeName>
List a particular deployment
kubectl get deployment <name>
List all the services
(service name, type, cluster-IP, external-IP, port, etc.)
kubectl get services
List all the nodes
(name of the nodes, node status, roles, age, version)
kubectl get nodes
To dump the logs of the specific pod.
kubectl logs <pod_name>
To get the logs of a specific microservice
kubectl logs <microservice_name> –follow –all-containers=true –namespace=<namespace_name>
Hope you find this article helpful.