Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enforce-gateway-nomenclature tetrate policy #189

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: enforce-gateway-nomenclature
annotations:
policies.kyverno.io/title: Enforce Gateway Nomenclature
policies.kyverno.io/category: Istio Best Practices
policies.kyverno.io/severity: medium
policies.kyverno.io/subject: VirtualService
policies.kyverno.io/description: >-
The preferred Istio nomenclature for referencing gateways is [gateway namespace]/[gateway name],
which provides clarity and avoids conflicts when gateways with the same name exist in different namespaces.
spec:
validationFailureAction: Enforce
rules:
- name: enforce-gateway-format
match:
any:
- resources:
kinds:
- VirtualService
validate:
message: "Gateways in VirtualService must follow the format: [namespace]/[gateway name]."
pattern:
spec:
gateways:
- "*/*"
19 changes: 19 additions & 0 deletions tetrate/enforce-gateway-nomenclature/resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: bad-virtual-service
spec:
hosts:
- "my-app.example.com"
gateways:
- "my-gateway"
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: good-virtual-service
spec:
hosts:
- "my-app.example.com"
gateways:
- "example-namespace/my-gateway"