1. 程式人生 > 其它 >K8s 常用命令(隨時更新......)

K8s 常用命令(隨時更新......)

1.建立deployment
kubectl create -f nginx-deployment.yaml

2.檢視deployment
kubectl get deployment

3.檢視Pod
kubectl get pod -o wide

4.測試Pod訪問
curl --head 10.2.83.17

5.更新Deployment
kubectl set image deployment/nginx-deployment nginx=nginx:1.14.2 --record

6.檢視更新後的Deployment
kubectl get deployment -o wide

7.檢視更新歷史
kubectl rollout history deployment/nginx-deployment

  檢視升級狀態
kubectl rollout status deployment/nginx-deployment

8.檢視具體某一個版本的升級歷史
kubectl rollout history deployment/nginx-deployment --revision=1

9.快速回滾到上一個版本
kubectl rollout undo deployment/nginx-deployment

10.擴容到5個節點
kubectl scale deployment nginx-deployment --replicas 5
 
11.檢視dployment完整過程
kubectl describe deployment
 
12.刪除deployment
kubectl delete deployment  nginx-deployment

13.檢視service
kubectl get service

14.檢視當前叢集元件狀態
kubectl get cs

15.檢視kube-system名稱空間裡的服務
kubectl get deployment -n kube-system
kubectl get service -n kube-system

16.檢視kube-system名稱空間裡所有服務
kubectl get all -n kube-system

17.檢視所有節點狀態
kubectl get nodes

18. 擴容pod
kubectl scale rc nginx-rc --replicas=5

19. 滾動更新nginx版本
kubectl rolling-update nginx-rc --image=192.168.56.80/devopsedu/nginx:1.14.0