2019-10-10 10:34:49 -07:00
|
|
|
apiVersion: kyverno.io/v1alpha1
|
|
|
|
kind: ClusterPolicy
|
|
|
|
metadata:
|
|
|
|
name: validate-namespace
|
2019-10-11 18:57:16 -07:00
|
|
|
annotations:
|
|
|
|
policies.kyverno.io/category: Workload Isolation
|
2019-10-14 16:33:19 -07:00
|
|
|
policies.kyverno.io/description: With many users spread across multiple teams, restricting
|
|
|
|
use of the default namespace and subdividing the cluster by namesoace isolates workloads.
|
2019-10-10 10:34:49 -07:00
|
|
|
spec:
|
|
|
|
rules:
|
|
|
|
- name: check-default-namespace
|
|
|
|
match:
|
|
|
|
resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
|
|
|
validate:
|
2019-10-14 10:47:54 -07:00
|
|
|
message: "Using 'default' namespace is restricted"
|
2019-10-10 10:34:49 -07:00
|
|
|
pattern:
|
|
|
|
metadata:
|
|
|
|
namespace: "!default"
|
|
|
|
- name: check-namespace-exist
|
|
|
|
match:
|
|
|
|
resources:
|
|
|
|
kinds:
|
|
|
|
- Pod
|
|
|
|
validate:
|
|
|
|
message: "A namespace is required"
|
|
|
|
pattern:
|
|
|
|
metadata:
|
|
|
|
namespace: "?*"
|