@@ -580,7 +580,7 @@ spec:
580
580
- name: foo
581
581
secret:
582
582
secretName: mysecret
583
- defaultMode: 256
583
+ defaultMode: 0400
584
584
` ` `
585
585
586
586
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
590
590
0400 permissions. If you use YAML instead of JSON for the Pod, you can use octal
591
591
notation to specify permissions in a more natural way.
592
592
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
+
593
625
You can also use mapping, as in the previous example, and specify different
594
626
permissions for different files like this:
595
627
@@ -612,12 +644,12 @@ spec:
612
644
items:
613
645
- key: username
614
646
path: my-group/my-username
615
- mode: 511
647
+ mode: 0777
616
648
```
617
649
618
650
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 ` .
621
653
622
654
Note that this permission value might be displayed in decimal notation if you
623
655
read it later.
0 commit comments