码迷,mamicode.com
首页 > 其他好文 > 详细

k8s 日志的收集

时间:2020-07-03 15:49:45      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:挂载   nbsp   test   seconds   spec   容器   period   default   nat   

filebeat的ConfigMap的文件

[root@laso yaml]# cat configmap.yaml 
apiVersion: v1
kind: ConfigMap
metadata:
  name: filebeat-config
data:
  filebeat.yml: |
    filebeat.prospectors:
    - input_type: log
      paths:
        - "/log/*"
      fields:
        type: "filebeta"
    output.logstash:
      hosts: ["192.168.199.224:5044"]

java项目的pod

[root@laso yaml]# cat deployment_consumer.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: consumer
  namespace: default
spec:
  replicas: 1
  selector:  
    matchLabels:
      app: consumer
      release: beta
  template: 
    metadata:
      labels:
        app: consumer
        release: beta
    spec:
      #nodeSelector:
      #  env: beta
      terminationGracePeriodSeconds: 40
      containers: # pod
      - name: filebeta
        image: registry.cn-beijing.aliyuncs.com/cn_genebox/filebeat:v7
        volumeMounts:
        - name: app-logs
          mountPath: /log
        - name: filebeat-config
          mountPath: /etc/filebeat/
      - name: consumer
        image: registry.cn-beijing.aliyuncs.com/cn_genebox/consumer:v1.0.4
        imagePullPolicy: Always
        ports: 
        - name: port
          containerPort: 8022
        readinessProbe:
          httpGet:
            port: port  #也可以使用80
            path: /smoketest
          initialDelaySeconds: 3 #容器启动后等待1秒开始探测
          periodSeconds: 2 #每隔3秒探测一次       
        livenessProbe:
          httpGet:
            port: port  #也可以使用80
            path: /smoketest
          initialDelaySeconds: 10 #容器启动后等待10秒开始探测
          periodSeconds: 2 #每隔3秒探测一次
        volumeMounts:
         - name: app-logs
           mountPath: /tmp/laso/logs/consumer
      # 拉取容器的账户密码
      imagePullSecrets:
      - name: registry-secret
      # 挂载卷
      volumes:
      - name: app-logs
        hostPath:
         path: /log/consumer   # node主机的/log/consumer挂载在 pod的/tmp/laso/logs/consumer上
         type: DirectoryOrCreate # 目录不存在创建
      # -  name: app-logs
      #   nfs:
      #     path: /home/nfs
      #     server: 192.168.199.226
       #   #type: DirectoryOrCreate
      - name: filebeat-config
        configMap:
          name: filebeat-config

 

k8s 日志的收集

标签:挂载   nbsp   test   seconds   spec   容器   period   default   nat   

原文地址:https://www.cnblogs.com/lulin9501/p/13230301.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!