目录
DaemonSet功能:
• 在每一个Node上运行一个Pod
• 新加入的Node也同样会自动运行一个Pod
应用场景:网络插件(kube-proxy、calico)、其他Agent
deplayment示例:
yaml示例
apiVersion: apps/v1kind: DaemonSetmetadata:labels:app: filebeatname: filebeatspec:selector:matchLabels:app: filebeattemplate:metadata:labels:app: filebeatspec:containers:- image: elastic/filebeat:7.3.2name: filebeatresources: {}
执行
kubectl apply -f daemonset.yaml
查看
kubectl get pods -o wide
可以看到node1和node2各一个,master节点没有是因为master有污点
假如需要在有污点的节点也运行。需要在yaml中添加污点容忍
示例,标红位置为污点容忍
apiVersion: apps/v1kind: DaemonSetmetadata:labels:app: filebeatname: filebeatspec:selector:matchLabels:app: filebeattemplate:metadata:labels:app: filebeatspec:tolerations:# Make sure calico-node gets scheduled on all nodes.- effect: NoScheduleoperator: Existscontainers:- image: elastic/filebeat:7.3.2name: filebeatresources: {}
kubectl get pods -o wide
master节点也有了容器运行