Skip to content

Commit fbfc54d

Browse files
committed
docs: import CloudNativePG main
1 parent 0ecbfd0 commit fbfc54d

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

website/docs/cluster_conf.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ the `.spec.ephemeralVolumesSizeLimit.shm` field in the cluster spec.
8989
Use this field only in case of
9090
[PostgreSQL running with `posix` shared memory dynamic allocation](postgresql_conf.md#dynamic-shared-memory-settings).
9191

92+
## ServiceAccount token mount
93+
94+
The `automountServiceAccountToken` field of the cluster specification
95+
controls the automatic mount of the `ServiceAccount` token in the instance
96+
Pods and in the Jobs that create them. Setting it to `false` helps comply
97+
with admission policies enforced in hardened environments; the operator then
98+
mounts an equivalent projected volume so that the instance manager can keep
99+
working. See
100+
["Disabling the automatic mount of the ServiceAccount token"](security.md#disabling-the-automatic-mount-of-the-serviceaccount-token)
101+
for the details.
102+
92103
## Environment variables
93104

94105
:::important

website/docs/security.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,47 @@ PostgreSQL `Cluster` resource name.
490490
[recommended way to access the API server from within a Pod](https://kubernetes.io/docs/tasks/run-application/access-api-from-pod/).
491491
:::
492492

493+
#### Disabling the automatic mount of the ServiceAccount token
494+
495+
Some hardened environments enforce admission policies that require
496+
`automountServiceAccountToken: false` on every Pod and on the
497+
`ServiceAccount` itself. You can comply with such policies by setting the
498+
`automountServiceAccountToken` field in the cluster specification:
499+
500+
```yaml
501+
apiVersion: postgresql.cnpg.io/v1
502+
kind: Cluster
503+
metadata:
504+
name: cluster-example
505+
spec:
506+
automountServiceAccountToken: false
507+
instances: 3
508+
storage:
509+
size: 1Gi
510+
```
511+
512+
The value is copied verbatim to the specification of the instance Pods, to
513+
the pod template of the Jobs that create the instances, and to the
514+
`ServiceAccount` generated by the operator.
515+
516+
Since the instance manager requires access to the Kubernetes API server, when
517+
the automatic mount is disabled the operator adds to those Pods and Jobs an
518+
explicit projected volume named `kube-api-access`, equivalent to the volume
519+
that Kubernetes would have automounted, and mounts it on every container at
520+
`/var/run/secrets/kubernetes.io/serviceaccount`. As a result, the workload
521+
keeps the same API server access it would have with the default settings,
522+
while satisfying policies that check the `automountServiceAccountToken`
523+
fields.
524+
525+
Changing the field triggers a rolling update of the cluster.
526+
527+
:::note
528+
When a shared `ServiceAccount` is referenced through `serviceAccountName`
529+
(see below), the operator does not modify it: setting
530+
`automountServiceAccountToken: false` on the `ServiceAccount` itself is your
531+
responsibility in that case.
532+
:::
533+
493534
#### Using a shared ServiceAccount
494535

495536
By default, CloudNativePG creates a dedicated `ServiceAccount` for each cluster,

0 commit comments

Comments
 (0)