• 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
  • 相关阅读:
    mysql设置定时任务
    Spark On Yarn:提交Spark应用程序到Yarn
    Spark On Yarn:提交Spark应用程序到Yarn
    在Yarn上运行spark-shell和spark-sql命令行
    在Yarn上运行spark-shell和spark-sql命令行
    SparkSQL On Yarn with Hive,操作和访问Hive表
    SparkSQL On Yarn with Hive,操作和访问Hive表
    使用hive访问elasticsearch的数据
    使用hive访问elasticsearch的数据
    redis数据类型之list
  • 原文地址:https://www.cnblogs.com/lulin9501/p/13230301.html
Copyright © 2020-2023  润新知