nôm na
k8s chuẩn cần >= 2 máy: 1 máy điều khiển (control-plane) - 1 máy là agent/worker/node
học k3s (nhẹ hơn, ko cần tới 2 máy, nhưng vẫn đủ thành phần (1 máy vừa là server vừa là agent))
tuy nhiên cú pháp giống hệt nhau
trang chủ: https://k3s.io/
kubectl create namespace <ns>
kubectl get pods -o wide
kubectl describe pods
kubectl logs <pod-name>
kubectl exec <pod-name> -- <cmd>
kubectl rollout restart deployment/<dp-name>
kubectl scale --replicas=0 deployment/<dp-name>
kubectl exec -it <pod-name> -- /bin/sh
Remove stuck pods
If there’s a pod that keep coming back after delete, we have to check its controller by this command:
kubectl describe pod <pod_name>
Look for the “Controlled By” field in the output
Or
kubectl get pod <pod_name> -o=json
Then look for “metadata.ownerReferences” field
Exec as root
https://linuxdatahub.com/solved-execute-commands-on-kubernetes-pods-with-root-access/