2.9、深入pod-滚动升级

先创建一个rc,启动v1版的redis-master

apiVersion: v1
kind: ReplicationController 
metadata:
  name: redis-master-roll
  labels:
    name: redis-master-roll 
spec:
  replicas: 1
  selector:
    name: redis-master-roll
  template:
    metadata:
      labels:
        name: redis-master-roll
    spec:
      containers:
      - name: master
        image: kubeguide/redis-master
        ports:
        - containerPort: 6379

然后创建滚动升级配置

apiVersion: v1
kind: ReplicationController
metadata:
  name: redis-master-roll-v2
  labels:
    name: redis-master-roll
    version: v2
spec:
  replicas: 1
  selector:
    name: redis-master-roll-v2
    version: v2
  template:
    metadata:
      labels:
        name: redis-master-roll-v2
        version: v2
    spec:
      containers:
      - name: master
        image: kubeguide/redis-master
        ports:
        - containerPort: 6379
# 执行升级命令
[root@k8s-master 2]# kubectl rolling-update redis-master -f pod-redis-master-v2.yaml
Command "rolling-update" is deprecated, use "rollout" instead
Created redis-master-roll-v2
Scaling up redis-master-roll-v2 from 0 to 1, scaling down redis-master from 4 to 0 (keep 1 pods available, don't exceed 2 pods)
Scaling redis-master down to 1
Scaling redis-master-roll-v2 up to 1
Scaling redis-master down to 0
Update succeeded. Deleting old controller: redis-master
Renaming redis-master-roll-v2 to redis-master
replicationcontroller/redis-master rolling updated

你可能感兴趣的:(2.9、深入pod-滚动升级)