Daemonset 控制器

DaemonSet 控制器:概念、原理解读
DaemonSet 控制器能够确保 k8s 集群所有的节点都运行一个相同的 pod 副本,当向k8s 集群中增加 node 节点时,这个 node 节点也会自动创建一个 pod 副本,当 node 节点从集群移除,这些 pod 也会自动删除;删除 Daemonset 也会删除它们创建的 pod
编写DaemonSet 控制器清单文件
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-elasticsearch
  labels:
    k8s-app: fluentd-logging
spec:
  selector:
    matchLabels:
      name: fluentd-elasticsearch
  template:
    metadata:
      labels:
        name: fluentd-elasticsearch
    spec:
      tolerations:
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: fluentd-elasticsearch
        image: lixiaofan0122/fluentd:v2.5.1
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true

      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath: 
          path: /var/lib/docker/containers
[root@master-1 pods]# kubectl apply -f daemonset-1.yaml 
daemonset.apps/fluentd-elasticsearch created

  

posted @ 2023-01-18 16:40  烟雨楼台,行云流水  阅读(30)  评论(0编辑  收藏  举报