zoukankan      html  css  js  c++  java
  • k8s 日志的收集

    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
  • 相关阅读:
    网络IO之阻塞、非阻塞、同步、异步总结
    C语言栈与调用惯例
    多个文件目录下Makefile的写法
    利用 mount 指令解决 Read-only file system的问题
    error while loading shared libraries: xxx.so.x" 错误的原因和解决办法
    Centos6.4下安装protobuf及简单使用
    Centos下修改启动项和网络配置
    Centos下配置单元测试工具gtest
    Centos配置为驱动程序开发环境
    Centos安装gcc及g++
  • 原文地址:https://www.cnblogs.com/lulin9501/p/13230301.html
Copyright © 2011-2022 走看看