statefulset和daemonset的滚动更新操作记录

分类讨论
daemonset滚动升级:
每台宿主机上的pod会先缩一个再弹出一个。

yaml文件配置解释如下
[root@a17216105175 101-10001]# kubectl explain daemonsets.spec.updateStrategy
KIND:     DaemonSet
VERSION:  extensions/v1beta1

RESOURCE: updateStrategy <Object>

DESCRIPTION:
     An update strategy to replace existing DaemonSet pods with new pods.

FIELDS:
   rollingUpdate        <Object>
     Rolling update config params. Present only if type = "RollingUpdate".

   type <string>
     Type of daemon set update. Can be "RollingUpdate" or "OnDelete". Default is
     OnDelete.

[root@a17216105175 101-10001]# kubectl explain daemonsets.spec.updateStrategy.rollingUpdate
KIND:     DaemonSet
VERSION:  extensions/v1beta1

RESOURCE: rollingUpdate <Object>

DESCRIPTION:
     Rolling update config params. Present only if type = "RollingUpdate".

     Spec to control the desired behavior of daemon set rolling update.

FIELDS:
   maxUnavailable       <string>
     The maximum number of DaemonSet pods that can be unavailable during the
     update. Value can be an absolute number (ex: 5) or a percentage of total
     number of DaemonSet pods at the start of the update (ex: 10%). Absolute
     number is calculated from percentage by rounding up. This cannot be 0.
     Default value is 1. Example: when this is set to 30%, at most 30% of the
     total number of nodes that should be running the daemon pod (i.e.
     status.desiredNumberScheduled) can have their pods stopped for an update at
     any given time. The update starts by stopping at most 30% of those
     DaemonSet pods and then brings up new DaemonSet pods in their place. Once
     the new pods are available, it then proceeds onto other DaemonSet pods,
     thus ensuring that at least 70% of original number of DaemonSet pods are
     available at all times during the update.

修改yaml如下:
spec:
  selector:
    matchLabels:
      name: iag-ds
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
执行命令如下:
kubectl set image daemonset/iag-ds iag=178.28.214.7:5000/zxiptv-req-all-dsiagv7.01.04.02/27:zxiptv-req-all-dsiag-pv7.01.04.02.image

pod变化过程如下:
[root@a17216105175 ~]# kubectl get pods -l name=iag-ds -o wide -w
NAME           READY   STATUS        RESTARTS   AGE   IP               NODE             NOMINATED NODE   READINESS GATES
iag-ds-4hrb6   1/1     Running       0          8d    80.80.102.130    80.80.102.130    <none>           <none>
iag-ds-6898f   1/1     Running       0          8d    172.16.105.219   172.16.105.219   <none>           <none>
iag-ds-6lhqm   1/1     Running       0          8d    172.16.105.33    172.16.105.33    <none>           <none>
iag-ds-lbz7k   1/1     Running       0          8d    172.16.105.175   172.16.105.175   <none>           <none>
iag-ds-p7n29   1/1     Terminating   3          62d   80.80.102.131    80.80.102.131    <none>           <none>

iag-ds-4hrb6   1/1   Terminating   0     8d    80.80.102.130   80.80.102.130   <none>   <none>
iag-ds-4hrb6   0/1   Terminating   0     8d    80.80.102.130   80.80.102.130   <none>   <none>
iag-ds-4hrb6   0/1   Terminating   0     8d    80.80.102.130   80.80.102.130   <none>   <none>
iag-ds-4hrb6   0/1   Terminating   0     8d    80.80.102.130   80.80.102.130   <none>   <none>
iag-ds-6lnjl   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
iag-ds-6lnjl   0/1   Pending   0     0s    <none>   80.80.102.130   <none>   <none>
iag-ds-6lnjl   0/1   ContainerCreating   0     0s    80.80.102.130   80.80.102.130   <none>   <none>
iag-ds-6lnjl   1/1   Running   0     2s    80.80.102.130   80.80.102.130   <none>   <none>
iag-ds-6lhqm   1/1   Terminating   0     8d    172.16.105.33   172.16.105.33   <none>   <none>
iag-ds-6lhqm   0/1   Terminating   0     8d    172.16.105.33   172.16.105.33   <none>   <none>
iag-ds-6lhqm   0/1   Terminating   0     8d    172.16.105.33   172.16.105.33   <none>   <none>
iag-ds-6lhqm   0/1   Terminating   0     8d    172.16.105.33   172.16.105.33   <none>   <none>
iag-ds-vqwwl   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
iag-ds-vqwwl   0/1   Pending   0     0s    <none>   172.16.105.33   <none>   <none>
iag-ds-vqwwl   0/1   ContainerCreating   0     0s    172.16.105.33   172.16.105.33   <none>   <none>
iag-ds-vqwwl   1/1   Running   0     1s    172.16.105.33   172.16.105.33   <none>   <none>
iag-ds-6898f   1/1   Terminating   0     8d    172.16.105.219   172.16.105.219   <none>   <none>
iag-ds-6898f   0/1   Terminating   0     8d    172.16.105.219   172.16.105.219   <none>   <none>
iag-ds-6898f   0/1   Terminating   0     8d    172.16.105.219   172.16.105.219   <none>   <none>
iag-ds-6898f   0/1   Terminating   0     8d    172.16.105.219   172.16.105.219   <none>   <none>
iag-ds-6898f   0/1   Terminating   0     8d    172.16.105.219   172.16.105.219   <none>   <none>
iag-ds-ft54n   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
iag-ds-ft54n   0/1   Pending   0     0s    <none>   172.16.105.219   <none>   <none>
iag-ds-ft54n   0/1   ContainerCreating   0     0s    172.16.105.219   172.16.105.219   <none>   <none>
iag-ds-ft54n   1/1   Running   0     1s    172.16.105.219   172.16.105.219   <none>   <none>
iag-ds-lbz7k   1/1   Terminating   0     8d    172.16.105.175   172.16.105.175   <none>   <none>
iag-ds-lbz7k   0/1   Terminating   0     8d    172.16.105.175   172.16.105.175   <none>   <none>
iag-ds-lbz7k   0/1   Terminating   0     8d    172.16.105.175   172.16.105.175   <none>   <none>
iag-ds-lbz7k   0/1   Terminating   0     8d    172.16.105.175   172.16.105.175   <none>   <none>
iag-ds-6rxjz   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
iag-ds-6rxjz   0/1   Pending   0     0s    <none>   172.16.105.175   <none>   <none>
iag-ds-6rxjz   0/1   ContainerCreating   0     0s    172.16.105.175   172.16.105.175   <none>   <none>
iag-ds-6rxjz   1/1   Running   0     1s    172.16.105.175   172.16.105.175   <none>   <none>

