Kubernetes DaemonSet(部署守護進程)

Kubernetes DaemonSet(部署守護進程)

• 在每個Node上運行一個Pod
• 新加入的Node也一樣會自動運行一個Podnginx

應用場景:Agentapi

官方文檔:https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/bash

案例

一、建立yaml文件app

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ds-test
  labels:
    app: filebeat
spec:
  # 標籤選擇器
  selector:
    matchLabels:
      app: filebeat
  # 標籤類型
  template:
    metadata:
      labels:
        app: filebeat
    spec:
      # 配置容器
      containers:
      - name: logs
      containers:
      - image: nginx
        ports:
        - containerPort: 80
        # 掛載目錄
        volumeMounts:
        - name: varlog
          mountPath: /tmp/log
      volumes:
      - name: varlog
        hostPath:
          path: /var/log

二、建立容器測試

kubectl apply -f ds.yaml

三、查看pod
kubectl get podsspa

NAME READY STATUS RESTARTS AGE
ds-test-8487j 1/1 Running 0 8s
ds-test-lkflr 1/1 Running 0 8s

四、進入容器測試掛在
kubectl exec -it ds-test-8487j bashdebug

root@ds-test-8487j:/# ls /tmp/log/
anaconda    cron-20190825 secure
audit    dmesg    secure-20190825
boot.log    dmesg.old    spooler
boot.log-20190822 firewalld    spooler-20190825
boot.log-20190823 grubby_prune_debug tallylog
boot.log-20190824 lastlog    tuned
boot.log-20190825 maillog    vmware-vgauthsvc.log.0
boot.log-20190827 maillog-20190825 vmware-vmsvc.log
btmp    messages    wtmp
chrony    messages-20190825 yum.log
containers    pods
cron    rhsm
相關文章
相關標籤/搜索