How to configure fluentd daemonset for RBAC
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
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.
Related reading
- How to configure ingress gateway in istio?
- How to configure Ingress request timeouts on GKE
- how to configure ingress to direct traffic to an https backend using https
- How to configure Keycloak Helm Chart
- How to configure Jetty in spring-boot easily?
- How to configure log-driver in kubernetes pods file?
- How to configure kubectl with cluster information from a .conf file?
- How to Configure Pod initialization in a specific order in Kubernetes?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.