DaemonSet

2022/7/9 23:24:09

本文主要是介绍DaemonSet,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

DaemonSet

DaemonSet 确保全部(或者一些)Node 上运行一个 Pod 的副本。当有 Node 加入集群时,也会为他们新增一个 Pod 。当有 Node 从集群移除时,这些 Pod 也会被回收。删除 DaemonSet 将会删除它创建的所有 Pod

使用 DaemonSet 的一些典型用法:

  • 运行集群存储 daemon,例如在每个 Node 上运行 glusterd 、 ceph

  • 在每个 Node 上运行日志收集 daemon,例如 fluentd 、 logstash

  • 在每个 Node 上运行监控 daemon,例如 Prometheus Node Exporter、 collectd 、Datadog 代理、New Relic 代理,或 Ganglia gmond

 

 

 

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: deamonset-example
  labels:
    app: daemonset
spec:
  selector:
    matchLabels:
      name: deamonset-example
  template:
    metadata:
      labels:
        name: deamonset-example
    spec:
      containers:
      - name: daemonset-example
        image: nginx

 

 

[root@k8s-master01 ~]# kubectl create -f daemonset.yaml

daemonset.apps/deamonset-example created

[root@k8s-master01 ~]# kubectl get pod -o wide
NAME                               READY   STATUS    RESTARTS   AGE   IP            NODE         NOMINATED NODE   READINESS GATES
deamonset-example-bj2lk            1/1     Running   0          48s   10.244.1.40   k8s-node01   <none>           <none>
deamonset-example-h7g25            1/1     Running   0          45s   10.244.2.40   k8s-node02   <none>           <none>
[root@k8s-master01 ~]#

 当我们把node01上面的pod删除,它也会继续新建出来一个,只需要满足一个node上面副本数为1!

 



这篇关于DaemonSet的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程