out_gcs: support application default credentials - #12263
Open
balys wants to merge 2 commits into
Open
Conversation
Signed-off-by: balys <6160690+balys@users.noreply.github.com>
Signed-off-by: balys <6160690+balys@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe GCS output plugin adds GCE/GKE metadata-server authentication, credential environment-variable precedence, configurable metadata-server settings, upstream lifecycle handling, and runtime tests for valid and invalid token responses. ChangesGCS metadata authentication
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant GCSPlugin
participant MetadataServer
participant GCSUploadEndpoint
GCSPlugin->>MetadataServer: Request service-account token
MetadataServer-->>GCSPlugin: Return token and expiry
GCSPlugin->>GCSUploadEndpoint: Upload with bearer token
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
cosmo0920
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The native GCS output currently supports an explicit
google_service_credentialsfile and the legacyGOOGLE_SERVICE_CREDENTIALSenvironment variable. It does not check Google'sstandard
GOOGLE_APPLICATION_CREDENTIALSvariable and fails initialization whenno credentials file is configured, preventing the plugin from using an attached
GCE service account or GKE Workload Identity Federation.
This change adds the relevant Application Default Credentials behavior to
out_gcs:google_service_credentialsconfiguration;GOOGLE_APPLICATION_CREDENTIALS;GOOGLE_SERVICE_CREDENTIALS; andMetadata tokens are retrieved from the default service-account token endpoint,
parsed through Fluent Bit's existing OAuth2 cache, and refreshed before expiry.
The metadata server URL is configurable for testing and non-default
environments.
Addresses #1032 and #9022.
Related work
PR #11758 adds
external_accountSTS token exchange toout_stackdriverforworkloads outside Google Cloud. This PR is complementary: it adds standard ADC
environment lookup and attached GCE/GKE metadata credentials to
out_gcs. Itdoes not add
external_accountcredential-file support.Compatibility
Existing explicit
google_service_credentialsconfigurations are unchanged.GOOGLE_SERVICE_CREDENTIALSremains supported for backwards compatibility. Ifboth environment variables are set,
GOOGLE_APPLICATION_CREDENTIALStakesprecedence and a warning is logged.
GOOGLE_APPLICATION_CREDENTIALSuses the service-account JSON format alreadysupported by
out_gcs. Other ADC file types, such asauthorized_userandexternal_account, are outside this change.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:
GKE Workload Identity or an attached GCE service account requires no credential
property:
A service-account file can use standard ADC:
export GOOGLE_APPLICATION_CREDENTIALS=/var/run/secrets/google/credentials.jsonFocused runtime test:
The runtime suite covers standard ADC precedence, successful metadata token
retrieval and upload, and rejection of an invalid metadata response without an
upload attempt.
Commands:
cmake --build build --target flb-rt-out_gcs -j8 ctest --test-dir build -R '^flb-rt-out_gcs$' --output-on-failure valgrind --leak-check=full \ --show-leak-kinds=definite,indirect \ --errors-for-leak-kinds=definite,indirect \ --error-exitcode=99 build/bin/flb-rt-out_gcsIf this is a change to packaging of containers or native binaries then please
confirm it works for all targets.
[N/A: no packaging changes]ok-package-testlabel to test for all targets (requires maintainer to do).[N/A: no packaging changes]Documentation
A follow-up documentation update should describe the credential precedence and
keyless GCE/GKE configuration. The code config-map description includes the new
metadata_serveroption.Backporting
[N/A: target master for the next release]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.
Summary by CodeRabbit
New Features
metadata_serverconfiguration option.Bug Fixes
GOOGLE_APPLICATION_CREDENTIALSover the legacy environment variable and warns when both are set.