replicas滚动升级:
建议将所有replicas全部升级为deployment

statefulset滚动升级:
一台宿主机有7个pod epg-cluster-104-10005-0 epg-cluster-104-10005-1 -------epg-cluster-104-10005-6
滚动升级后pod名字不会变,按照epg-cluster-104-10005-6————》epg-cluster-104-10005-0的顺序,先缩pod再扩pod

yaml文件配置解释如下:
[root@a17216105175 104-10005]# kubectl explain statefulset.spec.updateStrategy
KIND:     StatefulSet
VERSION:  apps/v1

RESOURCE: updateStrategy <Object>

DESCRIPTION:
     updateStrategy indicates the StatefulSetUpdateStrategy that will be
     employed to update Pods in the StatefulSet when a revision is made to
     Template.

     StatefulSetUpdateStrategy indicates the strategy that the StatefulSet
     controller will use to perform updates. It includes any additional
     parameters necessary to perform the update for the indicated strategy.

FIELDS:
   rollingUpdate        <Object>
     RollingUpdate is used to communicate parameters when Type is
     RollingUpdateStatefulSetStrategyType.

   type <string>
     Type indicates the type of the StatefulSetUpdateStrategy. Default is
     RollingUpdate.

[root@a17216105175 104-10005]# kubectl explain statefulset.spec.updateStrategy.rollingUpdate
KIND:     StatefulSet
VERSION:  apps/v1

RESOURCE: rollingUpdate <Object>

DESCRIPTION:
     RollingUpdate is used to communicate parameters when Type is
     RollingUpdateStatefulSetStrategyType.

     RollingUpdateStatefulSetStrategy is used to communicate parameter for
     RollingUpdateStatefulSetStrategyType.

FIELDS:
   partition    <integer>
     Partition indicates the ordinal at which the StatefulSet should be
     partitioned. Default value is 0.
     
修改yaml如下
spec:
  serviceName: "epg-cluster-104-10005"
  selector:
    matchLabels:
      name: epg-cluster-104-10005
  replicas: 7
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      partition: 0
      
执行命令如下:
kubectl set image statefulset/epg-cluster-104-10005 epg-cluster-104-10005=178.28.214.7:5000/zxiptv-epg-pv7.01.03.03p1/36:zxiptv-epg-pv7.01.03.03p1.iamge

pod变化过程如下:
[root@a17216105175 ~]# kubectl get pods -l name=epg-cluster-104-10005 -o wide -w
NAME                      READY   STATUS    RESTARTS   AGE     IP             NODE            NOMINATED NODE   READINESS GATES
epg-cluster-104-10005-0   1/1     Running   0          7d2h    162.16.3.111   80.80.102.130   <none>           <none>
epg-cluster-104-10005-1   1/1     Running   0          7h20m   162.16.3.113   80.80.102.130   <none>           <none>
epg-cluster-104-10005-2   1/1     Running   0          7h12m   162.16.3.114   80.80.102.130   <none>           <none>
epg-cluster-104-10005-3   1/1     Running   48         7h12m   162.16.3.115   80.80.102.130   <none>           <none>
epg-cluster-104-10005-4   1/1     Running   48         7h11m   162.16.3.116   80.80.102.130   <none>           <none>
epg-cluster-104-10005-5   1/1     Running   48         7h11m   162.16.3.117   80.80.102.130   <none>           <none>
epg-cluster-104-10005-6   1/1     Running   48         7h11m   162.16.3.118   80.80.102.130   <none>           <none>

