log-pilot在k8s中运行报/var/run/docker

2023-08-29  本文已影响0人  sexy_cyber

背景


解决方案


docker run -d \
   --name log-pilot-filebeat \
   -v /run/k3s/containerd/containerd.sock:/var/run/containerd/containerd.sock \
   -v /etc/localtime:/etc/localtime \
   -v /:/host:ro \
   --cap-add SYS_ADMIN \
   -e PILOT_LOG_PREFIX=glinux \
   -e LOGGING_OUTPUT=logstash \
   -e LOGSTASH_HOST=logstash.glinux.top \
   -e LOGSTASH_PORT=5063 \
   --restart=always \
   williamguozi/log-pilot-filebeat:containerd
docker pull williamguozi/log-pilot-filebeat:containerd
mkdir filebeat-modification
cd filebeat-modification
touch Dockerfile
vim Dockerfile
FROM williamguozi/log-pilot-filebeat:containerd

# 将修改后的 filebeat.tpl 文件复制到镜像中
COPY filebeat.tpl /pilot/filebeat.tpl
COPY filebeat.tpl /pilot/assets/filebeat/filebeat.tpl
  {{if .Stdout}}
  docker-json: true
  {{end}}
docker build -t uhub.service.ucloud.cn/drakespider/spider:logpilotc -f Dockerfile .
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: log-pilot-filebeat
spec:
  selector:
    matchLabels:
      app: log-pilot-filebeat
  template:
    metadata:
      labels:
        app: log-pilot-filebeat
    spec:
      imagePullSecrets:
        - name: ucloud-aliyun
      containers:
        - name: log-pilot-filebeat
          image: uhub.service.ucloud.cn/drakespider/spider:logpilotc
          volumeMounts:
            - name: containerd-sock
              mountPath: /var/run/containerd/containerd.sock
            - name: localtime
              mountPath: /etc/localtime
            - name: rootfs
              mountPath: /host
              readOnly: true
          securityContext:
            capabilities:
              add:
                - SYS_ADMIN
          env:
            - name: PILOT_LOG_PREFIX
              value: "bitget"
            - name: LOGGING_OUTPUT
              value: "elasticsearch"
            - name: ELASTICSEARCH_HOSTS
              value: "http://elasticsearch:9200"
            - name: ELASTICSEARCH_USER
              value: "elastic"
            - name: ELASTICSEARCH_PASSWORD
              value: "xxxx"
      volumes:
        - name: containerd-sock
          hostPath:
            path: /run/containerd/containerd.sock
        - name: localtime
          hostPath:
            path: /etc/localtime
        - name: rootfs
          hostPath:
            path: /
          readOnly: true
上一篇下一篇

猜你喜欢

热点阅读