-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from mastersans/tetrate
feat: enforce-gateway-nomenclature tetrate policy
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
tetrate/enforce-gateway-nomenclature/enforce-gateway-nomenclature.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
- "*/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |