[Kubernetes] container cluster management commonly used commands notes

A cluster deployment - query cluster status

① query k8s master each component health status:

kubectl get componentstatus

② query k8s node health status:

kubectl get node

Two, kubectl- management tools


① Creating

kubectl run nginx --replicas=3 --labels="app=example" --image=nginx:1.10 --port=80

② View

kubectl get deploy
kubectl get pods --show-labels
kubectl get pods -l app=example
kubectl get pods -o wide

③ release

kubectl expose deployment nginx --port=88 --type=NodePort --target-port=80 --name=nginx-service
kubectl describe service nginx-service

④ Troubleshooting

kubectl describe TYPE NAME_PREFIX
kubectl logs nginx-xxx
kubectl exec –it nginx-xxx bash

⑤ update

kubectl set image deployment/nginx nginx=nginx:1.11
or
kubectl edit deployment/nginx

资源发布管理:
kubectl rollout status deployment/nginx
kubectl rollout history deployment/nginx
kubectl rollout history deployment/nginx --revision=3
kubectl scale deployment nginx --replicas=10

⑥ rollback

kubectl rollout undo deployment/nginx-deployment
kubectl rollout undo deployment/nginx-deployment --to-revision=3

⑦ delete

kubectl delete deploy/nginx
kubectl delete svc/nginx-service

Three, Pod Management - Create / query / update / delete

① create pod resources

kubectl create -f pod.yaml

② view the pods

kubectl get pods nginx-pod

③ View pod description

kubectl describe pod nginx-pod

④ updated resource

kubectl apply -f pod.yaml

⑤ delete resources

kubectl delete pod nginx-pod

Guess you like

Origin www.cnblogs.com/wucaiyun1/p/11721284.html