标签:selector normal replicat lock sid container one contain png
1 [root@uk8s-m-01 study]# vi nginx-deployment.yaml 2 apiVersion: apps/v1beta1 3 kind: Deployment 4 metadata: 5 name: nginx-deployment 6 spec: 7 replicas: 3 8 template: 9 metadata: 10 labels: 11 app: nginx 12 spec: 13 containers: 14 - name: nginx 15 image: nginx:1.7.9 16 ports: 17 - containerPort: 80 18 19 [root@uk8s-m-01 study]# kubectl create -f nginx-deployment.yaml 20 [root@uk8s-m-01 study]# kubectl get pods
1 [root@uk8s-m-01 study]# kubectl get deployment #查看deployment 2 [root@uk8s-m-01 study]# kubectl set image deployment/nginx-deployment nginx=nginx:1.8.1 #命令更新 3 [root@uk8s-m-01 study]# kubectl get pods #查看升级后的pod
1 [root@uk8s-m-01 study]# kubectl edit deployment/nginx-deployment #直接编辑deployment
1 [root@uk8s-m-01 study]# kubectl rollout status deployment/nginx-deployment #查看升级情况
1 [root@uk8s-m-01 study]# kubectl get pods 2 [root@uk8s-m-01 study]# kubectl describe pod nginx-deployment-7448597cd5-8sng2 | grep Image
1 [root@uk8s-m-01 study]# kubectl describe deployments/nginx-deployment #观察Deployment的更新过程
1 [root@uk8s-m-01 study]# kubectl get rs #查看多次升级的结果
1 [root@uk8s-m-01 study]# kubectl rollout history deployment/nginx-deployment #查看部署历史 2 [root@uk8s-m-01 study]# kubectl rollout history deployment/nginx-deployment --revision=3 #查看对应的部署历史版本 3 [root@uk8s-m-01 study]# kubectl rollout history deployment/nginx-deployment --revision=2 #查看对应的部署历史版本
1 [root@uk8s-m-01 study]# kubectl rollout undo deployment/nginx-deployment --to-revision=2 #回滚版本 2 [root@uk8s-m-01 study]# kubectl describe deployment/nginx-deployment
1 [root@uk8s-m-01 study]# kubectl get deployments #查看deployment 2 [root@uk8s-m-01 study]# kubectl get rs #查看rs 3 [root@uk8s-m-01 study]# kubectl rollout pause deployment/nginx-deployment #暂停deployment 4 [root@uk8s-m-01 study]# kubectl set image deployment/nginx-deployment nginx=nginx:1.10.3 #升级操作,但由于暂停deployment,因此不会触发更新 5 [root@uk8s-m-01 study]# kubectl rollout history deployment/nginx-deployment #查看历史版本 6 [root@uk8s-m-01 study]# kubectl set resources deployment/nginx-deployment -c=nginx --limits=cpu=200m,memory=512Mi 7 [root@uk8s-m-01 study]# kubectl rollout resume deployment/nginx-deployment #恢复deployment 8 [root@uk8s-m-01 study]# kubectl get rs 9 NAME DESIRED CURRENT READY AGE 10 nginx-deployment-7448597cd5 0 0 0 52m 11 nginx-deployment-84bc94dcb7 1 1 0 6s 12 nginx-deployment-b5f766d54 3 3 3 55m
1 [root@uk8s-m-01 study]# kubectl describe deployment/nginx-deployment 2 [root@uk8s-m-01 study]# kubectl describe pods nginx-deployment-84bc94dcb7-hqxkk | grep Image 3 Image: nginx:1.10.3
1 [root@uk8s-m-01 study]# vi redis-master-controller-v1.yaml 2 apiVersion: v1 3 kind: ReplicationController 4 metadata: 5 name: redis-master-v1 6 labels: 7 name: redis-master 8 spec: 9 replicas: 1 10 selector: 11 name: redis-master 12 template: 13 metadata: 14 labels: 15 name: redis-master 16 spec: 17 containers: 18 - name: master 19 image: kubeguide/redis-master:1.0 20 ports: 21 - containerPort: 6379 22 23 [root@uk8s-m-01 study]# kubectl create -f redis-master-controller-v1.yaml
1 [root@uk8s-m-01 study]# vi redis-master-controller-v2.yaml #RC升级配置文件 2 apiVersion: v1 3 kind: ReplicationController 4 metadata: 5 name: redis-master-v2 6 labels: 7 name: redis-master 8 version: v2 9 spec: 10 replicas: 1 11 selector: 12 name: redis-master 13 version: v2 14 template: 15 metadata: 16 labels: 17 name: redis-master 18 version: v2 19 spec: 20 containers: 21 - name: master 22 image: kubeguide/redis-master:2.0 23 ports: 24 - containerPort: 6379
1 [root@uk8s-m-01 study]# kubectl rolling-update redis-master-v1 -f redis-master-controller-v2.yaml 2 [root@uk8s-m-01 study]# kubectl rolling-update redis-master-v1 --image=kubeguide/redis-master:2.0 #也可直接命令中升级
1 [root@uk8s-m-01 study]# kubectl rolling-update redis-master-v1 --rollback
标签:selector normal replicat lock sid container one contain png
原文地址:https://www.cnblogs.com/itzgr/p/11910832.html