# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Default values for fluentbit
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

---
release_group: null

labels:
  fluentbit:
    node_selector_key: openstack-control-plane
    node_selector_value: enabled

images:
  tags:
    fluentbit: docker.io/fluent/fluent-bit:0.14.2
    dep_check: quay.io/airshipit/kubernetes-entrypoint:latest-ubuntu_focal
    image_repo_sync: docker.io/library/docker:17.07.0
  pull_policy: IfNotPresent
  local_registry:
    active: false
    exclude:
      - dep_check
      - image_repo_sync

dependencies:
  dynamic:
    common:
      local_image_registry:
        jobs:
          - fluentbit-image-repo-sync
        services:
          - endpoint: node
            service: local_image_registry
  static:
    image_repo_sync:
      services:
        - endpoint: internal
          service: local_image_registry

conf:
  fluentbit:
    template: |
      [SERVICE]
          Daemon false
          Flush 30
          Log_Level info
          Parsers_File parsers.conf

      [INPUT]
          Buffer_Chunk_Size 1M
          Buffer_Max_Size 1M
          Mem_Buf_Limit 5MB
          Name tail
          Path /var/log/kern.log
          Tag kernel

      [INPUT]
          Buffer_Chunk_Size 1M
          Buffer_Max_Size 1M
          Mem_Buf_Limit 5MB
          Name tail
          Parser docker
          Path /var/log/containers/*.log
          Tag kube.*

      [INPUT]
          Buffer_Chunk_Size 1M
          Buffer_Max_Size 1M
          Mem_Buf_Limit 5MB
          Name tail
          Path /var/log/libvirt/libvirtd.log
          Tag libvirt

      [INPUT]
          Buffer_Chunk_Size 1M
          Buffer_Max_Size 1M
          Mem_Buf_Limit 5MB
          Name tail
          Path /var/log/libvirt/qemu/*.log
          Tag qemu

      [INPUT]
          Buffer_Chunk_Size 1M
          Buffer_Max_Size 1M
          Mem_Buf_Limit 5MB
          Name systemd
          Path ${JOURNAL_PATH}
          Systemd_Filter _SYSTEMD_UNIT=kubelet.service
          Tag journal.*

      [INPUT]
          Buffer_Chunk_Size 1M
          Buffer_Max_Size 1M
          Mem_Buf_Limit 5MB
          Name systemd
          Path ${JOURNAL_PATH}
          Systemd_Filter _SYSTEMD_UNIT=docker.service
          Tag journal.*

      [FILTER]
          Interval 1s
          Match **
          Name throttle
          Rate 1000
          Window 300

      [FILTER]
          Match libvirt
          Name record_modifier
          Record hostname ${HOSTNAME}

      [FILTER]
          Match qemu
          Name record_modifier
          Record hostname ${HOSTNAME}

      [FILTER]
          Match kernel
          Name record_modifier
          Record hostname ${HOSTNAME}

      [FILTER]
          Match journal.**
          Name modify
          Rename _BOOT_ID BOOT_ID
          Rename _CAP_EFFECTIVE CAP_EFFECTIVE
          Rename _CMDLINE CMDLINE
          Rename _COMM COMM
          Rename _EXE EXE
          Rename _GID GID
          Rename _HOSTNAME HOSTNAME
          Rename _MACHINE_ID MACHINE_ID
          Rename _PID PID
          Rename _SYSTEMD_CGROUP SYSTEMD_CGROUP
          Rename _SYSTEMD_SLICE SYSTEMD_SLICE
          Rename _SYSTEMD_UNIT SYSTEMD_UNIT
          Rename _TRANSPORT TRANSPORT
          Rename _UID UID

      [OUTPUT]
          Match **.fluentd**
          Name null

      [FILTER]
          Match kube.*
          Merge_JSON_Log true
          Name kubernetes

      [OUTPUT]
          Host ${FLUENTD_HOST}
          Match *
          Name forward
          Port ${FLUENTD_PORT}
  parsers:
    template: |
      [PARSER]
        Decode_Field_As escaped_utf8 log
        Format json
        Name docker
        Time_Format %Y-%m-%dT%H:%M:%S.%L
        Time_Keep true
        Time_Key time

secrets:
  oci_image_registry:
    fluentbit: fluentbit-oci-image-registry-key

endpoints:
  cluster_domain_suffix: cluster.local
  local_image_registry:
    name: docker-registry
    namespace: docker-registry
    hosts:
      default: localhost
      internal: docker-registry
      node: localhost
    host_fqdn_override:
      default: null
    port:
      registry:
        node: 5000
  oci_image_registry:
    name: oci-image-registry
    namespace: oci-image-registry
    auth:
      enabled: false
      fluentbit:
        username: fluentbit
        password: password
    hosts:
      default: localhost
    host_fqdn_override:
      default: null
    port:
      registry:
        default: null
  fluentd:
    namespace: null
    name: fluentd
    hosts:
      default: fluentd-logging
    host_fqdn_override:
      default: null
    path:
      default: null
    scheme:
      default: http
    port:
      service:
        default: 24224
      metrics:
        default: 24220

pod:
  security_context:
    fluentbit:
      pod:
        runAsUser: 65534
      container:
        fluentbit:
          runAsUser: 0
          readOnlyRootFilesystem: false
  affinity:
    anti:
      type:
        default: preferredDuringSchedulingIgnoredDuringExecution
      topologyKey:
        default: kubernetes.io/hostname
  dns_policy: "ClusterFirstWithHostNet"
  lifecycle:
    upgrades:
      daemonsets:
        pod_replacement_strategy: RollingUpdate
        fluentbit:
          enabled: true
          min_ready_seconds: 0
          max_unavailable: 1
  resources:
    enabled: false
    fluentbit:
      limits:
        memory: '400Mi'
        cpu: '400m'
      requests:
        memory: '100Mi'
        cpu: '100m'
  tolerations:
    fluentbit:
      enabled: false
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
      - key: node-role.kubernetes.io/control-plane
        operator: Exists
      - key: node-role.kubernetes.io/node
        operator: Exists
  mounts:
    fluentbit:
      fluentbit:

manifests:
  configmap_bin: true
  configmap_etc: true
  daemonset_fluentbit: true
  job_image_repo_sync: true
  secret_registry: true
...
