-
Notifications
You must be signed in to change notification settings - Fork 40.3k
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
Reference Secrets from ConfigMap #79224
Comments
@kubernetes/sig-apps-feature-requests |
@collimarco: Reiterating the mentions to trigger a notification: In response to this:
Instructions 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/test-infra repository. |
👋 Hi there I'm just curious if you could expand on some more reasons why this feature should be introduced. Since in order to use the secret inside a deployment for example I would then have to reference the ConfigMap which references the secret resource adding an additional layer I'd need to go through. |
@almiche It would be useful to have a single source of truth: if you have different deployments that share the same env, then you can use a ConfigMap and define all the variables there... but currently it cannot contain secrets, which represent a substancial portion of the env variables. |
Best practice is to not use secret values in envvars, only as mounted files. if you want to keep all config values in a single object, you can place all the values in a secret object and reference them that way. Referencing secrets via configmaps is a non-goal... it confuses whether things mounting or injecting the config map are mounting confidential values. /close |
@liggitt: Closing this issue. In response to this:
Instructions 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/test-infra repository. |
Indeed I am not doing that in my proposed solution. I am just referencing secrets from env variables, not including secrets in env variables. You already allow to reference secrets from env, in Deployments for example: the problem is that you don't allow to do the same inside ConfigMaps.
|
There's no reason to copy the value of the secret in the open into the config map value. Kubernetes is capable of using a pointer or reference to the secret. Either that, or allow defining templates for environment variables from multiple sources (configMap and secrets) that can also be referenced from envFrom. This is essential to keep service definitions concise - 10 env vars rapidly multiply when the same container image is used to run an app's deployments (eg multiple queue consumers or the like), its init containers for migrations, cronjobs, etc. Real life apps. |
I would also be interested in such a feature. Please consider reopening it. |
So, how do I set common parameters using reference. initContainers:
- name: init
env:
- name: HUGA
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: PIYO
valueFrom:
secretKeyRef:
name: a-secret
key: a-secret-key
containers:
- name: container1
env:
- name: HUGA
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: PIYO
valueFrom:
secretKeyRef:
name: a-secret
key: a-secret-key
- name: container2
env:
- name: HUGA
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: PIYO
valueFrom:
secretKeyRef:
name: a-secret
key: a-secret-key |
Adding my 2 cents here. I have an app that uses a config. Inside that config, my app requires a database password. I have that password in a secret. I would like to use it in my config. Without the ability to reference a secret in a config map, that gets resolved to the actual value of that secret when mounting the configmap as a file, I am obliged to store a secret directly in a config map, or use a secret to store my config and mount the secret as my apps config. Either way, it's ugly. I can't use a config map, which would make sense, I need to use a secret to store a config, which apart from a couple of lines of config, there is nothing secret about the rest of it. Or even worse, I need to create a custom entrypoint that generates a config on container start from a config map and a few secrets. Just feels wrong. |
I think it makes lot of sense to have option that links secret from config map. |
As previously mentioned by @gabriel-samfira, there's a bunch of possible useful scenarios where having access to Secrets inside a ConfigMap would avoid having configuration file interpolation during runtime or exposing the sensitive information wide-open directly into ConfigMap. |
Right now I think I need this to wire in a kubedb-managed postgresql instance into a helm release crd using flux helm operator, but it's possible i'll just hack around it awfully for now |
It is very impractical to not have this feature. The easy way around these are
Other not easy approaches
Please reopen this bud |
Please re open this. This is specially very useful when dealing with opensource helm charts which allow to load custom configurations through labelled config maps. And it is common that such configurations have some kind of secrets like db credentials, smtp credentials etc. For example: |
+1 reopen it please. |
+1 reopen it. |
/reopen |
@amit-uc: You can't reopen an issue/PR unless you authored it or you are a collaborator. In response to this:
Instructions 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/test-infra repository. |
The request makes so much sense to me. |
+1 for reopen |
+1 |
1 similar comment
+1 |
+1 reopen |
3 similar comments
+1 reopen |
+1 reopen |
+1 reopen |
Instead of commenting +1, please vote on the issue itself by clicking Like button. |
@Pitta - One person willing to do the job by writing a KEP [1] [1] https://github.com/kubernetes/enhancements#is-my-thing-an-enhancement |
Probably better to create a different resource type like ConfigMapTemplate or similar |
+1 reopen |
Have you found a solution to this? |
+1 reopen |
+1 re-open My case here is: I deployed an nginx-ingres-controller which should use config map to read the location snippet and all the config of the nginx server. Inside the configMap > location snippet of the nginx config, I have a very crucial secret key. |
The workarounds provided in this thread break suggested patterns for use of Secrets and ConfigMap. I don't seek to use any ENV variables, but instead to point to a Secret from a ConfigMap. +1 to re-open... as we approach year 4 of this issue |
@dims, I was looking at the KEP docs, and wanted to know about:
Which sig would this feature fall under if we were to write a KEP? Would this be sig-apps? Do we email the mailing list first before working on the KEP template, or should we email the initial completed KEP template to the mailing list? Update: I never had time to do this, but if someone else would like to, please be my guest and tag me when you do 💙 |
@jessebot sig-apps / sig-storage possibly. KEP's are filed as PR(s) in kubernetes/enhancements repository. you can email them / go to their meetings / talk to them on their slack channels etc.. |
I like the idea of this suggested feature. However, I may have overlooked another possibility already proposed here. If that's not the case, you might be able to achieve a similar concept using
By doing so, I think one can still keep the configuration redundancy-free and flexible. |
I guess people already mentioned it but it should be somewhat easy to create a container which is run as a init-container that just does a template expansion using the configmap as template and one or multiple secrets as data input. The result will be the materialised configuration file with secrets included that will be kept in a tmpfs volume shared with the application of interest. This would seamlessly integrate with resources like Another bonus point for this approach is that it should work for any application that works with config files. Not matter it's your own application or a third-party with their own custom file format.
I didn't tested it and I'm quite sure it's not gonna work as is, but you get the idea :) Perhaps I will give to my tmpl-renderer a second life. |
@mixolapmati Regarding updating ca bundles, maybe have a look at trust-manager from the cert-manager folks. |
please re open this |
I'm facing this issue now with managed prometheus on Azure, I cannot configure it to read the service catalog of consul without adding the token in this feature would be very helpful in such cases. |
There is no real alternative / solution to this real world issue. Could you reopen and consider this issue ? |
Would be great to have a solution for this one! |
For those still commenting that they want this featureI believe you need to write a KEP for it to be considered as an official feature request: I don't have time to write one right now, but if someone else would like to, please then link it to this issue. If no one can write the KEP, then I don't think it will be considered, as per #79224 (comment). I don't believe commenting that you want the feature or that you want this reopened has any effect. You need to write the KEP. |
+1 to reopen This will provides a unified solution for retrieving SSM parameters into a Kubernetes cluster. |
+1 for reopen! |
+1 for reopen pleasee :( |
+1 for reopen! |
What would you like to be added:
I would like to have a way to reference Secrets from ConfigMaps.
For example:
Why is this needed:
ConfigMaps are useful to describe in one place all the env variables: the you can easily reuse the same env for multiple deployments. Basically if I have multiple Deployments or Pods, I can easily include the same ConfigMap and have all the env variables... except the secret env variables :( Indeed Kubernetes doesn't allow me to reference secrets from the ConfigMap, so I have to reference the secrets separately.
I think that it would be useful to have a way to define all the env variables in one place. My proposed feature would achieve that, while also preserving security.
The text was updated successfully, but these errors were encountered: