Users may be able to specify any ServiceAccount which exists in their Namespace without restrictions. Confining Pods to a list of authorized ServiceAccounts can be useful to ensure applications in those Pods do not have more privileges than they should. This policy verifies that in the `staging` Namespace the ServiceAccount being specified is matched based on the image and name of the container. For example: 'sa-name: ["registry/image-name"]'
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: restrict-service-accountannotations:policies.kyverno.io/title: Restrict Service Accountpolicies.kyverno.io/category: Samplepolicies.kyverno.io/severity: mediumpolicies.kyverno.io/subject: Pod,ServiceAccountpolicies.kyverno.io/minversion: 1.6.0kyverno.io/kyverno-version: 1.6.2kyverno.io/kubernetes-version: "1.23"policies.kyverno.io/description: "Users may be able to specify any ServiceAccount which exists in their Namespace without restrictions. Confining Pods to a list of authorized ServiceAccounts can be useful to ensure applications in those Pods do not have more privileges than they should. This policy verifies that in the `staging` Namespace the ServiceAccount being specified is matched based on the image and name of the container. For example: 'sa-name: [\"registry/image-name\"]'"spec:validationFailureAction: Auditbackground: truerules:- name: validate-service-accountcontext:- name: saMapconfigMap:name: sa-mapnamespace: stagingmatch:any:- resources:kinds:- Podnamespaces:- stagingvalidate:message: Invalid service account {{ request.object.spec.serviceAccountName }} for image {{ images.containers.*.registry | [0] }}/{{ images.containers.*.name | [0] }}deny:conditions:any:- key: "{{ images.containers.*.registry | [0] }}/{{ images.containers.*.name | [0] }}"operator: AnyNotInvalue: "{{ saMap.data.\"{{ request.object.spec.serviceAccountName }}\" }}"
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.