-
Notifications
You must be signed in to change notification settings - Fork 97
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
[FEATURE] Multiple vault objects into single K8s secret #36
Comments
@torresdal Does this feature would make sense in your opinion? As I wrote - I could try to implement this, but I would like to know if this has a chance to be accepted. |
@MariuszJozala-Avaleo it does make sense 👍 Need to think through if we can reuse the AzureKeyVaultSecret CRD or if we have to create a new one. Mostly semantic really. AzureKeyVaultSecret is singular and I would expect it to represent a single secret in Azure Key Vault. Ignoring semantics, the easiest would be to reuse. Another alternative would be to define/use multiple We are also using Flux, but not currently using Regarding the alternative (#18) with templating, in your case you would still need multiple secrets as input. Therefore my interpretation is that your feature request is mainly about querying multiple objects in Azure Key Vault and output into one single secret. Just some initial thoughts. Anyone feel free to chip into this discussion with your preferences and suggestions. |
Actually, I would prefer not to change the So defining two seperate apiVersion: spv.no/v1alpha1
kind: AzureKeyVaultSecret
metadata:
name: keyvault-secret-one
spec:
vault:
name: mykeyvault
object:
name: SecretOne
type: secret
output:
secret:
name: my-only-kuberentes-secret
dataKey: secret-one
---
apiVersion: spv.no/v1alpha1
kind: AzureKeyVaultSecret
metadata:
name: keyvault-secret-two
spec:
vault:
name: mykeyvault
object:
name: SecretTwo
type: secret
output:
secret:
name: my-only-kuberentes-secret
dataKey: secret-two would result in one single Kubernetes apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: my-only-kuberentes-secret
data:
secret-one: XXXXXXXX
secret-two: XXXXXXXX What do you think? BTW: Currently, when defining two |
I'm thinking overwriting the To enable multiple
...or maybe What do you think @robinmanuelthiel ? |
I would definitely prefer camelCase over of kebab-case for the new field, as it seems to be the standard in other Kubernetes objects. What about
Can you explain, why we need a different extra property for this? Why can't we just reuse the existing I would honestly expect it to "just work" when I define two |
We’ll have a go at the most intuitive solution as you describe, and see where it goes from there 👍 |
Thanks for getting involved and all proposed solutions. Sorry for late reply, but I had to leave the topic aside for a while. apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: app-secret
namespace: apps-ns
data:
values.yaml: | # value of this field will be passed as additional values file to Helm (it needs to be YAML).
some:
value:
one: test-secret-value
two: another-secret value If the way is to go with multiple apiVersion: spv.no/v1alpha1
kind: AzureKeyVaultSecret
metadata:
name: keyvault-secret-one
spec:
vault:
name: mykeyvault
object:
name: SecretOne
type: secret
output:
multiKeySecret:
name: my-only-kuberentes-secret # <-- Same Kubernetes Secret targeted
dataKey: values.yaml # <-- Same data field in K8s secret
secretKey: some.value.one # <-- Additional to know where to put value
---
apiVersion: spv.no/v1alpha1
kind: AzureKeyVaultSecret
metadata:
name: keyvault-secret-two
spec:
vault:
name: mykeyvault
object:
name: SecretTwo
type: secret
output:
multiKeySecret:
name: my-only-kuberentes-secret # <-- Same Kubernetes Secret targeted
dataKey: values.yaml # <-- Same data field in K8s secret
secretKey: some.value.two # <-- Additional to know where to put value I was also thinking about how usage will look like. Some KeyVault secrets are shared by multiple applications, but we would still like to have separate Kubernetes secrets per application with all KeyVault secrets that application needs. Example:
I would like to have single secret which I could use in my HelmRelease: apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: foo-app-secrets
namespace: apps-ns
data:
values.yaml: |
database:
password: dbPassValue
rabbitmq:
password: rabbitmqPassValue
someintegration:
key: keyValue123456789 It would be possible to use it in HelmRelease like this (some fields omitted for clarity): apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
metadata:
name: foo-app
namespace: apps-ns
spec:
releaseName: foo-app
valuesFrom:
- secretKeyRef:
name: foo-app-secrets # <-- this is where I tell Flux to add K8s secret as value file
values:
image:
tag: 1.10.0 With all of this, I am asking myself a question if defining three AzureKeyVaultSecret resources, for this case, isn't too much work and duplication. apiVersion: spv.no/v1alpha1
kind: AzureKeyVaultSecretsMapping
metadata:
name: foo-app-secrets
namespace: apps-ns
spec:
vault:
name: my-keyvault
objects:
- name: database_foo_password
type: secret
outputKey: database.password # <-- this is different for each secret from KeyVault
- name: rabbitmq_foo_password
type: secret
outputKey: rabbitmq.password
- name: someintegration_key
type: secret
outputKey: someintegration.key
output:
secret:
name: foo-app-secrets # <-- these are the same for all secrets from Keyvault so I've put them separately
dataKey: values.yaml From my perspective important part is that there is not much duplication and it will be pretty easy to define based on what application needs from Azure KeyVault. Naming is probably rubbish. Forgive me, I wanted to focus on the use cases and structure. Please let me know what you think. |
I am trying to implement this, but I am pretty new to Kubernetes controllers.
I'v tried with code-generation from tag "kubernetes-1.17.4". I believe I am using wrong version of it. |
This is now supported in 1.2-beta - soon to be released |
As mentioned this will be available in 1.2. Closing. |
Is your feature request related to a problem? Please describe.
I would like to use azure-key-vault-to-kubernetes together with Flux feature "valuesFrom".
To do that, I need to read multiple secrets from Azure KeyVault and put it into a single Kubernetes secret, under single key. The values is read later by Flux and used as additional values file when deploying Helm release.
Describe the solution you'd like
I would like to be able to specify multiple objects in AzureKeyVaultSecret (or new CRD) so it would look like this:
And the output secret in K8s would be:
Describe alternatives you've considered
One alternative could be to have customer templating support so it would be possible to achieve the same with templating. There is an existing issue about templating #18.
Additional context
Would that feature make sense for others? Is anyone using azure-key-vault-to-kubernetes with Flux or ArgoCD?
I may try to implement it, but I would like to know what would be feasible solution for this project.
The text was updated successfully, but these errors were encountered: