--- apiVersion: apps/v1 kind: StatefulSet metadata: name: realtime-yuewen namespace: pro labels: app: realtime-yuewen spec: serviceName: realtime-yuewen replicas: 2 selector: matchLabels: app: realtime-yuewen template: metadata: labels: app: realtime-yuewen spec: terminationGracePeriodSeconds: 180 dnsPolicy: ClusterFirstWithHostNet dnsConfig: nameservers: - 223.5.5.5 - 10.26.22.50 initContainers: - name: init image: hub.evbj.easou.com/dev/busybox command: [ "chmod","777","-R","/data" ] imagePullPolicy: IfNotPresent volumeMounts: - name: volume mountPath: /data #nodeSelector: # app.touchrs: touchrs # affinity: # podAntiAffinity: # preferredDuringSchedulingIgnoredDuringExecution: # - weight: 100 # podAffinityTerm: # labelSelector: # matchExpressions: # - key: app # operator: In # values: # - realtime-yuewen # topologyKey: kubernetes.io/hostname containers: - name: realtime-yuewen image: hub.evbj.easou.com/pro/realtime-yuewen:r181367 imagePullPolicy: IfNotPresent env: - name: MY_NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName - name: MY_POD_IP valueFrom: fieldRef: fieldPath: status.podIP - name: MY_POD_NAME valueFrom: fieldRef: fieldPath: metadata.name - name: MY_POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: JAVA_OPTS value: "-server -Xmx2g -Xms2g -Xss512k -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=product" ports: - containerPort: 8080 name: port - containerPort: 8001 name: "jvm-debug" volumeMounts: - name: volume mountPath: /data lifecycle: preStop: exec: command: ["/bin/sh","-c","curl -H 'loginName:admin' -H 'password:ea1so2ua3dm4in5' -X POST 127.0.0.1:8080/actuator/shutdown"] livenessProbe: httpGet: path: /actuator/health port: 8080 httpHeaders: - name: loginName value: admin - name: password value: ea1so2ua3dm4in5 initialDelaySeconds: 40 #60s后启动第一次探测 periodSeconds: 15 # 每隔10s启动一次探测 timeoutSeconds: 3 # 超时时间3s successThreshold: 1 # 成功1次即表示容器健康 failureThreshold: 5 # 连续5次失败,则判定容器不健康,默认3次 readinessProbe: tcpSocket: port: 8080 initialDelaySeconds: 40 periodSeconds: 15 - image: hub.evbj.easou.com/pro/fluent-bit imagePullPolicy: IfNotPresent name: fluent-bit ports: - containerPort: 2020 name: metrics protocol: TCP terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - name: volume #日志同时挂载在nginx和filebeat中 mountPath: /data - name: fluent-bit-config mountPath: /opt/bitnami/fluent-bit/conf/fluent-bit.conf subPath: fluent-bit.conf - name: fluent-bit-config-parses mountPath: /opt/bitnami/fluent-bit/conf/parsers.conf subPath: parsers.conf volumes: - name: fluent-bit-config configMap: name: fluent-bit-config-realtime-yuewen items: - key: fluent-bit.conf path: fluent-bit.conf - name: fluent-bit-config-parses configMap: name: fluent-bit-config-realtime-yuewen items: - key: parsers.conf path: parsers.conf volumeClaimTemplates: - metadata: name: volume spec: accessModes: [ "ReadWriteOnce" ] storageClassName: ceph-block resources: requests: storage: 100Gi --- apiVersion: v1 kind: Service metadata: name: realtime-yuewen-svc namespace: pro labels: app: realtime-yuewen-svc spec: type: NodePort ports: - port: 80 targetPort: 8080 name: "main" selector: app: realtime-yuewen --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: realtime-yuewen-ingress namespace: pro spec: rules: - host: ywrealtime.appeasou.com http: paths: - path: / pathType: Prefix backend: service: name: realtime-yuewen-svc port: number: 8080 - host: pro-realtime-yuewen.ieasou.cn http: paths: - path: / pathType: Prefix backend: service: name: realtime-yuewen-svc port: number: 8080 ingressClassName: nginx --- apiVersion: v1 kind: ConfigMap metadata: name: fluent-bit-config-realtime-yuewen namespace: pro data: fluent-bit.conf: | [SERVICE] Flush 5 Daemon off Log_Level info [INPUT] Name tail Path /data/logs/app/access.log Mem_Buf_Limit 5MB Skip_Long_Lines On [OUTPUT] Name kafka Match * Brokers 10.26.22.124:8092,10.26.22.121:8092,10.26.22.120:8092,10.26.22.102:8092,10.26.22.122:8092 Topics test_realtime_yuewen_nginx Retry_Limit false log_key log # hides errors "Receive failed: Disconnected" when kafka kills idle connections rdkafka.log.connection.close false # producer buffer is not included in http://fluentbit.io/documentation/0.12/configuration/memory_usage.html#estimating rdkafka.queue.buffering.max.kbytes 10240 # for logs you'll probably want this ot be 0 or 1, not more rdkafka.request.required.acks 1 parsers.conf: | [PARSER] Name multiline_pattern Format regex Regex ^\\s*$