Skip to content

Commit

Permalink
Merge pull request #189 from mastersans/tetrate
Browse files Browse the repository at this point in the history
feat: enforce-gateway-nomenclature tetrate policy
  • Loading branch information
anusha94 authored Feb 25, 2025
2 parents 913cad6 + 3546919 commit 2385bb2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
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"

0 comments on commit 2385bb2

Please sign in to comment.