Back to Glossary
Operations

kubectl

The official Kubernetes command-line tool for interacting with the cluster API — deploying, inspecting, and managing resources.

What is kubectl?

kubectl (pronounced 'kube-control' or 'kube-c-t-l') is the official CLI for Kubernetes. It communicates with the Kubernetes API server using the configuration in ~/.kube/config (or the KUBECONFIG environment variable), which stores cluster connection details, authentication credentials, and context definitions. Nearly every Kubernetes operation — applying manifests, inspecting resource state, viewing logs, executing commands in containers, port-forwarding — is available through kubectl commands.

kubectl's core commands fall into a few categories: imperative commands (kubectl create, kubectl delete, kubectl scale) that directly mutate cluster state; declarative commands (kubectl apply, kubectl diff) that reconcile YAML/JSON manifests against cluster state; inspection commands (kubectl get, kubectl describe, kubectl top, kubectl logs); and cluster management commands (kubectl rollout, kubectl drain, kubectl cordon). The kubectl apply command with GitOps workflows is the standard production deployment mechanism.

kubectl supports powerful output formatting: -o yaml and -o json output raw object representations; -o jsonpath and -o go-template extract specific fields; -o wide shows additional columns for human-readable views. The kubectl explain command documents every field of every API object, making it an invaluable reference without leaving the terminal.

Example

# Apply a manifest
kubectl apply -f deployment.yaml

# Get all resources in a namespace
kubectl get all -n production

# Watch pod status in real-time
kubectl get pods -n production -w

# Execute a command in a running container
kubectl exec -it my-pod -n production -- /bin/sh

# Port-forward a local port to a pod
kubectl port-forward pod/my-pod 8080:8080 -n production

# View resource usage
kubectl top pods --all-namespaces --sort-by=memory

Cost & Waste Implications

kubectl is cost-neutral itself, but it's the tool through which all cost-generating mistakes are made — manually running kubectl delete deployment causing data loss, kubectl scale setting replicas too high, or kubectl apply applying a resource-intensive manifest to the wrong cluster. kubectl also enables the cost-saving queries: finding all orphaned resources, listing all LoadBalancer Services, or identifying Pods with no resource requests.

KorPro— Kubernetes Cost Optimization

How KorPro Helps

KorPro provides a read-only view of cluster resources without requiring kubectl access for individual team members, enabling cost and waste visibility without granting broad cluster permissions.

Scan Your Cluster Free

Stop Wasting Money on Orphaned Kubernetes Resources

KorPro connects to your clusters across GCP, AWS, and Azure — no agents, no installation — and surfaces every orphaned resource with its monthly cost estimate.