Naming patterns are commonplace in clusters where creation activities are granted to other users. In order to maintain organization, it is often such that patterns should be established for organizational consistency. This policy denies the creation of a Namespace if the name of the Namespace does not follow a specific naming defined by the cluster admins.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: team-validate-ns-nameannotations:policies.kyverno.io/title: Validate Team Namespace Schemapolicies.kyverno.io/category: OpenShiftpolicies.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: Namespacepolicies.kyverno.io/description: Naming patterns are commonplace in clusters where creation activities are granted to other users. In order to maintain organization, it is often such that patterns should be established for organizational consistency. This policy denies the creation of a Namespace if the name of the Namespace does not follow a specific naming defined by the cluster admins.spec:validationFailureAction: Auditbackground: falserules:- name: team-validate-ns-namematch:any:- resources:kinds:- Namespace- ProjectRequest- Projectvalidate:message: The only names approved for your Namespaces are the ones starting by {{request.userInfo.groups[?contains(@,':') == `false`]}}-*deny:conditions:any:- key: "{{request.object.metadata.name}}"operator: AnyNotInvalue: "{{ request.userInfo.groups[?contains(@,':') == `false`][].join('-', [@, '*']) }}"
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.