Files
Homelabv4/infrastructure/kyverno/policies/disallow-nodeport.yaml
T
2026-03-09 20:21:35 -05:00

30 lines
747 B
YAML

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-nodeport-services
annotations:
policies.kyverno.io/title: Disallow NodePort Services
policies.kyverno.io/category: Zero Trust
policies.kyverno.io/severity: medium
spec:
validationFailureAction: Enforce
background: true
rules:
- name: disallow-nodeport
match:
any:
- resources:
kinds:
- Service
exclude:
any:
- resources:
namespaces:
- kube-system
- istio-system
validate:
message: "NodePort services are not allowed. Use ClusterIP or LoadBalancer."
pattern:
spec:
type: "!NodePort"