DaemonSet

DaemonSet是用来在所有集群节点运行特定的一个Pods,比较典型的场景有三个

  • 监控Agent
  • 日志收集器,filebeat,fluentd,logstash
  • 集群存储服务,glusterd, ceph

第一个DaemonSet资源清单

这里的配置清单没有实际的意义,仅用了学习测试

daemon-demo.yaml

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: redis-daemon
  namespace: default
  labels:
    app: redis
spec:
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      name: redis-container
      labels:
        app: redis
    spec:
      containers:
      - name: redis-container
        image: ikubernetes/myapp:v1
        ports:
        - name: redis-port
          containerPort: 6379
          protocol: TCP

创建并查看DaemonSet情况

# kubectl apply -f daemon-demo.yaml 
daemonset.apps/redis-daemon created
# kubectl get ds
NAME           DESIRED   CURRENT   READY     UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
redis-daemon   2         2         2         2            2           <none>          7m
# kubectl describe ds redis-daemon
Name:           redis-daemon
Selector:       app=redis
Node-Selector:  <none>
Labels:         app=redis
Annotations:    kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"apps/v1","kind":"DaemonSet","metadata":{"annotations":{},"labels":{"app":"redis"},"name":"redis-daemon","namespace":"default"},"spec":{"...
Desired Number of Nodes Scheduled: 2
Current Number of Nodes Scheduled: 2
Number of Nodes Scheduled with Up-to-date Pods: 2
Number of Nodes Scheduled with Available Pods: 2
Number of Nodes Misscheduled: 0
Pods Status:  2 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=redis
  Containers:
   redis-container:
    Image:        ikubernetes/myapp:v1
    Port:         6379/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                  Message
  ----    ------            ----  ----                  -------
  Normal  SuccessfulCreate  8m    daemonset-controller  Created pod: redis-daemon-bl5qv
  Normal  SuccessfulCreate  8m    daemonset-controller  Created pod: redis-daemon-gb2mv

results matching ""

    No results matching ""