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
Copy file name to clipboardExpand all lines: content/en/docs/concepts/security/service-accounts.md
+30
Original file line number
Diff line number
Diff line change
@@ -196,6 +196,36 @@ or using a custom mechanism such as an [authentication webhook](/docs/reference/
196
196
You can also use TokenRequest to obtain short-lived tokens for your external application.
197
197
{{< /note >}}
198
198
199
+
### Restricting access to Secrets {#enforce-mountable-secrets}
200
+
201
+
Kubernetes provides an annotation called `kubernetes.io/enforce-mountable-secrets`
202
+
that you can add to your ServiceAccounts. When this annotation is applied,
203
+
the ServiceAccount's secrets can only be mounted on specified types of resources,
204
+
enhancing the security posture of your cluster.
205
+
206
+
You can add the annotation to a ServiceAccount using a manifest:
207
+
208
+
```yaml
209
+
apiVersion: v1
210
+
kind: ServiceAccount
211
+
metadata:
212
+
annotations:
213
+
kubernetes.io/enforce-mountable-secrets: "true"
214
+
name: my-serviceaccount
215
+
namespace: my-namespace
216
+
```
217
+
When this annotation is set to "true", the Kubernetes control plane ensures that
218
+
the Secrets from this ServiceAccount are subject to certain mounting restrictions.
219
+
220
+
1. The name of each Secret that is mounted as a volume in a Pod must appear in the `secrets` field of the
221
+
Pod's ServiceAccount.
222
+
1. The name of each Secret referenced using `envFrom` in a Pod must also appear in the `secrets`
223
+
field of the Pod's ServiceAccount.
224
+
1. The name of each Secret referenced using `imagePullSecrets` in a Pod must also appear in the `secrets`
225
+
field of the Pod's ServiceAccount.
226
+
227
+
By understanding and enforcing these restrictions, cluster administrators can maintain a tighter security profile and ensure that secrets are accessed only by the appropriate resources.
228
+
199
229
## Authenticating service account credentials {#authenticating-credentials}
0 commit comments