-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filter_kubernetes: add kubernetes_namespace metadata #8279
filter_kubernetes: add kubernetes_namespace metadata #8279
Conversation
Closes fluent#6544 Addresses fluent#3865 Signed-off-by: ryanohnemus <[email protected]>
Added a second commit for the following... thought it was probably a good idea to include at least one test 😄 :
|
- also updates error text for kubelet vs kube api upstream errors - get_namespace_api_server_info passes in meta->namespace instead of ctx->namespace which may not be set at time of call amended: Added missing test log file. Signed-off-by: ryanohnemus <[email protected]>
2a2e6d0
to
d86aab7
Compare
Initial test run failed due to missing test file. I didn't catch the |
@ryanohnemus I think we can link out to tests proving this now? That will demonstrate both the current behaviour working and this new behaviour right? If you can link that with some example output as well to show @edsiper this is well tested that will help. |
@patrick-stephens @edsiper - yes, i added CI tests for the kubernetes_filter here: https://github.com/fluent/fluent-bit-ci/blob/main/tests/kubernetes-plugins/full.bats and we have an example of those passing (also attached to this PR via the checks) here: https://github.com/fluent/fluent-bit/actions/runs/7654984585/job/20860421190?pr=8279 |
@ryanohnemus post the log contents as well for posterity as they'll expire eventually |
@patrick-stephens understood!
And the output is:
You should see a
config:
output:
You should see both a |
Signed-off-by: ryanohnemus <[email protected]>
ee8b176
to
da79167
Compare
ci test failure looks like a flake on gke runner, and mac os unit test is a failure on flb-it-log |
Yeah @ryanohnemus I'm happy you've done your best with the flakes :) |
thank you! |
Well done @ryanohnemus! |
fix regression in 3.0 from fluent#8279 Signed-off-by: ryanohnemus <[email protected]>
fix regression in 3.0 from #8279 Signed-off-by: ryanohnemus <[email protected]>
This provides the ability to have the filter_kubernetes plugin fetch namespace labels & annotations and add them to the record under a
kubernetes_namespace
key.Added 3 new configuration options:
kube_meta_namespace_cache_ttl
-FLB_CONFIG_MAP_TIME
- the TTL for the namespace cachenamespace_annotations
-FLB_CONFIG_MAP_BOOL
- On if you want namespace annotations added to the record. Default: Offnamespace_labels
-FLB_CONFIG_MAP_BOOL
- On if you want namespace labels added to the record. Default: OffFetching namespace metadata can not use kubelet so the shared variables around kubelet vs kubernetes api were completely split in this patch. This allows us to still use kubelet for pod information if
Use_Kubelet On
is set, while still being able to fetch namespace metadata from the upstream kubernetes api.namespace_labels
ornamespace_annotations
areOn
then fetching of namespace metadata from the kubrenetes api will NOT occur.a second cache (flb_hash_table) and configuration for it's ttl was added specifically for caching namespace information. I found this important as you may want to refresh namespace label information every few minutes (in case namespace labels/annotations change), while only fetching new pod metadata if the cache is full. I defaulted the namespace cache to a 15min ttl.
metadata fetching / extraction for pod vs namespace metadata is fairly separate intentionally as based on how this Pull Request goes, i would be willing to add the ability to add namespace metadata to non-pod logs (ie the ability to enrich kubernetes_events input with the same
kubernetes_namespace
data)Closes #6544
Addresses #3865
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
fluent/fluent-bit-docs#1280
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.