Skip to Content
This project is a work in progress. If you have any questions or suggestions, feel free to contact me.
KubernetesTools & CommandsKubectl Command

kubectl

kubectl (pronounced “cube control”, “kube cuddle”, or “kube C-T-L”) is the command-line tool used to interact with a Kubernetes cluster.

It allows you to deploy, manage, inspect, and troubleshoot applications and resources in Kubernetes.

Common Commands

CommandDescription
kubectl get podsList all pods in the current namespace
kubectl get svcList all services
kubectl get nodesList all nodes in the cluster
kubectl describe pod <name>Show detailed info about a specific pod
kubectl logs <pod>Show logs from a pod
kubectl apply -f <file.yaml>Apply configuration from a YAML file
kubectl delete -f <file.yaml>Delete resources defined in a YAML file
kubectl exec -it <pod> -- bashOpen a shell inside a running pod
kubectl scale deployment <name> --replicas=3Scale a deployment

Common Flags

FlagUsage ExamplePurpose
-n or --namespacekubectl get pods -n kube-systemTarget a specific namespace
-okubectl get pods -o wideOutput format (e.g., json, yaml, wide)
--watchkubectl get pods --watchContinuously watch for changes
-fkubectl apply -f config.yamlUse a file (YAML or JSON)

Example: Deploy an App

kubectl apply -f deployment.yaml

This might deploy a Deployment and Service defined in the YAML file.

Pro Tips

  • Use kubectl explain <resource> to learn what a resource is and its fields:

    kubectl explain pod.spec.containers
  • Use kubectl get all to get everything (pods, services, deployments, etc.).

Last updated on