Adding capabilities is a way for containers in a Pod to request higher levels of ability than those with which they may be provisioned. Many capabilities allow system-level control and should be prevented. Pod Security Policies (PSP) allowed a list of "good" capabilities to be added. This policy checks ephemeralContainers, initContainers, and containers to ensure the only capabilities that can be added are either NET_BIND_SERVICE or CAP_CHOWN.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: psp-restrict-adding-capabilitiesannotations:policies.kyverno.io/title: Restrict Adding Capabilitiespolicies.kyverno.io/category: PSP Migrationpolicies.kyverno.io/severity: mediumkyverno.io/kyverno-version: 1.6.0policies.kyverno.io/minversion: 1.6.0kyverno.io/kubernetes-version: "1.23"policies.kyverno.io/subject: Podpolicies.kyverno.io/description: Adding capabilities is a way for containers in a Pod to request higher levels of ability than those with which they may be provisioned. Many capabilities allow system-level control and should be prevented. Pod Security Policies (PSP) allowed a list of "good" capabilities to be added. This policy checks ephemeralContainers, initContainers, and containers to ensure the only capabilities that can be added are either NET_BIND_SERVICE or CAP_CHOWN.spec:validationFailureAction: Auditbackground: truerules:- name: allowed-capabilitiesmatch:any:- resources:kinds:- Podpreconditions:all:- key: "{{ request.operation || 'BACKGROUND' }}"operator: NotEqualsvalue: DELETEvalidate:message: Any capabilities added other than NET_BIND_SERVICE or CAP_CHOWN are disallowed.foreach:- list: request.object.spec.[ephemeralContainers, initContainers, containers][]deny:conditions:all:- key: "{{ element.securityContext.capabilities.add[] || '' }}"operator: AnyNotInvalue:- NET_BIND_SERVICE- CAP_CHOWN- ""
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.