更新和回滚 DaemonSet
如果添加了新节点或修改了节点标签(Label),DaemonSet 将立刻向新匹配上的节点添加 Pod,同时删除不能匹配的节点上的 Pod。
DaemonSet 更新策略和 StatefulSet 类似,也有 OnDelete 和 RollingUpdate 两种方式。
更新示例
查看 DaemonSet 更新方式:
$ kubectl get ds fluentd-elasticsearch -n kube-system -o go-template='{{.spec.updateStrategy.type}}{{"\n"}}' RollingUpdate
更新镜像
$ kubectl set image ds fluentd-elasticsearch fluentd-elasticsearch=quay.io/fluentd_elasticsearch/fluentd:v4.3 -n kube-system daemonset.apps/fluentd-elasticsearch image updated
查看更新过程
$ kubectl rollout status ds fluentd-elasticsearch -n kube-system Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 1 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 1 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 1 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 2 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 2 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 2 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 2 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 3 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 3 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 3 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 4 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 4 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 4 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 4 out of 5 new pods have been updated... Waiting for daemon set "fluentd-elasticsearch" rollout to finish: 4 of 5 updated pods are available... daemon set "fluentd-elasticsearch" successfully rolled out
查看 image 版本
$ kubectl describe ds fluentd-elasticsearch -n kube-system Name: fluentd-elasticsearch Selector: name=fluentd-elasticsearch Node-Selector: <none> Labels: k8s-app=fluentd-logging Annotations: deprecated.daemonset.template.generation: 2 Desired Number of Nodes Scheduled: 5 Current Number of Nodes Scheduled: 5 Number of Nodes Scheduled with Up-to-date Pods: 5 Number of Nodes Scheduled with Available Pods: 5 Number of Nodes Misscheduled: 0 Pods Status: 5 Running / 0 Waiting / 0 Succeeded / 0 Failed Pod Template: Labels: name=fluentd-elasticsearch Containers: fluentd-elasticsearch: Image: quay.io/fluentd_elasticsearch/fluentd:v4.3 Port: <none> Host Port: <none> Limits: memory: 200Mi Requests: cpu: 100m memory: 200Mi Environment: <none> Mounts: /var/log from varlog (rw) Volumes: varlog: Type: HostPath (bare host directory volume) Path: /var/log HostPathType: Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal SuccessfulCreate 33m daemonset-controller Created pod: fluentd-elasticsearch-r6v22 Normal SuccessfulCreate 33m daemonset-controller Created pod: fluentd-elasticsearch-tftmd Normal SuccessfulCreate 33m daemonset-controller Created pod: fluentd-elasticsearch-swp4z Normal SuccessfulCreate 33m daemonset-controller Created pod: fluentd-elasticsearch-j8hq8 Normal SuccessfulCreate 33m daemonset-controller Created pod: fluentd-elasticsearch-psfkr Normal SuccessfulDelete 11m daemonset-controller Deleted pod: fluentd-elasticsearch-j8hq8 Normal SuccessfulCreate 11m daemonset-controller Created pod: fluentd-elasticsearch-g6w9g Normal SuccessfulDelete 5m46s daemonset-controller Deleted pod: fluentd-elasticsearch-tftmd Normal SuccessfulCreate 5m43s daemonset-controller Created pod: fluentd-elasticsearch-68q7q Normal SuccessfulDelete 5m14s daemonset-controller Deleted pod: fluentd-elasticsearch-psfkr Normal SuccessfulCreate 5m11s daemonset-controller Created pod: fluentd-elasticsearch-9k47j Normal SuccessfulDelete 4m26s daemonset-controller Deleted pod: fluentd-elasticsearch-r6v22 Normal SuccessfulCreate 4m8s daemonset-controller Created pod: fluentd-elasticsearch-kpjxx Normal SuccessfulDelete 3m32s daemonset-controller Deleted pod: fluentd-elasticsearch-swp4z Normal SuccessfulCreate 3m20s daemonset-controller Created pod: fluentd-elasticsearch-4kr9x
回滚示例
查看 revision 列表
$ kubectl rollout history ds fluentd-elasticsearch -n kube-system daemonset.apps/fluentd-elasticsearch REVISION CHANGE-CAUSE 1 <none> 2 <none>
因为在更新镜像时没有使用 --record 选项,因此没有 CHANGE-CAUSE 信息
回滚到上一个 revision
$ kubectl rollout undo ds fluentd-elasticsearch -n kube-system daemonset.apps/fluentd-elasticsearch rolled back
查看镜像版本:
$ kubectl describe ds fluentd-elasticsearch -n kube-system Name: fluentd-elasticsearch Selector: name=fluentd-elasticsearch Node-Selector: <none> Labels: k8s-app=fluentd-logging Annotations: deprecated.daemonset.template.generation: 3 Desired Number of Nodes Scheduled: 5 Current Number of Nodes Scheduled: 5 Number of Nodes Scheduled with Up-to-date Pods: 5 Number of Nodes Scheduled with Available Pods: 5 Number of Nodes Misscheduled: 0 Pods Status: 5 Running / 0 Waiting / 0 Succeeded / 0 Failed Pod Template: Labels: name=fluentd-elasticsearch Containers: fluentd-elasticsearch: Image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2 Port: <none> Host Port: <none> Limits: memory: 200Mi Requests: cpu: 100m memory: 200Mi Environment: <none> Mounts: /var/log from varlog (rw) Volumes: varlog: Type: HostPath (bare host directory volume) Path: /var/log HostPathType: Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal SuccessfulCreate 36m daemonset-controller Created pod: fluentd-elasticsearch-r6v22 Normal SuccessfulCreate 36m daemonset-controller Created pod: fluentd-elasticsearch-tftmd Normal SuccessfulCreate 36m daemonset-controller Created pod: fluentd-elasticsearch-swp4z Normal SuccessfulCreate 36m daemonset-controller Created pod: fluentd-elasticsearch-j8hq8 Normal SuccessfulCreate 36m daemonset-controller Created pod: fluentd-elasticsearch-psfkr Normal SuccessfulDelete 14m daemonset-controller Deleted pod: fluentd-elasticsearch-j8hq8 Normal SuccessfulCreate 14m daemonset-controller Created pod: fluentd-elasticsearch-g6w9g Normal SuccessfulDelete 8m40s daemonset-controller Deleted pod: fluentd-elasticsearch-tftmd Normal SuccessfulCreate 8m37s daemonset-controller Created pod: fluentd-elasticsearch-68q7q Normal SuccessfulDelete 8m8s daemonset-controller Deleted pod: fluentd-elasticsearch-psfkr Normal SuccessfulCreate 8m5s daemonset-controller Created pod: fluentd-elasticsearch-9k47j Normal SuccessfulDelete 7m20s daemonset-controller Deleted pod: fluentd-elasticsearch-r6v22 Normal SuccessfulCreate 7m2s daemonset-controller Created pod: fluentd-elasticsearch-kpjxx Normal SuccessfulDelete 6m26s daemonset-controller Deleted pod: fluentd-elasticsearch-swp4z Normal SuccessfulCreate 6m14s daemonset-controller Created pod: fluentd-elasticsearch-4kr9x Normal SuccessfulDelete 28s daemonset-controller Deleted pod: fluentd-elasticsearch-kpjxx Normal SuccessfulCreate 26s daemonset-controller Created pod: fluentd-elasticsearch-ct4jk Normal SuccessfulDelete 24s daemonset-controller Deleted pod: fluentd-elasticsearch-4kr9x Normal SuccessfulCreate 21s daemonset-controller Created pod: fluentd-elasticsearch-xddqv Normal SuccessfulDelete 19s daemonset-controller Deleted pod: fluentd-elasticsearch-g6w9g Normal SuccessfulCreate 17s daemonset-controller Created pod: fluentd-elasticsearch-cz8q5 Normal SuccessfulDelete 15s daemonset-controller Deleted pod: fluentd-elasticsearch-9k47j Normal SuccessfulCreate 12s daemonset-controller Created pod: fluentd-elasticsearch-hqqh9 Normal SuccessfulDelete 11s daemonset-controller (combined from similar events): Deleted pod: fluentd-elasticsearch-68q7q Normal SuccessfulCreate 9s daemonset-controller (combined from similar events): Created pod: fluentd-elasticsearch-wjrdb
最后更新于
这有帮助吗?