Add secrets to runtime configuration#1169
Conversation
05ec2a6 to
3996a76
Compare
3996a76 to
8f25eb8
Compare
andresmgot
left a comment
There was a problem hiding this comment.
Thanks for the feature! I have a couple of minor comments.
pkg/utils/kubelessutil.go
Outdated
| result.InitContainers[i].VolumeMounts = append(result.InitContainers[i].VolumeMounts, v1.VolumeMount{ | ||
| Name: secret.Name, | ||
| ReadOnly: true, | ||
| MountPath: "/" + secret.Name, |
There was a problem hiding this comment.
you need to use an unused subpath like "/etc/secrets/" + secret.Name so you avoid issues with people using as secret name var or run
There was a problem hiding this comment.
Hi @andresmgot , I agree completely, mounting in the root is not ideal - I went for it as a first iteration + AFAIK serverless-kubeless plugin is using this approach.
I am thinking of the following options:
/var/run/secrets/{{secret.name}}/var/run/secrets/kubeless.io/{{secret.name}}/opt/secrets/{{secret.name}}/opt/secrets/kubeless.io/{{secret.name}}
My choice would be 2. Seems consistent with what I see as mounted volumes with secrets in kubernetes.
What do you think?
There was a problem hiding this comment.
Changed mount path to /var/run/secrets/kubeless.io/{{secret.name}}.
| - Init Image: Image used for installing the function and/or dependencies. | ||
| - (Optional) Image Pull Secrets: Secret required to pull the image in case the repository is private. | ||
| - (Optional) Environment variables. | ||
| - (Optional) Secrets: Shared with the container as mounted volumes. |
There was a problem hiding this comment.
I would add here the path in which the secrets are mounted.
andresmgot
left a comment
There was a problem hiding this comment.
Thanks for the changes!
Issue Ref: None
Description:
Adds support for using secrets via mounted volumes.
Extends the
runtime-imagesstructure inkubeless-configconfigmap to allow using secrets in the init containers of function deployments, in a similar way as providing environment variables.Usage:
Manifest for
github-tokensecret.Manifest for
kubeless-configconfigmapThe above runtime configuration specified custom image for Go 1.14 runtime with a secret
github-tokenshared with the container as a volume mounted at/var/run/secrets/kubeless.io/{{secret.name}}(/var/run/secrets/kubeless.io/github-tokenin this example). Now the container can read the GitHub token secret from the filesystem and use it to download private Go packages.TODOs: