70 lines
2 KiB
YAML
70 lines
2 KiB
YAML
apiVersion: kyverno.io/v1
|
|
kind: ClusterPolicy
|
|
metadata:
|
|
name: require-app-labels
|
|
annotations:
|
|
policies.kyverno.io/title: Require application identity labels
|
|
policies.kyverno.io/category: Best Practices
|
|
policies.kyverno.io/severity: medium
|
|
policies.kyverno.io/description: >-
|
|
Require application name and instance labels, accepting Dragonfly's native
|
|
app identity in its namespace.
|
|
spec:
|
|
validationFailureAction: Enforce
|
|
background: true
|
|
rules:
|
|
- name: require-app-name-and-instance
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
exclude:
|
|
any:
|
|
- resources:
|
|
namespaces:
|
|
- kube-system
|
|
- kube-public
|
|
- kube-node-lease
|
|
- flux-system
|
|
- flux-canary
|
|
- kyverno
|
|
- cert-manager
|
|
- cilium-secrets
|
|
- olm
|
|
- operators
|
|
- longhorn
|
|
- openebs
|
|
- intel-system
|
|
- nfd
|
|
- dragonfly
|
|
validate:
|
|
message: >-
|
|
Pod must have non-empty labels app.kubernetes.io/name and
|
|
app.kubernetes.io/instance for Cilium and operational selectors.
|
|
pattern:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: "?*"
|
|
app.kubernetes.io/instance: "?*"
|
|
- name: dragonfly-identity
|
|
match:
|
|
any:
|
|
- resources:
|
|
kinds:
|
|
- Pod
|
|
namespaces:
|
|
- dragonfly
|
|
validate:
|
|
message: >-
|
|
Pods require name and instance labels; Dragonfly cache Pods may use
|
|
their native app label as the instance identity.
|
|
anyPattern:
|
|
- metadata:
|
|
labels:
|
|
app.kubernetes.io/name: "?*"
|
|
app.kubernetes.io/instance: "?*"
|
|
- metadata:
|
|
labels:
|
|
app.kubernetes.io/name: dragonfly
|
|
app: "?*"
|