---
apiVersion: v1
data:
  fluent-bit.conf: |-
    [SERVICE]
        http_server On
        http_port   2020
        log_level   debug

    [INPUT]
        name    forward
        port    24224

    [OUTPUT]
        name    stdout
        match   *
        format  json_lines

    [OUTPUT]
        name    loki
        match   *
        host    loki-http
        labels  namespace=$namespace, podIP=$podip, nodeName=$nodename, application=$component, podName=$podname, labels_run=$labels_run, labels_app=$labels_app, container=$container
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: test-fluentbit-config
  labels:
    run: fluentbit
    app: demo-logging
---
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: fluentbit
    app: demo-logging
  name: test-fluentbit
spec:
  containers:
  # append "-debug" to image name to run in debug mode, in case you run into CrashLoopBackOff errors.
  - image: ghcr.io/fluent/fluent-bit:latest
    name: test-fluentbit
    resources: {}
    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        drop:
        - ALL
      runAsNonRoot: true
      seccompProfile:
        type: RuntimeDefault
    volumeMounts:
      - name: test-fluentbit-config
        mountPath: "/fluent-bit/etc/fluent-bit.conf"
        subPath: "fluent-bit.conf"
    ports:
      - name: fb-http-server
        containerPort: 2020
      - name: fb-fw-input
        containerPort: 24224
  dnsPolicy: ClusterFirst
  restartPolicy: Always
  volumes:
    - name: test-fluentbit-config
      configMap:
        name: test-fluentbit-config
---
apiVersion: v1
kind: Service
metadata:
  name: fluent-bit-forward-input
  labels:
    run: fluentbit
    app: demo-logging
spec:
  ports:
    - name: fb-fw-input
      port: 24224
      protocol: TCP
      targetPort: 24224
  selector:
    run: fluentbit
    app: demo-logging