Merge pull request #1178 from rata/release-1.4
Add documentation for secret, configmap and downwardAPI file permissions for 1.4 releasepull/1063/head
commit
26d8a596b8
|
@ -414,6 +414,11 @@ When this pod is run, the output will be:
|
|||
very
|
||||
```
|
||||
|
||||
#### Projecting keys to specific paths and file permissions
|
||||
|
||||
You can project keys to specific paths and specific permissions on a per-file
|
||||
basis. The [Secrets](/docs/user-guide/secrets/) user guide explains the syntax.
|
||||
|
||||
## Real World Example: Configuring Redis
|
||||
|
||||
Let's take a look at a real-world example: configuring redis using ConfigMap. Say we want to inject
|
||||
|
|
|
@ -114,6 +114,10 @@ The downward API volume refreshes its data in step with the kubelet refresh loop
|
|||
|
||||
In future, it will be possible to specify a specific annotation or label.
|
||||
|
||||
#### Projecting keys to specific paths and file permissions
|
||||
|
||||
You can project keys to specific paths and specific permissions on a per-file
|
||||
basis. The [Secrets](/docs/user-guide/secrets/) user guide explains the syntax.
|
||||
|
||||
### Example
|
||||
|
||||
|
|
|
@ -262,6 +262,83 @@ If `spec.volumes[].secret.items` is used, only keys specified in `items` are pro
|
|||
To consume all keys from the secret, all of them must be listed in the `items` field.
|
||||
All listed keys must exist in the corresponding secret. Otherwise, the volume is not created.
|
||||
|
||||
**Secret files permissions**
|
||||
|
||||
You can also specify the permission mode bits files part of a secret will have.
|
||||
If you don't specify any, `0644` is used by default. You can sepecify a default
|
||||
mode for the whole secret volume and override per key if needed.
|
||||
|
||||
For example, you can specify a default mode like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Pod",
|
||||
"metadata": {
|
||||
"name": "mypod",
|
||||
"namespace": "myns"
|
||||
},
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "mypod",
|
||||
"image": "redis",
|
||||
"volumeMounts": [{
|
||||
"name": "foo",
|
||||
"mountPath": "/etc/foo",
|
||||
}]
|
||||
}],
|
||||
"volumes": [{
|
||||
"name": "foo",
|
||||
"secret": {
|
||||
"secretName": "mysecret",
|
||||
"defaultMode": 0400
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then, the secret will be mounted on `/etc/foo` and all the files created by the
|
||||
secret volume mount will have permission `0400`.
|
||||
|
||||
You can also use mapping, as in the previous example, and specify different
|
||||
permission for different files like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"apiVersion": "v1",
|
||||
"kind": "Pod",
|
||||
"metadata": {
|
||||
"name": "mypod",
|
||||
"namespace": "myns"
|
||||
},
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "mypod",
|
||||
"image": "redis",
|
||||
"volumeMounts": [{
|
||||
"name": "foo",
|
||||
"mountPath": "/etc/foo",
|
||||
}]
|
||||
}],
|
||||
"volumes": [{
|
||||
"name": "foo",
|
||||
"secret": {
|
||||
"secretName": "mysecret",
|
||||
"items": [{
|
||||
"key": "username",
|
||||
"path": "my-group/my-username",
|
||||
"mode": 0777
|
||||
}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In this case, the file resulting in `/etc/foo/my-group/my-username` will have
|
||||
permission `0777`.
|
||||
|
||||
**Consuming Secret Values from Volumes**
|
||||
|
||||
Inside the container that mounts a secret volume, the secret keys appear as
|
||||
|
|
Loading…
Reference in New Issue