Tanzu: Install Fluent Bit for Log Forwarding

Fluent Bit is a lightweight log processor and forwarder that streamlines the log collection process and enables you to send logs to a variety of storage providers such as Elastic Search, Kafka, Splunk, VMware Aria Operations for Logs, or even an HTTP endpoint.

You can deploy Fluent Bit on any standalone management cluster or workload cluster from which you want to collect logs. First, you configure an output plugin on the cluster from which you want to gather logs, depending on the endpoint that you use. Then, you deploy Fluent Bit on the cluster.

Prerequisites

  • A bootstrap machine with the following installed:
    • Tanzu CLI and kubectlCarvel tools
    • yq v4.5 or later.
  • A standalone management cluster and workload cluster running on vSphere 8, AWS, or Azure.
  • You have deployed one of the logging management backends for storing and analyzing logs that Fluent Bit supports, such as VMware Aria Operations for Logs.

Prepare the Cluster for Fluent Bit Deployment

Note

You must deploy Fluent Bit on each cluster from which you want to collect logs.

To prepare the cluster:

  1. Get the admin credentials of the cluster into which you want to deploy Fluent Bit.

    tanzu cluster kubeconfig get my-cluster --admin
  2. Set the context of kubectl to the cluster.

    kubectl config use-context my-cluster-admin@my-cluster

Follow the procedure below to deploy Fluent Bit on a cluster:

  1. If the cluster does not already have the standard package repository installed, install it:Note: If you are targeting a plan-based cluster (legacy), skip this step. For plan-based clusters, the tanzu-standard package repository is automatically enabled in every cluster, in the tanzu-package-repo-global namespace.

    tanzu package repository add tanzu-standard --url PACKAGE-REPOSITORY-ENDPOINT --namespace tkg-system

    Where PACKAGE-REPOSITORY-ENDPOINT is the URL of the standard package repository. For this release, the URL is projects.registry.vmware.com/tkg/packages/standard/repo:v2.1.1.

See List Package Repositories to obtain this value from the Tanzu CLI, or in Tanzu Mission Control see the Addons > Repositories list in the Cluster pane.

2. If you have not already done so, install cert-manager in the cluster.

3. Confirm that the Fluent Bit package is available in your cluster:

tanzu package available list -A

4. Retrieve the version of the available package:

tanzu package available list fluent-bit.tanzu.vmware.com -A

5. Prepare a configuration file for the Fluent Bit package:

Retrieve the default configuration of the package:

tanzu package available get fluent-bit.tanzu.vmware.com/1.9.5+vmware.1-tkg.2 --default-values-file-output fluent-bit-data-values

Where PACKAGE-VERSION is the version of the Fluent Bit package that you want to install and FILE-PATH is the location to which you want to save the configuration file, for example, fluent-bit-data-values.yaml.

Based on the log management backend you want to configure, add one or more [Output] configurations to the fluent_bit.config.outputs key in the fluent-bit-data-values.yaml file.

The sample file contains examples for Syslog, Elasticsearch, Kafka, Splunk, and HTTP [Output] configurations for your reference. To use the provided Syslog output plugin configuration, you must also uncomment the [Filter] entries under fluent-bit.config.filters –> “Optional – uncomment if using Syslog output plugin”.

The configuration blocks for some [Output], [Input], and [Filter] options are commented out. Uncomment and fill in values for any options you want to configure. You must provide values such as hostnames and ports for your log management backend, as these will be specific to your environment.

6. After you prepare your fluent-bit-data-values.yaml file, remove all comments in the file:

yq -i eval '... comments=""' fluent-bit-data-values.yaml

7. Run tanzu package install to deploy the package:

tanzu package install fluent-bit \
--package fluent-bit.tanzu.vmware.com \
--version AVAILABLE-PACKAGE-VERSION \
--values-file fluent-bit-data-values.yaml \
--namespace TARGET-NAMESPACE


Where:

  • TARGET-NAMESPACE is the namespace in which you want to install the Fluent Bit package. For example, the my-packages namespace.
    • If the –namespace flag is not specified, the Tanzu CLI uses the default namespace. The Fluent Bit pods and any other resources associated with the Fluent Bit component are created in the namespace that you provided in fluent-bit-data-values.yaml; do not install the Fluent Bit package into this namespace.
    • The specified namespace must already exist, for example from running kubectl create namespace my-packages.
  • AVAILABLE-PACKAGE-VERSION is the version that you retrieved by running tanzu package available above.

tanzu package install fluent-bit --package fluent-bit.tanzu.vmware.com --namespace my-packages --version 1.8.15+vmware.1-tkg.1 --values-file fluent-bit-data-values.yaml

8. Verify Fluent Bit Deployment

After you deploy Fluent Bit, you can verify that the deployment is successful:

Confirm that the fluent-bit package is installed. For example:

tanzu package installed list -A

The fluent-bit package and the fluent-bit app are installed in the namespace that you specify when running the tanzu package install command.

Confirm that the fluent-bit app is successfully reconciled in your AVAILABLE-PACKAGE-NAMESPACE:

kubectl get apps -A

If the status is not Reconcile succeeded, view the full status details of the fluent-bit app. Viewing the full status can help you troubleshoot the problem:

kubectl get app fluent-bit --namespace AVAILABLE-PACKAGE-NAMESPACE -o yaml

Where AVAILABLE-PACKAGE-NAMESPACE is the namespace in which you installed the package.

Confirm that the new services are running by listing all of the pods that are running in the cluster:

kubectl get pods -n tanzu-system-logging

9. Update a Running Fluent Bit Deployment, if needed.

To make changes to the configuration of the Fluent Bit package after deployment, update your deployed Fluent Bit package:

Update the Fluent Bit configuration in the fluent-bit-data-values.yaml file.

Update the installed package:

tanzu package installed update fluent-bit \
--version 1.8.15+vmware.1-tkg.1 \
--values-file fluent-bit-data-values.yaml \
--namespace my-packages

The Fluent Bit package is reconciled using the new value or values that you added. It can take up to five minutes for kapp-controller to apply the changes.

10. Delete a Fluent Bit Deployment, if needed.

To remove the Fluent Bit package on your cluster, run:

tanzu package installed delete fluent-bit --namespace my-packages

Reference: Install Fluent Bit for Log Forwarding

Leave a comment