Refer to these instructions to install Fluent Bit on a TKG cluster provisioned with TKr for vSphere 7.x.

Prerequisites

See Workflow for Installing Standard Packages on TKr for vSphere 7.x.

Install Fluent Bit

Install Fluent Bit for log forwarding.
  1. List the available Fluent Bit versions in the repository.
    kubectl -n tkg-system get packages | grep fluent-bit
  2. Create the namespace.
    kubectl create ns tanzu-system-logging
  3. Label the namespace for PSA.
    kubectl label ns fluentbit-logging pod-security.kubernetes.io/enforce=privileged
    Or, alternatively:
    apiVersion: v1
    kind: Namespace
    metadata:  
      name: fluentbit-logging
    ---
    apiVersion: v1
    kind: Namespace
    metadata:  
      name: fluentbit-logging
      labels: pod-security.kubernetes.io/enforce: privileged
  4. Prepare fluentbit.yaml.

    See

  5. Customize fluentbit-data-values as needed for your environment.

    See Fluent Bit Package Reference for configuration parameters.

  6. Install Fluent Bit.
    kubectl apply -f fluentbit.yaml
  7. Verify Fluent Bit installation.
    kubectl get all -n fluentbit-logging

fluentbit.yaml

The following example can be used for a Syslog endpoint. Update the package version as needed.
apiVersion: v1
kind: ServiceAccount
metadata:
  name: fluentbit-sa
  namespace: tkg-system
  annotations:
    pod-security.kubernetes.io/enforce: "privileged"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: fluentbit-role-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
  - kind: ServiceAccount
    name: fluentbit-sa
    namespace: tkg-system
---
apiVersion: packaging.carvel.dev/v1alpha1
kind: PackageInstall
metadata:
  name: fluentbit
  namespace: tkg-system
spec:
  serviceAccountName: fluentbit-sa
  packageRef:
    refName: fluent-bit.tanzu.vmware.com
    versionSelection:
      constraints: 2.1.6+vmware.1-tkg.2 #PKG_VERSION
  values:
  - secretRef:
      name: fluentbit-data-values
---
apiVersion: v1
kind: Secret
metadata:
  name: fluentbit-data-values
  namespace: tkg-system
stringData:
  values.yml: |
    ---
    namespace: tanzu-system-logging
    tkg:
      instance_name: "guest-cluster"     #TKG_INSTANCE_NAME
      cluster_name: "tkgs-vc-wl"         #TKG_CLUSTER_NAME
    fluentbit:
      output_plugin: "syslog"
      syslog:
        host: "10.202.27.235"           #SYSLOG_HOST
        port: "514"                     #SYSLOG_PORT
        mode: "tcp"                     #SYSLOG_MODE
        format: "rfc5424"               #SYSLOG_FORMAT