-
Notifications
You must be signed in to change notification settings - Fork 2.3k
secretGenerator to generate Secret with stringData manifest #5142
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
Comments
This old issue #1444 was simply closed without being commented, or addressed. |
To clarify, post-build substitution does not require use of the "stringData" field in a candidate manifest, but you want to use that field to sidestep the Base64 encoding, which masks the content you wish to replace. Flux doesn't pay any attention to field names in the manifests. It serializes them as YAML, and runs envsubst over the bytes. |
The Flux's post-build variable substitution documentation clearly states:
|
Yes, that's the documentation clarifying a common situation in which post-build substitution cannot see the content you'd like it to act upon. You have the same problem editing comments in PEM-encoded X.509 certificate bundles that occur in a (Valida|Muta)tingWebhookConfiguration's "webhooks[*].clientConfig.caBundle" field, which is also Base64-encoded. The Flux documentation is correct, but not complete. I was explaining why you need to use the Secret "stringData" field here. |
We also need this, we're using envsubst and it does not work on Secret/data. We need stringData option :D |
I could see implementing this, accepting an option in the "secretGenerator[*].options" field, though that field is of type The |
Hi @valerytschopp, thank you for explaining your use case and providing an example in your description. Thanks @seh for investigating. Yes, we believe it is a reasonable use case to specify the /triage accepted |
Edit: Doesn't work - secretGenerator base64 encodes the values, but stringData expects plaintext. This also works in the meantime:
|
What about the Base64 encoding of the "data" field's value? |
You're right, it still gets Base64 encoded. No dice. |
Thanks to @filedeploy I found an ugly workaround which works at least for environment variables for pods, which we use with generators so that deployments get restarted once the values change (although this probably doesn't work as well for files): secretGenerator:
- name: my-secret
namespace: my-namespace
literals: []
patches:
- patch: |-
- op: move
from: /data
path: /stringData
- op: add
path: /stringData
value:
API_KEY: ${API_KEY}
SECRET: ${SECRET_KEY}
target:
kind: Secret
name: my-secret EDIT: Just found out that the secret suffix does not change anymore with this approach, so this is not really a solution either. |
Hi, it would be really useful also with using vals for managing secrets. I hope it will land soon inside the options of secretGenerator or generatorOptions. Something like |
I'm so glad you filed this issue. |
Eschewed features
What would you like to have added?
The secretGenerator should be able to generate Secret manifest with unencoded stringData.
We understand that kustomize eschews parameterization, but the resulting manifest is valid YAML, and can be processed by various tools (envsubst, flux post-build variable substitution, ...).
Therefore we ask the Kustomize SIG to consider this feature.
Example:
kustomize build .
Why is this needed?
We are doing GitOps with Flux's post-build variable substitution which currently requires stringData in the secret.
Base64 encoded values would not be able to be substitued.
Can you accomplish the motivating task without this feature, and if so, how?
Create the Secret by hand with stringData:
But this negate the usefulness of Kustomize generators.
What other solutions have you considered?
Don't use secretGenerator for Helm secret values
Anything else we should know?
No response
Feature ownership
The text was updated successfully, but these errors were encountered: