51 kubectl Befehle

Die wertvollste Resource in der Prüfung ist:

kubectl cheatsheet

Aktion Befehl Resultat
Pod kubectl run nginx --image=nginx --dry-run=client -o yaml Erzeugt einen Pod
Deployment kubectl create deploy [NAME] --image=nginx --dry-run=client -o yaml Erzeugt ein Deployment
Service kubectl create service [TYPE] [NAME] --dry-run=client -o yaml Erzeugt einen Service
ConfigMap kubectl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2 --dry-run=client -o yaml Erzeugt eine ConfigMap
Secret kubectl create secret generic my-secret --from-literal=key1=supersecret --from-literal=key2=topsecret --dry-run=client -o yaml Erzeugt ein Secret
Job kubectl create job my-job --image=busybox -- date --dry-run=client -o yaml Erzeugt einen Job
CronJob kubectl create cronjob my-job --image=busybox --schedule="*/1 * * * *" --dry-run=client -o yaml Erzeugt einen CronJob
Namespace kubectl create namespace my-namespace --dry-run=client -o yaml Erzeugt einen Namespace
ServiceAccount kubectl create sa my-app-sa --dry-run=client -o yaml Erzeugt einen ServiceAccount
ClusterRole kubectl create clusterrole pod-reader --verb=get,list,watch --resource=pods --dry-run=client -o yaml Erzeugt eine ClusterRole
ClusterRoleBinding kubectl create clusterrolebinding cluster-admin --clusterrole=cluster-admin --user=user1 --user=user2 --group=group1 --dry-run=client -o yaml Erzeugt eine ClusterRoleBinding
Role kubectl create role pod-reader --verb=get,list,watch --resource=pods --dry-run=client -o yaml Erzeugt eine Role
RoleBinding kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1 --dry-run=client -o yaml Erzeugt eine RoleBinding
Apply kubectl apply -f mypod.yaml Wendet eine Konfiguration an
Delete kubectl delete pods --all Löscht Ressourcen
Describe kubectl describe pods Zeigt Details von Ressourcen
Exec kubectl exec mypod -- date Führt einen Befehl in einem Container aus
Logs kubectl logs nginx Holt die Logs eines Containers
Top kubectl top node Zeigt die Ressourcennutzung an
Expose kubectl expose deployment nginx --port=80 --target-port=8000 Erzeugt einen Service für eine Ressource
Scale kubectl scale --replicas=3 deployment/mysql Skaliert eine Ressource
Rollout kubectl rollout undo deployment/abc Verwaltet Rollouts
Taint kubectl taint nodes foo dedicated=special-user:NoSchedule Fügt Nodes Taints hinzu/entfernt sie
Cordon/Uncordon kubectl cordon foo Aktiviert/Deaktiviert die Planung auf Nodes
Drain kubectl drain foo --force Bereitet einen Node für Wartung vor