Merge pull request #28936 from rata/secret-configmap-file-mode

Automatic merge from submit-queue

Allow setting permission mode bits on secrets, configmaps and downwardAPI files

cc @thockin @pmorie 

Here is the first round to implement: https://github.com/kubernetes/kubernetes/pull/28733.

I made two commits: one with the actual change and the other with the auto-generated code. I think it's easier to review this way, but let me know if you prefer in some other way.

I haven't written any tests yet, I wanted to have a first glance and not write them till this (and the API) are more close to the "LGTM" :)

There are some things:
 * I'm not sure where to do the "AND 0777". I'll try to look better in the code base, but suggestions are always welcome :)
 * The write permission on group and others is not set when you do an `ls -l` on the running container. It does work with write permissions to the owner. Debugging seems to show that is something happening after this is correctly set on creation. Will look closer.
 * The default permission (when the new fields are not specified) are the same that on kubernetes v1.3
 * I do realize there are conflicts with master, but I think this is good enough to have a look. The conflicts is with the autog-enerated code, so the actual code is actually the same (and it takes like ~30 minutes to generate it here)
 * I didn't generate the docs (`generated-docs` and `generated-swagger-docs` from `hack/update-all.sh`) because my machine runs out of mem. So that's why it isn't in this first PR, will try to investigate and see why it happens.

Other than that, this works fine here with some silly scripts I did to create a secret&configmap&downwardAPI, a pod and check the file permissions. Tested the "defaultMode" and "mode" for all. But of course, will write tests once this is looking fine :)


Thanks a lot again!
Rodrigo
This commit is contained in:
Kubernetes Submit Queue
2016-08-18 05:59:48 -07:00
committed by GitHub
34 changed files with 41594 additions and 39335 deletions

View File

@@ -606,6 +606,12 @@ type SecretVolumeSource struct {
// the volume setup will error. Paths must be relative and may not contain
// the '..' path or start with '..'.
Items []KeyToPath `json:"items,omitempty"`
// Mode bits to use on created files by default. Must be a value between
// 0 and 0777.
// Directories within the path are not affected by this setting.
// This might be in conflict with other options that affect the file
// mode, like fsGroup, and the result can be other mode bits set.
DefaultMode *int32 `json:"defaultMode,omitempty"`
}
// Represents an NFS mount that lasts the lifetime of a pod.
@@ -707,6 +713,12 @@ type FlockerVolumeSource struct {
type DownwardAPIVolumeSource struct {
// Items is a list of DownwardAPIVolume file
Items []DownwardAPIVolumeFile `json:"items,omitempty"`
// Mode bits to use on created files by default. Must be a value between
// 0 and 0777.
// Directories within the path are not affected by this setting.
// This might be in conflict with other options that affect the file
// mode, like fsGroup, and the result can be other mode bits set.
DefaultMode *int32 `json:"defaultMode,omitempty"`
}
// Represents a single file containing information from the downward API
@@ -718,6 +730,11 @@ type DownwardAPIVolumeFile struct {
// Selects a resource of the container: only resources limits and requests
// (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.
ResourceFieldRef *ResourceFieldSelector `json:"resourceFieldRef,omitempty"`
// Optional: mode bits to use on this file, must be a value between 0
// and 0777. If not specified, the volume defaultMode will be used.
// This might be in conflict with other options that affect the file
// mode, like fsGroup, and the result can be other mode bits set.
Mode *int32 `json:"mode,omitempty"`
}
// AzureFile represents an Azure File Service mount on the host and bind mount to the pod.
@@ -757,6 +774,12 @@ type ConfigMapVolumeSource struct {
// the volume setup will error. Paths must be relative and may not contain
// the '..' path or start with '..'.
Items []KeyToPath `json:"items,omitempty"`
// Mode bits to use on created files by default. Must be a value between
// 0 and 0777.
// Directories within the path are not affected by this setting.
// This might be in conflict with other options that affect the file
// mode, like fsGroup, and the result can be other mode bits set.
DefaultMode *int32 `json:"defaultMode,omitempty"`
}
// Maps a string key to a path within a volume.
@@ -769,6 +792,11 @@ type KeyToPath struct {
// May not contain the path element '..'.
// May not start with the string '..'.
Path string `json:"path"`
// Optional: mode bits to use on this file, should be a value between 0
// and 0777. If not specified, the volume defaultMode will be used.
// This might be in conflict with other options that affect the file
// mode, like fsGroup, and the result can be other mode bits set.
Mode *int32 `json:"mode,omitempty"`
}
// ContainerPort represents a network port in a single container