5.3 执行滚动升级
apiVersion: apps/v1 kind: Deployment metadata: name: hello-deploy spec: replicas: 10 selector: matchLabels: app: hello-world minReadySeconds: 10 strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 1 template: metadata: labels: app: hello-world spec: containers: - name: hello-pod image: nigelpoulton/k8sbook:edge ports: - containerPort: 8080
更改上面deploy.yaml里面的image的版本
kubectl apply -f deploy.yml --record
当你使用 kubectl apply -f deploy.yml --record 命令时,你正在应用或更新(如果资源已存在)由 deploy.yml 文件定义的 Kubernetes 资源,并且通过 --record 参数,Kubernetes 会记录此次更改的详细信息,这样之后你可以更容易地追踪资源的变更历史
[root@master k8s]# kubectl apply -f deploy.yml --record
deployment.apps/hello-deploy configured
kubectl rollout status deployment hello-deploy
可以看到正在依次更新
kubectl rollout status deployment hello-deploy Waiting for deployment "hello-deploy" rollout to finish: 3 out of 10 new replicas have been updated... Waiting for deployment "hello-deploy" rollout to finish: 3 out of 10 new replicas have been updated... Waiting for deployment "hello-deploy" rollout to finish: 3 out of 10 new replicas have been updated... Waiting for deployment "hello-deploy" rollout to finish: 3 out of 10 new replicas have been updated... Waiting for deployment "hello-deploy" rollout to finish: 4 out of 10 new replicas have been updated... Waiting for deployment "hello-deploy" rollout to finish: 4 out of 10 new replicas have been updated...

浏览器查看可以看到页面已经发生改变
※ 注意这里可以使用火狐浏览器 50.0版本的来访问

浙公网安备 33010602011771号