@@ -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
495536By default, CloudNativePG creates a dedicated `ServiceAccount` for each cluster,
0 commit comments