Skip to content

Commit bcc8602

Browse files
authored
Merge pull request #21034 from jqmichael/patch-4
Clarified Secrets file mode
2 parents 9885164 + 14448d7 commit bcc8602

File tree

1 file changed

+36
-4
lines changed
  • content/en/docs/concepts/configuration

1 file changed

+36
-4
lines changed

content/en/docs/concepts/configuration/secret.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ spec:
580580
- name: foo
581581
secret:
582582
secretName: mysecret
583-
defaultMode: 256
583+
defaultMode: 0400
584584
```
585585

586586
Then, the secret will be mounted on `/etc/foo` and all the files created by the
@@ -590,6 +590,38 @@ Note that the JSON spec doesn't support octal notation, so use the value 256 for
590590
0400 permissions. If you use YAML instead of JSON for the Pod, you can use octal
591591
notation to specify permissions in a more natural way.
592592

593+
Note if you `kubectl exec` into the Pod, you need to follow the symlink to find
594+
the expected file mode. For example,
595+
596+
Check the secrets file mode on the pod.
597+
```
598+
kubectl exec mypod -it sh
599+
600+
cd /etc/foo
601+
ls -l
602+
```
603+
604+
The output is similar to this:
605+
```
606+
total 0
607+
lrwxrwxrwx 1 root root 15 May 18 00:18 password -> ..data/password
608+
lrwxrwxrwx 1 root root 15 May 18 00:18 username -> ..data/username
609+
```
610+
611+
Follow the symlink to find the correct file mode.
612+
613+
```
614+
cd /etc/foo/..data
615+
ls -l
616+
```
617+
618+
The output is similar to this:
619+
```
620+
total 8
621+
-r-------- 1 root root 12 May 18 00:18 password
622+
-r-------- 1 root root 5 May 18 00:18 username
623+
```
624+
593625
You can also use mapping, as in the previous example, and specify different
594626
permissions for different files like this:
595627
@@ -612,12 +644,12 @@ spec:
612644
items:
613645
- key: username
614646
path: my-group/my-username
615-
mode: 511
647+
mode: 0777
616648
```
617649

618650
In this case, the file resulting in `/etc/foo/my-group/my-username` will have
619-
permission value of `0777`. Owing to JSON limitations, you must specify the mode
620-
in decimal notation.
651+
permission value of `0777`. If you use JSON, owing to JSON limitations, you
652+
must specify the mode in decimal notation, `511`.
621653

622654
Note that this permission value might be displayed in decimal notation if you
623655
read it later.

0 commit comments

Comments
 (0)