Kubectl Commands
Get list of resource Types
Other Options
kubectl api-resources --namespaced=true # All namespaced resources
kubectl api-resources --namespaced=false # All non-namespaced resources
kubectl api-resources -o name # All resources with simple output (only the resource name)
kubectl api-resources -o wide # All resources with expanded (aka "wide") output
kubectl api-resources --verbs=list,get # All resources that support the "list" and "get" request verbs
kubectl api-resources --api-group=extensions # All resources in the "extensions" API group
Connect to the cluster
gcloud container clusters get-credentials <cluster name> --zone us-central1-c --project <project name>
Get pods
Get deployment
Deploy a deployment
Scale a deployment
Create an LB
See services
Resize a node pool in the cluster
Enable HPA
kubectl autoscale deployment <deployment name> --max=<max containers> --min=<number> --cpu-percent=<number>
Get HPA
Delete HPA
Auto-scaling the cluster
gcloud container clusters update <cluster name> --enable-autoscaling --min-nodes=<min> --max-nodes=<max>
Create a config map
Describe the details of something
Create a secret
Update an image
Get the service IP range
SVCRANGE=$(echo '{"apiVersion":"v1","kind":"Service","metadata":{"name":"tst"},"spec":{"clusterIP":"1.1.1.1","ports":[{"port":443}]}}' | kubectl apply -f - 2>&1 | sed 's/.*valid IPs is //')
echo $SVCRANGE
Enable Autocomplete
source <(kubectl completion bash)
kubectl set image deployment.v1.apps/nginx-deployment nginx=nginx:1.9.1 --record
kubectl rollout status deployment.v1.apps/nginx-deployment
kubectl rollout history deployment nginx-deployment
kubectl rollout undo deployments nginx-deployment
kubectl create secret generic <name> \
--from-file=key.json=$HOME/<file>.json
Want to make this site better? Open a PR or help fund hosting costs