k8s Daemonset功能
1. k8s-Daemonset功能
-
DaemonSet功能:
- 在每一个Node上运行一个Pod
- 新加入的Node也同样会自动运行一个Pod
-
应用场景:网络插件(kube-proxy、calico)、其他Agent
-
示图:
-
示例代码:
[root@k8s-master deployment]# vim daemonset.yaml [root@k8s-master deployment]# cat daemonset.yaml apiVersion: apps/v1 kind: DaemonSet metadata: name: filebeat namespace: kube-system spec: selector: matchLabels: name: filebeat template: metadata: labels: name: filebeat spec: containers: - name: log image: elastic/filebeat:7.3.2
2. 案例
-
编写配置
[root@k8s-master deployment]# vim daemonset.yaml [root@k8s-master deployment]# cat daemonset.yaml apiVersion: apps/v1 kind: DaemonSet metadata: name: filebeat namespace: kube-system spec: selector: matchLabels: name: filebeat template: metadata: labels: name: filebeat spec: containers: - name: log image: elastic/filebeat:7.3.2
-
执行案例
[root@k8s-master deployment]# kubectl apply -f daemonset.yaml daemonset.apps/filebeat created
-
查询服务
[root@k8s-master deployment]# kubectl get pods -n kube-system NAME READY STATUS RESTARTS AGE calico-kube-controllers-5dc87d545c-nscfb 1/1 Running 3 6d20h calico-node-j6rhw 1/1 Running 3 6d20h calico-node-n7d6s 1/1 Running 3 6d20h calico-node-x86s2 1/1 Running 3 6d20h coredns-6d56c8448f-hkgnk 1/1 Running 4 6d23h coredns-6d56c8448f-jfbjs 1/1 Running 3 6d23h etcd-k8s-master 1/1 Running 4 6d23h filebeat-7cz4r 1/1 Running 0 3m25s filebeat-tdsm9 1/1 Running 0 3m25s kube-apiserver-k8s-master 1/1 Running 9 6d23h kube-controller-manager-k8s-master 1/1 Running 9 6d23h kube-proxy-fhgbd 1/1 Running 3 6d22h kube-proxy-l7q4r 1/1 Running 3 6d23h kube-proxy-qwpjp 1/1 Running 3 6d22h kube-scheduler-k8s-master 1/1 Running 10 6d23h