Kubernetes automatically mounts ServiceAccount credentials in each Pod. The ServiceAccount may be assigned roles allowing Pods to access API resources. Blocking this ability is an extension of the least privilege best practice and should be followed if Pods do not need to speak to the API server to function. This policy ensures that mounting of these ServiceAccount tokens is blocked.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: restrict-automount-sa-tokenannotations:policies.kyverno.io/title: Restrict Auto-Mount of Service Account Tokenspolicies.kyverno.io/category: Sample, EKS Best Practicespolicies.kyverno.io/severity: mediumpolicies.kyverno.io/subject: Pod,ServiceAccountpolicies.kyverno.io/minversion: 1.6.0policies.kyverno.io/description: Kubernetes automatically mounts ServiceAccount credentials in each Pod. The ServiceAccount may be assigned roles allowing Pods to access API resources. Blocking this ability is an extension of the least privilege best practice and should be followed if Pods do not need to speak to the API server to function. This policy ensures that mounting of these ServiceAccount tokens is blocked.spec:validationFailureAction: Auditbackground: truerules:- name: validate-automountServiceAccountTokenmatch:any:- resources:kinds:- Podpreconditions:all:- key: "{{ request.\"object\".metadata.labels.\"app.kubernetes.io/part-of\" || '' }}"operator: NotEqualsvalue: policy-reportervalidate:message: Auto-mounting of Service Account tokens is not allowed.pattern:spec:automountServiceAccountToken: "false"
This policy prevents the use of the default project in an Application.
Services of type LoadBalancer when deployed inside AWS have support for transport encryption if it is enabled via an annotation. This policy requires that Services of type LoadBalancer contain the annotation service.beta.kubernetes.io/aws-load-balancer-ssl-cert with some value.
This policy prevents updates to the project field after an Application is created.