Kubernetes CLI: kubectl

kubectl is the command line interface for Kubernetes.

Basic kubectl commands

kubectl get podsList all pods
kubectl cluster-infoDisplay cluster information
kubectl get allList all resources: Pods, deployments, services, etc.
kubectl run [container-name] --image=[image-name]Create a deployment for a pod
kubectl port-forward [pod-name] [port-number]Forward a port to a pod to allow external access
kubectl create [resource]Create a resource
kubectl apply [resource]Create or update resource

Useful Aliases for kubectl

A common practice for kubectl is to alias it to k for convenience.

To alias kubectl to k in PowerShell:

Set-Alias -Name k -Value kubectl

To alias kubectl to k in bash:

alias k="kubectl"

You can test the alias by running k version.

Broader Topics Related to Kubernetes CLI: kubectl

Command-line Interfaces (CLI)

Programs that take commands through terminals and shells

Kubernetes (k8s)

A system to conduct an orchestra of containers

Kubernetes CLI: kubectl Knowledge Graph