kubernetes之kubectl与YAML详解1( 六 )


根据帮助信息里的修改,deployment名字要对上 。后面容器名字=新的镜像要对上容器名,把pod后面的随机字符串去掉就行 。貌似也就是deployment名称呀 。-w会实时显示pod的情况

kubernetes之kubectl与YAML详解1

文章插图

kubernetes之kubectl与YAML详解1

文章插图
不知道为啥,master上执行命令,拉取镜像很慢,拉取不下来,但是我直接取node上docker pull很快的 。可能是node上直接用的配置文件里面的三个镜像地址,而kubectl去拉去镜像,用的是k8s集群里哪里设置的一个镜像地址吧?我记得之前设置了一个阿里云镜像地址的 。所以我直接就在node上执行命令拉取镜像了 。让pod不用显示拉取镜像这一个步骤了 。
-w可能理解有误,我这直接去node上执行命令pull镜像之后,貌似已经运行了,但是-w这里还是那里卡着不动 。
kubernetes之kubectl与YAML详解1

文章插图
我们再次去浏览器上的响应头里看,发现已经成了我们修改的1.14版本了
kubernetes之kubectl与YAML详解1

文章插图
我们层层查看,就用这个命令来查看版本
kubernetes之kubectl与YAML详解1

文章插图
[root@mcwk8s04 ~]# kubectl get deployNAMEREADYUP-TO-DATEAVAILABLEAGEmcw-nginx-deployment3/3333h54m[root@mcwk8s04 ~]#kubectl rollout history deployment/mcw-nginx-deploymentdeployment.extensions/mcw-nginx-deploymentREVISIONCHANGE-CAUSE1<none>2<none>[root@mcwk8s04 ~]# 回滚到上一个版本以及查看回滚的状态
[root@mcwk8s04 ~]#kubectl rollout undo deployment/mcw-nginx-deploymentdeployment.extensions/mcw-nginx-deployment rolled back[root@mcwk8s04 ~]#kubectl rollout status deployment/mcw-nginx-deploymentWaiting for deployment "mcw-nginx-deployment" rollout to finish: 1 out of 3 new replicas have been updated...Waiting for deployment "mcw-nginx-deployment" rollout to finish: 1 out of 3 new replicas have been updated...Waiting for deployment "mcw-nginx-deployment" rollout to finish: 1 out of 3 new replicas have been updated...Waiting for deployment "mcw-nginx-deployment" rollout to finish: 2 out of 3 new replicas have been updated...Waiting for deployment "mcw-nginx-deployment" rollout to finish: 2 out of 3 new replicas have been updated...Waiting for deployment "mcw-nginx-deployment" rollout to finish: 2 old replicas are pending termination...Waiting for deployment "mcw-nginx-deployment" rollout to finish: 1 old replicas are pending termination...Waiting for deployment "mcw-nginx-deployment" rollout to finish: 1 old replicas are pending termination...deployment "mcw-nginx-deployment" successfully rolled out[root@mcwk8s04 ~]#kubectl rollout status deployment/mcw-nginx-deploymentdeployment "mcw-nginx-deployment" successfully rolled out[root@mcwk8s04 ~]# 再刷新一下,页面上已经显示之前的那个版本了
kubernetes之kubectl与YAML详解1

文章插图
删除资源[root@mcwk8s04 ~]# kubectl get deployNAMEREADYUP-TO-DATEAVAILABLEAGEmcw-nginx-deployment3/3334h1m[root@mcwk8s04 ~]# kubectl delete deploy mcw-nginx-deploymentdeployment.extensions "mcw-nginx-deployment" deleted[root@mcwk8s04 ~]# kubectl get podNAMEREADYSTATUSRESTARTSAGEmcw-nginx-deployment-86466dbd78-8r5wr0/1Terminating04m23s[root@mcwk8s04 ~]# kubectl get podNo resources found.[root@mcwk8s04 ~]# kubectl get svcNAMETYPECLUSTER-IPEXTERNAL-IPPORT(S)AGEkubernetesClusterIP10.2.0.1<none>443/TCP5d22hmcw-nginx-serviceNodePort10.2.0.252<none>80:39719/TCP3h6m[root@mcwk8s04 ~]# kubectl delete svc mcw-nginx-serviceservice "mcw-nginx-service" deleted[root@mcwk8s04 ~]# kubectl get svcNAMETYPECLUSTER-IPEXTERNAL-IPPORT(S)AGEkubernetesClusterIP10.2.0.1<none>443/TCP5d22h[root@mcwk8s04 ~]#

经验总结扩展阅读