标签:class 架构 完成 ash images selector nts container mtom
应用程序一次只更新一小部分副本,更新成功后,再更新更多的副本,最终完成所有副本的更新。 滚动更新的优点:零停机,整个更新过程始终有副本在运行,从而保证了业务的连续性。
###cat httpd.yaml### apiVersion: apps/v1beta2 kind: Deployment metadata: name: httpd spec: replicas: 3 selector: matchLabels: app: httpd template: metadata: labels: app: httpd spec: containers: - name: httpd image: httpd:2.2.31 imagePullPolicy: IfNotPresent #默认值,本地有则使用本地镜像,不拉取 ports: - containerPort: 80
kubectl apply -f httpd.yaml
应用
kubectl apply -f httpd.yaml --record
--record的作用是将当前命令记录到revision 记录中,这样我们就可以知道每个revison对应的是哪个配置文件
kubectl describe deployment httpd
结果:每次只更新替换一个pod副本
kubectl set image deployments/httpd httpd=httpd:2.2.33
[root@k8s-node1 rolling]# kubectl get deployment -o wide NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR httpd 3 4 1 3 42m httpd httpd:2.2.33 app=httpd mtomcat 1 1 1 1 4d mtomcat liujixiao/java-demo:latest app=mtomcat mynginx 1 1 1 1 9d mynginx nginx:latest name=mynginx mytomcat 1 1 1 1 9d mytomcat tomcat:8 app=mytomcat nginx 1 1 1 1 16d nginx nginx:latest name=nginx [root@k8s-node1 rolling]# kubectl get rs -o wide NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR httpd-7584b484ff 3 3 3 11m httpd httpd:2.2.32 app=httpd,pod-template-hash=3140604099 httpd-cb5f5c5cb 1 1 0 38s httpd httpd:2.2.33 app=httpd,pod-template-hash=761917176 httpd-fbdc45d78 0 0 0 42m httpd httpd:2.2.31 app=httpd,pod-template-hash=968701834 mtomcat-7d6b5577b9 0 0 0 4d mtomcat tomcat:8 app=mtomcat,pod-template-hash=3826113365 mtomcat-b8d9c579 1 1 1 3d mtomcat liujixiao/java-demo:latest app=mtomcat,pod-template-hash=64857135 mynginx-7659f869f4 1 1 1 9d mynginx nginx:latest name=mynginx,pod-template-hash=3215942590 mytomcat-698fb6789 1 1 1 9d mytomcat tomcat:8 app=mytomcat,pod-template-hash=254962345 nginx-5bc649579b 1 1 1 5d nginx nginx:latest name=nginx,pod-template-hash=1672051356 nginx-fd7dc4fbc 0 0 0 16d nginx nginx:latest name=nginx,pod-template-hash=983870967
标签:class 架构 完成 ash images selector nts container mtom
原文地址:https://www.cnblogs.com/yanxinjiang/p/11969717.html