首页
技术小册
AIGC
面试刷题
技术文章
MAGENTO
云计算
视频课程
源码下载
PDF书籍
「涨薪秘籍」
登录
注册
1. Pod
1.1. Pod介绍
1.1.1. Pod简介
1.1.2. Pod生命周期
1.1.3. Pod状态
1.2. Pod模板
1.2.1. apiversion/kind
1.2.2. metadata
1.2.3. spec
1.2.4. k8s和image中的命令
1.2.5. 就绪性探测和存活性探测
1.3. 案例
1.3.1. 创建简单pod
1.3.2. 带健康检测的pod
2. Deployment
2.1. 介绍
2.1.1. 简介
2.1.2. 部署方式
2.1.3. Deployment升级方案
2.2. 模板
2.3. 案例
2.3.1. 创建deployment
2.3.2. 模拟蓝绿发布
2.3.3. 滚动发布
2.3.4. 模拟灰度(金丝雀)发布
2.3.5. 版本回滚
2.3.6. 常用命令
3. DaemonSet
3.1. DaemonSet介绍
3.2. 模板
3.3. 案例
3.3.1. 创建daemonset
3.3.2. 升级daemonset
4. Job
4.1. Job介绍
4.2. 模板
4.3. 案例
5. CronJob
5.1. cronjob介绍
5.2. 模板
5.3. 案例
6. StatefulSet
6.1. 介绍
6.1.1. Statefulset使用场景
6.1.2. Statefulset注意项
6.2. 模板
6.3. 案例
6.3.1. 创建Statefulset资源
6.3.2. 扩缩容
6.3.3. 滚动更新
6.3.4. 删除Statefulset
6.3.5. 部署有状态应用一般思路
7. 原理分析
8. 调度
8.1. 调度器
8.2. 节点选择器
8.3. 节点亲和性
8.4. Pod亲和性
8.5. 污点和污点容忍度
当前位置:
首页>>
技术小册>>
Kubernets合辑5-Pod控制器
小册名称:Kubernets合辑5-Pod控制器
滚动更新是按照倒序方式进行,可以指定分区号,如指定分区号N,则表示更新序号大于等于N的Pod,默认分区为0,表示更新所有Pod ``` [root@maxiaoke local-k8s-yaml]# kubectl -n apps set image sts nginx-web nginx-web=linuxmaxiaoke/nginx:v1.0.1 [root@maxiaoke ~]# kubectl get pod -n apps -w # 注意是倒序更新所有Pod NAME READY STATUS RESTARTS AGE nginx-web-0 1/1 Running 2 10h nginx-web-1 1/1 Running 2 10h nginx-web-1 1/1 Terminating 2 10h nginx-web-1 0/1 Terminating 2 10h nginx-web-1 0/1 Terminating 2 10h nginx-web-1 0/1 Terminating 2 10h nginx-web-1 0/1 Pending 0 0s nginx-web-1 0/1 Pending 0 0s nginx-web-1 0/1 ContainerCreating 0 0s nginx-web-1 0/1 Running 0 22s nginx-web-1 1/1 Running 0 27s nginx-web-0 1/1 Terminating 2 10h nginx-web-0 0/1 Terminating 2 10h nginx-web-0 0/1 Terminating 2 10h nginx-web-0 0/1 Terminating 2 10h nginx-web-0 0/1 Pending 0 0s nginx-web-0 0/1 Pending 0 0s nginx-web-0 0/1 ContainerCreating 0 0s nginx-web-0 0/1 ErrImagePull 0 29s nginx-web-0 0/1 ImagePullBackOff 0 44s nginx-web-0 0/1 Running 0 62s nginx-web-0 1/1 Running 0 70s ``` ``` [root@maxiaoke local-k8s-yaml]# kubectl -n apps patch sts nginx-web -p '{"spec":{"replicas":5}}' # 扩容到5个副本,方便演示 [root@maxiaoke local-k8s-yaml]# kubectl -n apps patch sts nginx-web -p '{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":3}}}}' # 指定更新分区为3 [root@maxiaoke local-k8s-yaml]# kubectl -n apps set image sts nginx-web nginx-web=linuxmaxiaoke/nginx:v1.0.2 # 开始更新 [root@maxiaoke ~]# kubectl get pod -n apps -w # 只更新序号4和3的Pod NAME READY STATUS RESTARTS AGE nginx-web-0 1/1 Running 0 6m31s nginx-web-1 1/1 Running 0 7m12s nginx-web-2 1/1 Running 0 3m38s nginx-web-3 1/1 Running 0 3m33s nginx-web-4 1/1 Running 0 3m23s nginx-web-4 1/1 Terminating 0 3m25s nginx-web-4 0/1 Terminating 0 3m26s nginx-web-4 0/1 Terminating 0 3m32s nginx-web-4 0/1 Terminating 0 3m32s nginx-web-4 0/1 Pending 0 0s nginx-web-4 0/1 Pending 0 0s nginx-web-4 0/1 ContainerCreating 0 0s nginx-web-4 0/1 Running 0 10s nginx-web-4 1/1 Running 0 17s nginx-web-3 1/1 Terminating 0 3m59s nginx-web-3 0/1 Terminating 0 4m nginx-web-3 0/1 Terminating 0 4m1s nginx-web-3 0/1 Terminating 0 4m1s nginx-web-3 0/1 Pending 0 0s nginx-web-3 0/1 Pending 0 0s nginx-web-3 0/1 ContainerCreating 0 0s nginx-web-3 0/1 Running 0 22s nginx-web-3 1/1 Running 0 25s ``` ``` [root@maxiaoke local-k8s-yaml]# kubectl -n apps patch sts nginx-web -p '{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":0}}}}' # 修改分区为0 [root@maxiaoke ~]# kubectl get pod -n apps -w # 会更新剩下来的三个Pod NAME READY STATUS RESTARTS AGE nginx-web-0 1/1 Running 0 9m10s nginx-web-1 1/1 Running 0 9m51s nginx-web-2 1/1 Running 0 6m17s nginx-web-3 1/1 Running 0 2m11s nginx-web-4 1/1 Running 0 2m30s nginx-web-2 1/1 Terminating 0 6m24s nginx-web-2 0/1 Terminating 0 6m24s nginx-web-2 0/1 Terminating 0 6m25s nginx-web-2 0/1 Terminating 0 6m25s nginx-web-2 0/1 Pending 0 0s nginx-web-2 0/1 Pending 0 0s nginx-web-2 0/1 ContainerCreating 0 0s nginx-web-2 0/1 Running 0 1s nginx-web-2 1/1 Running 0 9s nginx-web-1 1/1 Terminating 0 10m nginx-web-1 0/1 Terminating 0 10m nginx-web-1 0/1 Terminating 0 10m nginx-web-1 0/1 Terminating 0 10m nginx-web-1 0/1 Pending 0 0s nginx-web-1 0/1 Pending 0 0s nginx-web-1 0/1 ContainerCreating 0 0s nginx-web-1 0/1 Running 0 1s nginx-web-1 1/1 Running 0 8s nginx-web-0 1/1 Terminating 0 9m47s nginx-web-0 0/1 Terminating 0 9m48s nginx-web-0 0/1 Terminating 0 10m nginx-web-0 0/1 Terminating 0 10m nginx-web-0 0/1 Pending 0 0s nginx-web-0 0/1 Pending 0 0s nginx-web-0 0/1 ContainerCreating 0 0s nginx-web-0 0/1 Running 0 1s nginx-web-0 1/1 Running 0 9s ```
上一篇:
6.3.2. 扩缩容
下一篇:
6.3.4. 删除Statefulset
该分类下的相关小册推荐:
Kubernetes中文教程(三)
Kubernets合辑12-配置中心
Kubernets合辑3-kubernetes介绍
Kubernets合辑9-资源约束
Kubernets合辑8-权限控制
Kubernets合辑14-日志收集
Kubernets合辑13-集群监控
云原生-K8S入门实战
Kubernets合辑7-存储
Kubernets合辑15-持续部署
Kubernetes中文教程(一)
Kubernets合辑2-部署Ingress