-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Fine-grained control of secret data in volume #4789
Comments
@liggitt fyi |
I have a use case where a component requires 'secret' information across multiple sub-directories.
Both secret1 and secret2 are related, and it would be convenient to manage them as part of the same Kubernetes Secret resource. While I am not sure if my reaction is knee-jerk, my initial bias is that I should be able to control what sub-directories a secret key can present itself under relate to relative to the mounted directory rather than all keys being files that are immediate children of the parent directory. |
I have use case where MongoDB 'keyFile' requires to have 0600 permissions, so having a mechanism to set the permissions for the file in secret will be extra useful. For now, the workaround is to copy the 'keyFile' to other location and adjust the permissions manually. |
For my use case requiring multiple directories, we have a work around, but I am not sure that would be possible for all other situations. Sometimes it would be useful to have a tar as a secret value and I can ask it to be expanded prior to giving it to my container? |
My use case is to pass a SSH key through secret, with that I'm hitting too broad access permissions. SSH requires its key to be accessible only by the user owning those keys. Simple fix is possible, if I change in |
0400 seems like a reasonable default for secrets. In general, enabling permissions to be set on generated volumes (as opposed to attached or exposed volumes) would be useful. |
SSH keys is one example of where this is useful and almost required. |
Related: #7554 |
As discussed in #6477, we have now solved all of the problems of validating paths. We should refactor to an API similar to the one provided for the downward API volume. |
Applying the pattern from the downward API and the proposed // SecretVolumeSource represents a volume containing Secret keys
// projected into files
type SecretVolumeSource struct {
// A list of files containing secret data in the volume.
Items []SecretVolumeFile `json:"items,omitempty"`
}
// SecretVolumeFile represents a single file containing a Secret key
type SecretVolumeFile struct {
// A reference to the secret key to project
SecretKeySelector `json:",inline"`
// Path is the relative path name of the file to be created.
// Must not be absolute or contain the '..' path.
// Must be utf-8 encoded.
// The first item of the relative path must not start with '..'
Path string `json:"path"`
// Ownership and permission information for the file.
FileInfo FileInfo `json:"fileInfo"`
}
// SecretKeySelector selects a key of a Secret.
//
// This mirrors the ConfigDataSelector type in the proposed ConfigData API
type SecretKeySelector struct {
// The name of the secret in the pod's namespace to select from.
SecretName string `json:"secretName"`
// The key of the secret to select from. Must be a valid secret key.
Key string `json:"key"`
}
// FileInfo contains ownership and permission information for a file.
// If FileInfo is specified for a file, that file will not be relabeled
// by ownership management.
type FileInfo struct {
// The UID to own the file
UID int32 `json:"uid"`
// The GID that should own the file
GID int32 `json:"gid,omitempty"`
// The unix rwxrwxrwx permissions of the file. Only the nine least
// significant bits are the allowed to be set.
Mode int32 `json:"mode"`
} EDIT:
@derekwaynecarr the downward API does support your multiple-directory use-case. |
👍 that should perfectly satisfy what I was looking for, at the same time being a better solution to what I proposed in #7908. |
@soltysh Yeah, the devil's in the details, though. We will need policy to determine what users can specify for UID and GID at least, as well as probably for the mode field. |
@pweil- new policy touchpoint |
|
|
@deads2k What aspect of file info did you have in mind? Being more explicit about the semantics, I think the presence of a |
Hi, is someone working on this? I opened another issue (#28317) that is quite similar, although I was planning to extend it for configmaps too (as was requested there). If someone is working on this, can we coordinate to not step over each other? |
This can be closed, as the first one is implemented via "items" in the volume and the second via the "defaultMode" on the volume or "mode" in items. And both present in a released k8s version (1.4 is the first version with both). Thanks! |
The Editing ( |
Yes, upgrading the client fixes that. |
Adding 0400 mode worked for me! |
Is there a solution for that? |
Currently the
SecretVolumeSource
does not allow the user to control:It should be possible to control both of these things.
The text was updated successfully, but these errors were encountered: