Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions content/en/docs/tasks/run-application/access-api-from-pod.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,29 @@ The output will be similar to this:
]
}
```


## Security considerations

A workload that talks to the Kubernetes API authenticates as a ServiceAccount
and inherits whatever permissions that account has been granted. Treat that
identity the way you would any service credential:

- Bind a dedicated ServiceAccount to each workload that needs API access
rather than reusing the namespace's `default` ServiceAccount, so that
permissions stay scoped to one workload at a time.
- Grant the minimum permissions the workload actually needs, using
[Role-based access control](/docs/reference/access-authn-authz/rbac/).
Prefer a `Role` and `RoleBinding` in the workload's namespace over a
`ClusterRole`/`ClusterRoleBinding` whenever the access can be confined to
a single namespace.
- Set
[`automountServiceAccountToken: false`](/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-server)
on the Pod or ServiceAccount when the workload does not need to call the
API server. The token is mounted by default, and an unused token widens
the blast radius if the Pod is later compromised.
- Re-evaluate periodically whether the workload still needs direct API
access. A controller running in a separate namespace, an admission
webhook, or an external service that reads from the API once per
reconciliation loop is often a safer alternative than embedding API
credentials in every Pod replica.