iocalhost.nl // no place like ::1
references Containers & Orchestration kubectl

kubectl

Kubernetes-resources bekijken, beheren en debuggen.

Bekijken

kubectl get pods                  -A = alle namespaces
kubectl get pods -o wide          met node/IP
kubectl get svc,deploy,ingress
kubectl describe pod <naam>       details + events
kubectl get events --sort-by=.lastTimestamp
kubectl get pods -n kube-system

Namespaces & context

kubectl config get-contexts
kubectl config use-context <naam>
kubectl config set-context --current --namespace=prod
kubectl get ns

Toepassen & wijzigen

kubectl apply -f manifest.yaml
kubectl delete -f manifest.yaml
kubectl scale deploy/web --replicas=3
kubectl rollout restart deploy/web
kubectl rollout status deploy/web
kubectl rollout undo deploy/web        terugrollen
kubectl edit deploy/web                live bewerken

Debuggen

kubectl logs <pod>                 -f volgen, --previous voor gecrashte
kubectl logs <pod> -c <container>  specifieke container
kubectl exec -it <pod> -- sh       shell
kubectl port-forward svc/web 8080:80
kubectl cp <pod>:/pad ./lokaal
kubectl top pods                   resourcegebruik

Snel

kubectl run tmp --rm -it --image=busybox -- sh    wegwerp-pod
kubectl get pod <naam> -o yaml                     volledige spec
kubectl apply -k ./                                kustomize