-
Notifications
You must be signed in to change notification settings - Fork 752
Add secrets to runtime configuration #1169
Add secrets to runtime configuration #1169
Conversation
05ec2a6
to
3996a76
Compare
3996a76
to
8f25eb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed mount path to /var/run/secrets/kubeless.io/{{secret.name}}
.
- Name: Unique ID of the runtime. It should contain the runtime name and version. | ||
- Version: Major and minor version of the runtime. | ||
- Runtime Image: Image used to execute the function. | ||
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add here the path in which the secrets are mounted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes!
Issue Ref: None
Description:
Adds support for using secrets via mounted volumes.
Extends the
runtime-images
structure inkubeless-config
configmap to allow using secrets in the init containers of function deployments, in a similar way as providing environment variables.Usage:
Manifest for
github-token
secret.Manifest for
kubeless-config
configmapThe above runtime configuration specified custom image for Go 1.14 runtime with a secret
github-token
shared with the container as a volume mounted at/var/run/secrets/kubeless.io/{{secret.name}}
(/var/run/secrets/kubeless.io/github-token
in this example). Now the container can read the GitHub token secret from the filesystem and use it to download private Go packages.TODOs: