You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -55,18 +55,75 @@ See [Information security for Secrets](#information-security-for-secrets) for mo
55
55
56
56
## Uses for Secrets
57
57
58
-
There are three main ways for a Pod to use a Secret:
58
+
You can use Secrets for purposes such as the following:
59
59
60
-
- As [files](#using-secrets-as-files-from-a-pod) in a
61
-
{{< glossary_tooltip text="volume" term_id="volume" >}} mounted on one or more of
62
-
its containers.
63
-
- As [container environment variable](#using-secrets-as-environment-variables).
64
-
- By the [kubelet when pulling images](#using-imagepullsecrets) for the Pod.
60
+
-[Set environment variables for a container](/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data).
61
+
-[Provide credentials such as SSH keys or passwords to Pods](/docs/tasks/inject-data-application/distribute-credentials-secure/#provide-prod-test-creds).
62
+
-[Allow the kubelet to pull container images from private registries](/docs/tasks/configure-pod-container/pull-image-private-registry/).
65
63
66
64
The Kubernetes control plane also uses Secrets; for example,
67
65
[bootstrap token Secrets](#bootstrap-token-secrets) are a mechanism to
68
66
help automate node registration.
69
67
68
+
### Use case: dotfiles in a secret volume
69
+
70
+
You can make your data "hidden" by defining a key that begins with a dot.
71
+
This key represents a dotfile or "hidden" file. For example, when the following secret
72
+
is mounted into a volume, `secret-volume`, the volume will contain a single file,
73
+
called `.secret-file`, and the `dotfile-test-container` will have this file
74
+
present at the path `/etc/secret-volume/.secret-file`.
75
+
76
+
{{< note >}}
77
+
Files beginning with dot characters are hidden from the output of `ls -l`;
78
+
you must use `ls -la` to see them when listing directory contents.
79
+
{{< /note >}}
80
+
81
+
```yaml
82
+
apiVersion: v1
83
+
kind: Secret
84
+
metadata:
85
+
name: dotfile-secret
86
+
data:
87
+
.secret-file: dmFsdWUtMg0KDQo=
88
+
---
89
+
apiVersion: v1
90
+
kind: Pod
91
+
metadata:
92
+
name: secret-dotfiles-pod
93
+
spec:
94
+
volumes:
95
+
- name: secret-volume
96
+
secret:
97
+
secretName: dotfile-secret
98
+
containers:
99
+
- name: dotfile-test-container
100
+
image: registry.k8s.io/busybox
101
+
command:
102
+
- ls
103
+
- "-l"
104
+
- "/etc/secret-volume"
105
+
volumeMounts:
106
+
- name: secret-volume
107
+
readOnly: true
108
+
mountPath: "/etc/secret-volume"
109
+
```
110
+
111
+
### Use case: Secret visible to one container in a Pod
112
+
113
+
Consider a program that needs to handle HTTP requests, do some complex business
114
+
logic, and then sign some messages with an HMAC. Because it has complex
115
+
application logic, there might be an unnoticed remote file reading exploit in
116
+
the server, which could expose the private key to an attacker.
117
+
118
+
This could be divided into two processes in two containers: a frontend container
119
+
which handles user interaction and business logic, but which cannot see the
120
+
private key; and a signer container that can see the private key, and responds
121
+
to simple signing requests from the frontend (for example, over localhost networking).
122
+
123
+
With this partitioned approach, an attacker now has to trick the application
124
+
server into doing something rather arbitrary, which may be harder than getting
125
+
it to read a file.
126
+
70
127
### Alternatives to Secrets
71
128
72
129
Rather than using a Secret to protect confidential data, you can pick from alternatives.
@@ -108,8 +165,8 @@ These types vary in terms of the validations performed and the constraints
By default, Secrets are required. None of a Pod's containers will start until
@@ -697,269 +754,6 @@ for a detailed explanation of that process.
697
754
698
755
You cannot use ConfigMaps or Secrets with {{< glossary_tooltip text="static Pods" term_id="static-pod" >}}.
699
756
700
-
## Use cases
701
-
702
-
### Use case: As container environment variables {#use-case-as-container-environment-variables}
703
-
704
-
You can create a Secret and use it to
705
-
[set environment variables for a container](/docs/tasks/inject-data-application/distribute-credentials-secure/#define-container-environment-variables-using-secret-data).
0 commit comments