epg-cluster-104-10005-6   1/1   Terminating   48    7h11m   162.16.3.118   80.80.102.130   <none>   <none>
epg-cluster-104-10005-6   0/1   Terminating   48    7h12m   162.16.3.118   80.80.102.130   <none>   <none>
epg-cluster-104-10005-6   0/1   Terminating   48    7h12m   162.16.3.118   80.80.102.130   <none>   <none>
epg-cluster-104-10005-6   0/1   Terminating   48    7h12m   162.16.3.118   80.80.102.130   <none>   <none>
epg-cluster-104-10005-6   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
epg-cluster-104-10005-6   0/1   Pending   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-6   0/1   ContainerCreating   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-6   1/1   Running   0     18s   162.16.3.119   80.80.102.130   <none>   <none>
epg-cluster-104-10005-5   1/1   Terminating   48    7h12m   162.16.3.117   80.80.102.130   <none>   <none>
epg-cluster-104-10005-5   0/1   Terminating   48    7h13m   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-5   0/1   Terminating   48    7h13m   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-5   0/1   Terminating   48    7h13m   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-5   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
epg-cluster-104-10005-5   0/1   Pending   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-5   0/1   ContainerCreating   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-5   1/1   Running   0     13s   162.16.3.120   80.80.102.130   <none>   <none>
epg-cluster-104-10005-4   1/1   Terminating   48    7h13m   162.16.3.116   80.80.102.130   <none>   <none>
epg-cluster-104-10005-4   0/1   Terminating   48    7h14m   162.16.3.116   80.80.102.130   <none>   <none>
epg-cluster-104-10005-4   0/1   Terminating   48    7h14m   162.16.3.116   80.80.102.130   <none>   <none>
epg-cluster-104-10005-4   0/1   Terminating   48    7h14m   162.16.3.116   80.80.102.130   <none>   <none>
epg-cluster-104-10005-4   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
epg-cluster-104-10005-4   0/1   Pending   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-4   0/1   ContainerCreating   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-4   1/1   Running   0     15s   162.16.3.121   80.80.102.130   <none>   <none>
epg-cluster-104-10005-3   1/1   Terminating   48    7h14m   162.16.3.115   80.80.102.130   <none>   <none>
epg-cluster-104-10005-3   0/1   Terminating   48    7h15m   162.16.3.115   80.80.102.130   <none>   <none>
epg-cluster-104-10005-3   0/1   Terminating   48    7h15m   162.16.3.115   80.80.102.130   <none>   <none>
epg-cluster-104-10005-3   0/1   Terminating   48    7h15m   162.16.3.115   80.80.102.130   <none>   <none>
epg-cluster-104-10005-3   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
epg-cluster-104-10005-3   0/1   Pending   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-3   0/1   ContainerCreating   0     1s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-3   1/1   Running   0     13s   162.16.3.122   80.80.102.130   <none>   <none>
epg-cluster-104-10005-2   1/1   Terminating   0     7h15m   162.16.3.114   80.80.102.130   <none>   <none>
epg-cluster-104-10005-2   0/1   Terminating   0     7h16m   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-2   0/1   Terminating   0     7h16m   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-2   0/1   Terminating   0     7h16m   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-2   0/1   Terminating   0     7h16m   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-2   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
epg-cluster-104-10005-2   0/1   Pending   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-2   0/1   ContainerCreating   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-2   1/1   Running   0     13s   162.16.3.123   80.80.102.130   <none>   <none>
epg-cluster-104-10005-1   1/1   Terminating   0     7h25m   162.16.3.113   80.80.102.130   <none>   <none>
epg-cluster-104-10005-1   0/1   Terminating   0     7h25m   162.16.3.113   80.80.102.130   <none>   <none>
epg-cluster-104-10005-1   0/1   Terminating   0     7h25m   162.16.3.113   80.80.102.130   <none>   <none>
epg-cluster-104-10005-1   0/1   Terminating   0     7h25m   162.16.3.113   80.80.102.130   <none>   <none>
epg-cluster-104-10005-1   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
epg-cluster-104-10005-1   0/1   Pending   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-1   0/1   ContainerCreating   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-1   1/1   Running   0     12s   162.16.3.124   80.80.102.130   <none>   <none>
epg-cluster-104-10005-0   1/1   Terminating   0     7d2h   162.16.3.111   80.80.102.130   <none>   <none>
epg-cluster-104-10005-0   0/1   Terminating   0     7d2h   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-0   0/1   Terminating   0     7d2h   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-0   0/1   Terminating   0     7d2h   <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-0   0/1   Pending   0     0s    <none>   <none>   <none>   <none>
epg-cluster-104-10005-0   0/1   Pending   0     0s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-0   0/1   ContainerCreating   0     1s    <none>   80.80.102.130   <none>   <none>
epg-cluster-104-10005-0   1/1   Running   0     13s   162.16.3.125   80.80.102.130   <none>   <none>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值