In some cases a validation check for one type of resource may need to take into consideration the requesting user's permissions on a different type of resource. Rather than parsing through all Roles and/or ClusterRoles to check if these permissions are held, Kyverno can perform a SubjectAccessReview request to the Kubernetes API server and have it figure out those permissions. This policy illustrates how to perform a POST request to the API server to subject a SubjectAccessReview for a user creating/updating a ConfigMap. It is intended to be used as a component in a more functional rule.
apiVersion: kyverno.io/v2beta1kind: ClusterPolicymetadata:name: check-subjectaccessreviewannotations:policies.kyverno.io/title: Check SubjectAccessReviewpolicies.kyverno.io/category: Otherpolicies.kyverno.io/subject: SubjectAccessReviewkyverno.io/kyverno-version: 1.10.0policies.kyverno.io/minversion: 1.10.0kyverno.io/kubernetes-version: "1.26"policies.kyverno.io/description: In some cases a validation check for one type of resource may need to take into consideration the requesting user's permissions on a different type of resource. Rather than parsing through all Roles and/or ClusterRoles to check if these permissions are held, Kyverno can perform a SubjectAccessReview request to the Kubernetes API server and have it figure out those permissions. This policy illustrates how to perform a POST request to the API server to subject a SubjectAccessReview for a user creating/updating a ConfigMap. It is intended to be used as a component in a more functional rule.spec:validationFailureAction: Auditbackground: falserules:- name: check-sarmatch:any:- resources:kinds:- ConfigMapcontext:- name: subjectaccessreviewapiCall:urlPath: /apis/authorization.k8s.io/v1/subjectaccessreviewsmethod: POSTdata:- key: kindvalue: SubjectAccessReview- key: apiVersionvalue: authorization.k8s.io/v1- key: specvalue:resourceAttributes:resource: namespacesnamespace: "{{ request.namespace }}"verb: deletegroup: ""user: "{{ request.userInfo.username }}"validate:message: User is not authorized.deny:conditions:any:- key: "{{ subjectaccessreview.status.allowed }}"operator: NotEqualsvalue: true
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.