Kubernetes Command Reference
kubectl Common command Quick Reference, and
Pod
kubectl get pods |
Pod |
kubectl get pods -A |
Pod |
kubectl get pods -o wide |
Pod and IP |
kubectl describe pod <name> |
Pod and |
kubectl logs <pod> |
Pod |
kubectl logs <pod> -f --tail=100 |
100 |
kubectl logs <pod> --previous |
|
kubectl exec -it <pod> -- /bin/sh |
Pod |
kubectl delete pod <name> |
Pod(Deployment ) |
kubectl run debug --image=busybox -it --rm -- sh |
Pod |
Deployment
kubectl get deployments |
Deployment |
kubectl create deployment <name> --image=<img> |
Deployment |
kubectl apply -f deployment.yaml |
/New Deployment |
kubectl scale deployment <name> --replicas=3 |
|
kubectl set image deployment/<name> <container>=<image> |
New |
kubectl rollout status deployment/<name> |
New |
kubectl rollout undo deployment/<name> |
|
kubectl rollout history deployment/<name> |
New |
kubectl rollout restart deployment/<name> |
Pod |
Service
kubectl get svc |
Service |
kubectl expose deployment <name> --port=80 --type=ClusterIP |
Service |
kubectl port-forward svc/<name> 8080:80 |
|
kubectl get ingress |
Ingress |
kubectl get endpoints <svc> |
Service Pod |
kubectl get networkpolicy |
|
kubectl create configmap <name> --from-literal=key=value |
ConfigMap |
kubectl create secret generic <name> --from-literal=pwd=123 |
Secret |
kubectl get configmap <name> -o yaml |
ConfigMap |
kubectl get secret <name> -o jsonpath='{.data.key}' | base64 -d |
Secret |
kubectl create configmap <name> --from-file=config.yaml |
ConfigMap |
kubectl edit configmap <name> |
ConfigMap |
kubectl describe pod <name> |
Pod () |
kubectl logs <pod> -c <container> |
|
kubectl exec -it <pod> -- curl localhost:8080/health |
|
kubectl get events --sort-by=.lastTimestamp |
|
kubectl top pods --sort-by=memory |
Pod |
kubectl run debug --image=nicolaka/netshoot -it --rm -- bash |
|
kubectl auth can-i create pods |
|
kubectl get nodes |
|
kubectl top nodes |
|
kubectl cordon <node> |
|
kubectl drain <node> --ignore-daemonsets |
Pod |
kubectl uncordon <node> |
|
kubectl taint nodes <node> key=value:NoSchedule |
|
kubectl config get-contexts |
|
kubectl config use-context <name> |
|
kubectl api-resources |
|
kubectl explain pod.spec.containers |
|
kubectl get all -n <namespace> |
|
kubectl get pv,pvc |
and |
kubectl get quota -n <namespace> |
|
kubectl cluster-info |
|