How to configure fluentd daemonset for RBAC
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Running Fluentd as a DaemonSet is a common Kubernetes logging pattern, but collecting logs and enriching them with Kubernetes metadata are separate concerns. Fluentd can read files from the node without API access, yet metadata filters often need RBAC permissions to read pods, namespaces, and sometimes nodes.
Know When RBAC Is Actually Required
Fluentd can tail files under paths such as /var/log/containers using host mounts alone. RBAC becomes necessary when the configuration asks Fluentd to query the Kubernetes API for metadata such as:
- pod name and namespace
- labels and annotations
- container identity
- node-related information
That distinction helps during debugging. If raw log lines are arriving but fields such as namespace or labels are missing, the problem is often RBAC or metadata-plugin configuration rather than the output sink.
Create a Dedicated Service Account
Start by creating a dedicated service account for the log collector instead of using the namespace default account.
This makes access review easier and avoids giving broad permissions to unrelated workloads.
Grant Read-Only RBAC Permissions
For the common Kubernetes metadata filter, read-only API access is usually enough.
Not every deployment needs node access, but many metadata enrichers include node information. Keep the role as small as the plugin actually requires.
Attach the Service Account to the DaemonSet
The RBAC objects are useless unless the DaemonSet runs as that service account.
If serviceAccountName is missing, Kubernetes uses the default service account and the expected permissions never apply.
Enable the Kubernetes Metadata Filter
RBAC is only half of the setup. Fluentd must also be configured to query Kubernetes metadata.
If the metadata filter plugin is not enabled, adding RBAC will not change the output because Fluentd is not even attempting API lookups.
Verify Permissions Before Chasing Other Problems
Use kubectl auth can-i to check the service account directly.
Then inspect the workload itself:
This order matters. It is faster to prove or disprove RBAC first than to debug Elasticsearch, OpenSearch, or another sink while the collector is still missing upstream metadata.
Common Pitfalls
The biggest mistake is solving missing metadata by granting cluster-admin. That may make the symptom disappear, but it creates far more access than a log collector needs.
Another common issue is creating the service account and binding correctly but forgetting serviceAccountName in the DaemonSet. Developers also sometimes assume RBAC is wrong when the real problem is that the metadata filter plugin was never enabled in Fluentd.
Summary
- Fluentd needs RBAC for Kubernetes metadata enrichment, not merely for reading node log files.
- Use a dedicated service account and minimal read-only permissions.
- Make the DaemonSet run under that service account explicitly.
- Enable the metadata filter so Fluentd actually queries the Kubernetes API.
- Verify permissions with
kubectl auth can-ibefore debugging downstream log sinks.

