Frequently used Kubernetes Commands

Published on
18 March 2024
2 min read

Here is a list of some frequently used Kubernetes commands.

Listing Pods

kubectl get pods

This command lists all pods in the current namespace.

Describing a Pod

kubectl describe pods <pod-name>

This command provides detailed debug information about a specific pod.

Listing Nodes

kubectl get node

This command lists all the nodes (VMs) in the cluster.

Listing CronJobs

kubectl get cronjob

This command shows a summary table of all running cronjobs.

Viewing CronJob Details

kubectl get cronjob <cronjob-name> -o yaml

This command provides a detailed YAML file that includes environment variables, schedules, resource allocations, and more.

Listing ConfigMaps

kubectl get configmaps

ConfigMaps hold configuration data for pods to consume.

Viewing a ConfigMap

kubectl get configmaps <configmap-name> -o yaml

This command shows the YAML configuration of a specific ConfigMap.

Listing Secrets

kubectl get secrets

Secrets store sensitive information such as passwords, tokens, and keys.

Listing Services

kubectl get svc

This command lists all services, which manage network access to the pods.

Listing Deployments

kubectl get deployments

Deployments manage the desired state of the application pods.

Viewing Deployments

kubectl get deployments <app-name> -o yaml

This command provides a detailed YAML file for a specific deployment.

Listing Horizontal Pod Autoscalers (HPA)

kubectl get hpa

HPA automatically adjusts the number of pod replicas based on CPU usage.

Viewing HPA Details

kubectl get hpa <hpa-name> -o yaml

This command shows the YAML configuration of a specific HPA.

Viewing Pod Logs

kubectl logs <pod-name> -f

This command streams the logs of a specified pod.