Kubernetes-DaemonSet

1 介绍

  DaemonSet确保创建足够的pod,并在自己的节点上部署每个pod,确保一个pod匹配它的选择器并在每个节点上运行。要在所有集群节点上运行一个pod,就需要创建这样一个DaemonSet对象。
  若节点下线,DaemonSet不会在其他地方重建pod;若一个新节点添加到集群中,DaemonSet会立刻部署一个新的pod实例;若无意中删除一个pod,则会从配置的pod模板创建一个新的pod。

2 DS使用

2.1 使用DaemonSet在特定的节点上运行pod

  DaemonSet将pod部署到集群中的所有节点上,除非指定这些pod只在部分节点上运行。通过pod模板中的nodeSelector属性指定。

2.2 创建DS

写好yaml文件:

  • 版本号:apiVersion为apps/v1beta2
  • DS定义:kind配置为DaemonSet;
  • DS名字:metadata.name
  • pod选择器:spec.selector中可以使用matchLabels选择器
  • pod模板:spec.template,其中模板中可以包含一个节点选择器,spec.nodeSelector
    DS的yaml文件范例

by k8s in action

创建DS命令
$ kubectl create -f xxx.yaml

给节点打标签
$ kubectl label node node_name tag_key=tag_value

2.3 查看DS

查看DS
$ kubectl get ds

发布了82 篇原创文章 · 获赞 112 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/Andya_net/article/details/104715307