[root@k8s-master deployment]# kubectl -n demo get po -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES myblog 1/1 Running 3 10d 10.244.2.40 k8s-slave1 <none> <none> mysql 1/1 Running 2 3d2h 192.168.56.20 k8s-slave1 <none> <none>
#删除旧的mysql pod [root@k8s-master deployment]# kubectl -n demo delete po mysql pod "mysql" deleted
#创建新的mysql pod [root@k8s-master deployment]# kubectl -n demo get po -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES myblog 1/1 Running 3 10d 10.244.2.40 k8s-slave1 <none> <none> [root@k8s-master deployment]# vi deploy-mysql.yaml [root@k8s-master deployment]# kubectl create -f deploy-mysql.yaml deployment.apps/mysql created
#检查状态 [root@k8s-master deployment]# kubectl -n demo get po -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES myblog 1/1 Running 3 10d 10.244.2.40 k8s-slave1 <none> <none> mysql-5fcb655cc9-q48f9 1/1 Running 0 11s 192.168.56.20 k8s-slave1 <none> <none>
#创建myblog pod [root@k8s-master deployment]# kubectl apply -f deploy-myblog.yaml deployment.apps/myblog created
#检查状态 [root@k8s-master deployment]# kubectl -n demo get po -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES myblog 1/1 Running 4 10d 10.244.2.40 k8s-slave1 <none> <none> myblog-749b5dbc4b-fvsk9 1/1 Running 0 15s 10.244.2.43 k8s-slave1 <none> <none> mysql-5fcb655cc9-q48f9 1/1 Running 0 9m7s 192.168.56.20 k8s-slave1 <none> <none>
#删除旧的 myblog pod [root@k8s-master deployment]# kubectl -n demo delete po myblog pod "myblog" deleted
# kubectl api-resources [root@k8s-master deployment]# kubectl -n demo get deploy NAME READY UP-TO-DATE AVAILABLE AGE myblog 1/1 1 1 11m mysql 1/1 1 1 20m
* `NAME` 列出了集群中 Deployments 的名称。 * `READY`显示当前正在运行的副本数/期望的副本数。 * `UP-TO-DATE`显示已更新以实现期望状态的副本数。 * `AVAILABLE`显示应用程序可供用户使用的副本数。 * `AGE` 显示应用程序运行的时间量。 [root@k8s-master deployment]# kubectl -n demo get po NAME READY STATUS RESTARTS AGE myblog-749b5dbc4b-fvsk9 1/1 Running 0 14m mysql-5fcb655cc9-q48f9 1/1 Running 0 22m
#检查副本集状态 [root@k8s-master deployment]# kubectl -n demo get rs NAME DESIRED CURRENT READY AGE myblog-749b5dbc4b 1 1 1 16m mysql-5fcb655cc9 1 1 1 25m
$ kubectl -n demo describe deploy myblog Normal ScalingReplicaSet 37m deployment-controller Scaled up replica set myblog-749b5dbc4b to 2 Normal ScalingReplicaSet 20m deployment-controller Scaled up replica set myblog-785dbb55cc to 1 #启动一个新pod Normal ScalingReplicaSet 19m deployment-controller Scaled down replica set myblog-749b5dbc4b to 1 #关闭一个旧pod Normal ScalingReplicaSet 19m deployment-controller Scaled up replica set myblog-785dbb55cc to 2 #再起一个新pod Normal ScalingReplicaSet 19m deployment-controller Scaled down replica set myblog-749b5dbc4b to 0 #再关一个旧pod
# 正在更新中 [root@k8s-master deployment]# kubectl -n demo get po -o wide NAME READY STATUS RESTARTS AGE myblog-749b5dbc4b-5xmsf 1/1 Terminating 0 22m myblog-749b5dbc4b-jhmc5 1/1 Terminating 0 17m myblog-785dbb55cc-ljjf7 1/1 Running 0 46s myblog-785dbb55cc-r7hpf 1/1 Running 0 21s mysql-5fcb655cc9-q48f9 1/1 Running 0 56m
# 更新完毕 [root@k8s-master deployment]# kubectl -n demo get po -o wide NAME READY STATUS RESTARTS AGE myblog-785dbb55cc-ljjf7 1/1 Running 0 24m myblog-785dbb55cc-r7hpf 1/1 Running 0 23m mysql-5fcb655cc9-q48f9 1/1 Running 0 79m