Skip to content

feat(fluentbit): add the mkdir option to the file output - #2097

Open
cvas22 wants to merge 4 commits into
fluent:masterfrom
cvas22:feat/1618-file-mkdir
Open

cvas22 wants to merge 4 commits into
fluent:masterfrom
cvas22:feat/1618-file-mkdir

Conversation

@cvas22

@cvas22 cvas22 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Adds the mkdir option to the Fluent Bit file output, as requested in #1618. When it is true, Fluent Bit creates the output directory recursively (with permissions 0755), so the whole path no longer has to be mounted into the Fluent Bit pods.

file:
  path: /var/log/out/app/logs
  mkdir: true

mkdir is a *bool, so it is only written to the config when set (Mkdir true or Mkdir false), and existing outputs are unchanged.

Changes:

  • apis/fluentbit/v1alpha2/plugins/output/file_types.go: the field and its Mkdir parameter
  • zz_generated.deepcopy.go: the matching deepcopy for the pointer
  • file_types_test.go: the field set, unset and false
  • docs/plugins/fluentbit/output/file.md and the outputs/clusteroutputs CRDs in config/crd/bases, both charts and manifests/setup/setup.yaml

Notes

I used some help from AI. I reviewed the changes and the tests, please don't yell at me. Thx.

The issue was picked up in November 2025, but I couldn't find a PR for it. If someone is still working on it, I'm happy to close this one.

go test ./apis/fluentbit/v1alpha2/plugins/output/ passes. The CRD YAML was edited by hand and matches what the generate-and-diff check in CI produces; that check also needed one deepcopy line for the new pointer field, which is included. I haven't run this against a live Fluent Bit.

Fixes #1618

Add mkdir to the File output so Fluent Bit creates the output directory recursively, instead of every path having to be mounted into the Fluent Bit pods.

Fixes fluent#1618

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
Comment on lines +45 to +47
if f.Mkdir != nil {
kvs.Insert("Mkdir", fmt.Sprint(*f.Mkdir))
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the plugins.InsertKVString function?

@cvas22 cvas22 Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a5b23da. Mkdir is a *bool, so I used plugins.InsertKVField, which also skips it when it's unset, rather than InsertKVString, which takes a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support mkdir option for the output file plugin fluentbit

2 participants