Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
© 2022 Yandex.Cloud LLC
Yandex Managed Service for Kubernetes
  • Comparison with other Yandex Cloud services
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Configuring security groups
    • Connecting to a node over SSH
    • Creating a configuration file
    • Updating Kubernetes
    • Installing applications
      • Basics of working with Cloud Marketplace
      • Installing Metrics Provider
    • Network scenarios
      • Granting access to an app running in a Kubernetes cluster
      • Configuring the Calico network policy controller
      • Configuring the Cilium network policy controller
      • Configuring Node Local DNS for the Cilium network policy controller
    • Encrypting secrets
    • Automatic scaling
    • Working with persistent volumes
      • Dynamic volume provisioning
      • Static volume provisioning
      • Managing storage classes
      • Expanding a pod volume
      • Expanding a StatefulSet controller volume
      • Mounting a volume in Block mode
      • Integration with Object Storage
    • Managing a Kubernetes cluster
      • Adding Kubernetes cluster credentials to the kubectl configuration file
      • Getting information about a Kubernetes cluster
      • Creating a Kubernetes cluster
      • Editing a Kubernetes cluster
      • Creating a namespace in a Kubernetes cluster
      • Deleting a Kubernetes cluster
    • Managing a node group
      • Getting information about a node group
      • Creating a node group
      • Changing a node group
      • Managing cluster node labels
      • Deleting a node group
    • Connecting external nodes to the cluster
  • Practical guidelines
    • All tutorials
    • Integration with Container Registry
    • Running workloads with GPUs
    • Installing the NGINX Ingress controller with Let's Encrypt®
    • Configuring the Application Load Balancer Ingress controller
    • Backup to Object Storage
    • Horizontal application scaling in a cluster
    • Working with snapshots
    • Integration with a corporate DNS zone
    • Automatic DNS scaling by cluster size
    • Setting up local DNS caching
    • Configuring Fluent Bit for Yandex Cloud Logging
    • Syncing with Yandex Lockbox secrets
  • Concepts
    • Relationship between service resources
    • Release channels and updates
    • Encrypting secrets
    • Using Kubernetes API objects
      • Volumes
      • Service
    • Node groups
      • Cluster autoscaler
      • Evicting pods from nodes
      • Dynamic resource allocation for a node
      • Node groups with GPUs
    • Network in Managed Service for Kubernetes
    • External cluster nodes
    • Network settings and cluster policies
    • Automatic scaling
    • Quotas and limits
    • Recommendations for using Managed Service for Kubernetes
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • ClusterService
      • NodeGroupService
      • VersionService
      • OperationService
    • REST
      • Overview
      • Cluster
        • Overview
        • create
        • delete
        • get
        • list
        • listNodeGroups
        • listNodes
        • listOperations
        • start
        • stop
        • update
      • NodeGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listNodes
        • listOperations
        • update
      • Version
        • Overview
        • list
  • Questions and answers
    • General questions
    • Data storage
    • Configuring and updating
    • Automatic scaling
    • Resources
    • Logs
    • All questions on one page
  1. Practical guidelines
  2. Configuring Fluent Bit for Yandex Cloud Logging

Configuring Fluent Bit for Cloud Logging

Written by
Yandex.Cloud
  • Before you start
  • Prepare the Kubernetes cluster
  • Install and configure Fluent Bit
  • Delete the resources you created

The Fluent Bit log processor lets you transfer the Managed Service for Kubernetes cluster logs to Yandex Cloud Logging. The Fluent Bit plugin for Yandex Cloud Logging module is used to transfer logs.

To set up transfer of logs:

  1. Prepare the Kubernetes cluster.
  2. Install and configure Fluent Bit.

Before you start

  1. If you don't have the Yandex Cloud command line interface yet, install and initialize it.

    The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

  2. Create a service account needed for Fluent Bit to run.

    1. Assign it the role logging.writer.

    2. Create an authorized key and save it to key.json:

      yc iam key create \
        --service-account-name <name of service account for Fluent Bit> \
        --output key.json
      
  3. Create a log group.

  4. Create a Managed Service for Kubernetes cluster and a node group in any suitable configuration with the Kubernetes version 1.21 or higher.

  5. Install kubectl and set it up for working with the created cluster.

Prepare the Kubernetes cluster

  1. Create the objects necessary for Fluent Bit to run:

    kubectl create namespace logging && \
    kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-service-account.yaml && \
    kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role.yaml && \
    kubectl create -f https://raw.githubusercontent.com/fluent/fluent-bit-kubernetes-logging/master/fluent-bit-role-binding.yaml
    
  2. Create a secret including the key of the service account:

    kubectl create secret generic secret-key-json \
      --from-file=key.json \
      --namespace logging
    

Install and configure Fluent Bit

  1. Create a folder for the service account key and copy the key there:

    sudo mkdir -p /etc/secret && \
    sudo cp key.json /etc/secret
    
  2. Download the config.yaml configuration file:

    wget https://raw.githubusercontent.com/knpsh/yc-logging-fluent-bit-example/main/config.yaml
    
  3. Enter the log output parameters in the data.output-elasticsearch.conf section in config.yaml:

    ...
      output-elasticsearch.conf: |
        [OUTPUT]
          Name            yc-logging
          Match           *
          group_id        <log group ID>
          resource_id     <optional: Kubernetes cluster ID>
          message_key     log
          authorization   iam-key-file:/etc/secret/key.json
    ...
    

    You can request the log group ID with a list of log groups in the folder.

    If needed, enter additional settings for Fluent Bit.

  4. Create Fluent Bit objects:

    kubectl apply -f config.yaml
    

    Expected execution result:

    configmap/fluent-bit-config created
    daemonset.apps/fluent-bit created
    
  5. Make sure the Fluent Bit status changed to Running:

    kubectl get pods -n logging
    
  6. Check the log transmission of the Kubernetes cluster to Cloud Logging.

Delete the resources you created

If you no longer need these resources, delete them:

  1. Delete the cluster Managed Service for Kubernetes.
  2. If you reserved a public static IP address for the cluster, delete it.
  3. Delete the log group.

Was the article helpful?

Language / Region
© 2022 Yandex.Cloud LLC
In this article:
  • Before you start
  • Prepare the Kubernetes cluster
  • Install and configure Fluent Bit
  • Delete the resources you created