KEP-5883: Optional key in ConfigMapKeyRef and SecretKeyRef defaults to env var name#5955
KEP-5883: Optional key in ConfigMapKeyRef and SecretKeyRef defaults to env var name#5955dap0am wants to merge 1 commit intokubernetes:masterfrom
Conversation
…o env var name Adds a provisional KEP for allowing the `key` field to be omitted from `configMapKeyRef` and `secretKeyRef`, defaulting to the enclosing `env[*].name` when the `EnvVarKeyDefaultsToName` feature gate is enabled. Ref: kubernetes/kubernetes#132195
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dap0am The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @dap0am! |
|
Hi @dap0am. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
When the EnvVarKeyDefaultsToName feature gate is enabled, the `key` field in `configMapKeyRef` and `secretKeyRef` may be omitted. The kubelet then defaults the lookup key to the enclosing `env[*].name` at runtime. Changes: - Register EnvVarKeyDefaultsToName feature gate (alpha, v1.35, default off) - Update validateConfigMapKeySelector/validateSecretKeySelector to allow an empty key when the gate is on, validating that env var name is also a valid ConfigMap/Secret key - Update makeEnvironmentVariables() in kubelet to default an empty key to env var name when the gate is on - Add unit tests for both the validation and kubelet resolution paths Ref: kubernetes#132195 KEP: kubernetes/enhancements#5955
When the EnvVarKeyDefaultsToName feature gate is enabled, the `key` field in `configMapKeyRef` and `secretKeyRef` may be omitted. The kubelet then defaults the lookup key to the enclosing `env[*].name` at runtime. Changes: - Register EnvVarKeyDefaultsToName feature gate (alpha, v1.35, default off) - Update validateConfigMapKeySelector/validateSecretKeySelector to allow an empty key when the gate is on, validating that env var name is also a valid ConfigMap/Secret key - Update makeEnvironmentVariables() in kubelet to default an empty key to env var name when the gate is on - Add unit tests for both the validation and kubelet resolution paths Ref: kubernetes#132195 KEP: kubernetes/enhancements#5955
Summary
Adds a provisional KEP for making the
keyfield optional inconfigMapKeyRefand
secretKeyRef. When omitted and theEnvVarKeyDefaultsToNamefeature gateis enabled, the kubelet defaults
keyto the enclosingenv[*].name.This eliminates boilerplate in the common case where the env var name and the
ConfigMap/Secret key are identical:
What this PR includes
keps/sig-node/5883-optional-env-key-defaulting/kep.yaml— KEP metadatakeps/sig-node/5883-optional-env-key-defaulting/README.md— full provisional KEPRelated
EnvVarSourcekubernetes#132195EnvVarKeyDefaultsToName/sig node
/sig api-machinery
/kind feature