当前位置:   article > 正文

filebeat 7.13.3 收集 k8s 1.18.20集群 windows server 2019 1909节点日志_filebeat7.13 windows

filebeat7.13 windows

构建镜像

下载

1.从官方下载 filebeat-7.13.3-windows-x86_64.zip。
地址:https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.15.2-windows-x86_64.zip
2.解压

Expand-Archive -Path s:/soft/filebeat-7.13.3-windows-x86_64.zip -DestinationPath .
mv filebeat-* filebeat
  • 1
  • 2

Dockerfile

# escape=`
FROM mcr.microsoft.com/windows/servercore:1909
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV ES_HOSTS= `
    LOGSTASH_HOSTS=

COPY filebeat /filebeat

ENTRYPOINT ["powershell", "C:\\filebeat\\filebeat.exe"]
CMD ["-c /filebeat/filebeat.yml", "-e"]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

构建

docker build -t filebeat-w2019:7.13.3 .
  • 1

k8s

filebeat-w2019-7.13.3.yml

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-config-w2019
  namespace: kube-system
  labels:
    k8s-app: filebeat-w2019
data:
  filebeat.yml: |-
    filebeat.inputs:
    - type: container
      enabled: true
      paths:
        - C:\ProgramData\Docker\containers\**\*.log
      processors:
        - add_kubernetes_metadata:
            host: ${NODE_NAME}
            matchers:
            - logs_path:
                logs_path: "C:\\ProgramData\\Docker\\containers"
    - type: log
      enabled: true
      paths:
        - /var/log/kubelet/kubelet.exe.ERROR
        - /var/log/kubelet/kubelet.exe.INFO
        - /var/log/kubelet/kubelet.exe.WARNING

    # To enable hints based autodiscover, remove `filebeat.inputs` configuration and uncomment this:
    #filebeat.autodiscover:
    #  providers:
    #    - type: kubernetes
    #      node: ${NODE_NAME}
    #      hints.enabled: true
    #      hints.default_config:
    #        type: container
    #        paths:
    #          - /var/log/containers/*${data.kubernetes.container.id}.log

    processors:
      - add_host_metadata:

    output.elasticsearch:
      hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
      username: ${ELASTICSEARCH_USERNAME}
      password: ${ELASTICSEARCH_PASSWORD}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: filebeat-w2019
  namespace: kube-system
  labels:
    k8s-app: filebeat-w2019
spec:
  selector:
    matchLabels:
      k8s-app: filebeat-w2019
  template:
    metadata:
      labels:
        k8s-app: filebeat-w2019
    spec:
      serviceAccountName: filebeat-w2019
      terminationGracePeriodSeconds: 30
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
      - name: filebeat-w2019
        image: filebeat-w2019:7.13.3
        args: [
          "--environment=windows_service",
          "--path.data", "$env:PROGRAMDATA/filebeat/data",
          "-c", "/etc/filebeat.yml",
          "-e"
        ]
        env:
        - name: ELASTICSEARCH_HOST
          value: 192.168.3.150
        - name: ELASTICSEARCH_PORT
          value: "9200"
        - name: ELASTICSEARCH_USERNAME
          value: elastic
        - name: ELASTICSEARCH_PASSWORD
          value: changeme
        - name: ELASTIC_CLOUD_ID
          value:
        - name: ELASTIC_CLOUD_AUTH
          value:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        securityContext:
          # runAsUser: 0
          # If using Red Hat OpenShift uncomment this:
          privileged: true
        resources:
          limits:
            memory: 500Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: config
          mountPath: /etc
          readOnly: true
        - name: data
          mountPath: /programdata/filebeat
        - name: varlibdockercontainers
          mountPath: /programdata/docker/containers
          readOnly: true
        - name: varlog
          mountPath: /var/log
          readOnly: true
      nodeSelector:
        kubernetes.io/os: windows
      volumes:
      - name: config
        configMap:
          defaultMode: 0640
          name: filebeat-config-w2019
      # data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
      - name: data
        hostPath:
          # When filebeat runs as non-root user, this directory needs to be writable by group (g+w).
          path: /programdata/filebeat
          type: DirectoryOrCreate
      - name: varlibdockercontainers
        hostPath:
          path: /programdata/docker/containers
      - name: varlog
        hostPath:
          path: /var/log
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: filebeat-w2019
subjects:
- kind: ServiceAccount
  name: filebeat-w2019
  namespace: kube-system
roleRef:
  kind: ClusterRole
  name: filebeat-w2019
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: filebeat-w2019
  labels:
    k8s-app: filebeat-w2019
rules:
- apiGroups: [""] # "" indicates the core API group
  resources:
  - namespaces
  - pods
  - nodes
  verbs:
  - get
  - watch
  - list
- apiGroups: ["apps"]
  resources:
    - replicasets
  verbs: ["get", "list", "watch"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: filebeat-w2019
  namespace: kube-system
  labels:
    k8s-app: filebeat-w2019
---
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177

filebeat-w2019-7.13.3.yml.2 docker数据存储在d:/docker-root

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-config-w2019
  namespace: kube-system
  labels:
    k8s-app: filebeat-w2019
data:
  filebeat.yml: |-
    filebeat.inputs:
    - type: container
      enabled: true
      paths:
        - C:\ProgramData\Docker\containers\**\*.log
      processors:
        - add_kubernetes_metadata:
            host: ${NODE_NAME}
            matchers:
            - logs_path:
                logs_path: "C:\\ProgramData\\Docker\\containers"
    - type: log
      enabled: true
      paths:
        - /var/log/kubelet/kubelet.exe.ERROR
        - /var/log/kubelet/kubelet.exe.INFO
        - /var/log/kubelet/kubelet.exe.WARNING

    # To enable hints based autodiscover, remove `filebeat.inputs` configuration and uncomment this:
    #filebeat.autodiscover:
    #  providers:
    #    - type: kubernetes
    #      node: ${NODE_NAME}
    #      hints.enabled: true
    #      hints.default_config:
    #        type: container
    #        paths:
    #          - /var/log/containers/*${data.kubernetes.container.id}.log

    processors:
      - add_host_metadata:

    output.elasticsearch:
      hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
      username: ${ELASTICSEARCH_USERNAME}
      password: ${ELASTICSEARCH_PASSWORD}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: filebeat-w2019
  namespace: kube-system
  labels:
    k8s-app: filebeat-w2019
spec:
  selector:
    matchLabels:
      k8s-app: filebeat-w2019
  template:
    metadata:
      labels:
        k8s-app: filebeat-w2019
    spec:
      serviceAccountName: filebeat-w2019
      terminationGracePeriodSeconds: 30
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      containers:
      - name: filebeat-w2019
        image: filebeat-w2019:7.13.3
        args: [
          "--environment=windows_service",
          "--path.data", "$env:PROGRAMDATA/filebeat/data",
          "-c", "/etc/filebeat.yml",
          "-e"
        ]
        env:
        - name: ELASTICSEARCH_HOST
          value: 192.168.3.150
        - name: ELASTICSEARCH_PORT
          value: "9200"
        - name: ELASTICSEARCH_USERNAME
          value: elastic
        - name: ELASTICSEARCH_PASSWORD
          value: changeme
        - name: ELASTIC_CLOUD_ID
          value:
        - name: ELASTIC_CLOUD_AUTH
          value:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        securityContext:
          # runAsUser: 0
          # If using Red Hat OpenShift uncomment this:
          privileged: true
        resources:
          limits:
            memory: 500Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: config
          mountPath: /etc
          readOnly: true
        - name: data
          mountPath: /programdata/filebeat
        - name: varlibdockercontainers
          mountPath: /programdata/docker/containers
          readOnly: true
        - name: varlog
          mountPath: /var/log
          readOnly: true
      nodeSelector:
        kubernetes.io/os: windows
      volumes:
      - name: config
        configMap:
          defaultMode: 0640
          name: filebeat-config-w2019
      # data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
      - name: data
        hostPath:
          # When filebeat runs as non-root user, this directory needs to be writable by group (g+w).
          path: /programdata/filebeat
          type: DirectoryOrCreate
      - name: varlibdockercontainers
        hostPath:
          path: d:/docker-root/containers
      - name: varlog
        hostPath:
          path: /var/log
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: filebeat-w2019
subjects:
- kind: ServiceAccount
  name: filebeat-w2019
  namespace: kube-system
roleRef:
  kind: ClusterRole
  name: filebeat-w2019
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: filebeat-w2019
  labels:
    k8s-app: filebeat-w2019
rules:
- apiGroups: [""] # "" indicates the core API group
  resources:
  - namespaces
  - pods
  - nodes
  verbs:
  - get
  - watch
  - list
- apiGroups: ["apps"]
  resources:
    - replicasets
  verbs: ["get", "list", "watch"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: filebeat-w2019
  namespace: kube-system
  labels:
    k8s-app: filebeat-w2019
---
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/706244
推荐阅读
相关标签
  

闽ICP备14008679号