BeginnerLesson 10 of 35
kubectl essentials
The commands for 90% of daily work.
bash
kubectl get <resource> [-o wide|yaml|json] [-w]
kubectl describe <resource> <name> # events explain most problems
kubectl logs <pod> [-c container] [-f] [--previous]
kubectl exec -it <pod> -- sh
kubectl port-forward svc/web 8080:80
kubectl apply -f file.yaml # create or update (declarative)
kubectl delete -f file.yaml
kubectl explain deployment.spec.strategy # built-in docs
kubectl get events --sort-by=.lastTimestampUse -o yaml --dry-run=client to generate manifests: kubectl create deployment web --image=nginx --dry-run=client -o yaml.