Skip to content

Commit f40d935

Browse files
sheidkampsoloio-bulldozer[bot]sam-heilbronNadine2016jenshu
authored
Split webhook validation (#10284)
Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com> Co-authored-by: changelog-bot <changelog-bot> Co-authored-by: Sam Heilbron <[email protected]> Co-authored-by: Nadine Spies <[email protected]> Co-authored-by: Jenny Shu <[email protected]>
1 parent 2731f39 commit f40d935

File tree

20 files changed

+476
-44
lines changed

20 files changed

+476
-44
lines changed

.github/workflows/pr-kubernetes-tests.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ jobs:
7676
go-test-run-regex: '(^TestK8sGatewayIstio$$|^TestGlooGatewayEdgeGateway$$|^TestGlooctlIstioInjectEdgeApiGateway$$)'
7777

7878
# October 10, 2024: 22 minutes
79+
# TODO (sheidkamp) rebalance tests
7980
- cluster-name: 'cluster-five'
80-
go-test-args: '-v -timeout=25m'
81+
go-test-args: '-v -timeout=35m'
8182
go-test-run-regex: '^TestFullEnvoyValidation$$|^TestValidationStrict$$|^TestValidationAlwaysAccept$$|^TestTransformationValidationDisabled$$|^TestGloomtlsGatewayEdgeGateway$$|^TestWatchNamespaceSelector$$'
8283

8384
# October 10, 2024: 12 minutes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
changelog:
2+
- type: NEW_FEATURE
3+
issueLink: https://github.com/solo-io/gloo/issues/10247
4+
resolvesIssue: false
5+
description: >-
6+
Split the validating webhook to allow different failure policies for gloo/non-gloo resources.
7+
The split out webhook for kubernetes resources shares all configuration with the existing webhook except for the failure policy,
8+
which can be set with `gateway.validation.kubeCoreFailurePolicy`
9+
- type: DEPENDENCY_BUMP
10+
dependencyOwner: solo-io
11+
dependencyRepo: k8s-utils
12+
dependencyTag: v0.8.1
13+
description: >-
14+
Bump k8s-utils to v0.8.1 for updated `ConvertUnstructured` function

docs/content/reference/values.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@
569569
|gateway.validation.disableTransformationValidation|bool|false|set this to true to disable transformation validation. This may bring significant performance benefits if using many transformations, at the cost of possibly incorrect transformations being sent to Envoy. When using this value make sure to pre-validate transformations.|
570570
|gateway.validation.warnRouteShortCircuiting|bool|false|Write a warning to route resources if validation produced a route ordering warning (defaults to false). By setting to true, this means that Gloo Edge will start assigning warnings to resources that would result in route short-circuiting within a virtual host.|
571571
|gateway.validation.secretName|string|gateway-validation-certs|Name of the Kubernetes Secret containing TLS certificates used by the validation webhook server. This secret will be created by the certGen Job if the certGen Job is enabled.|
572-
|gateway.validation.failurePolicy|string|Ignore|failurePolicy defines how unrecognized errors from the Gateway validation endpoint are handled - allowed values are 'Ignore' or 'Fail'. Defaults to Ignore |
572+
|gateway.validation.failurePolicy|string|Ignore|Specify how to handle unrecognized errors for Gloo resources that are returned from the Gateway validation endpoint. Supported values are 'Ignore' or 'Fail'|
573+
|gateway.validation.kubeCoreFailurePolicy|string|Ignore|Specify how to handle unrecognized errors for Kubernetes core resources that are returned by the Gateway validation endpoint. Currently the [validation webhook](https://github.com/solo-io/gloo/blob/main/install/helm/gloo/templates/5-gateway-validation-webhook-configuration.yaml) is configured to handle errors for Kubernetes secrets and namespaces. Supported values are 'Ignore' or 'Fail'. If you set this value to 'Fail', you cannot modify these core resources if the 'gloo' service is unavailable.|
573574
|gateway.validation.webhook.enabled|bool|true|enable validation webhook (default true)|
574575
|gateway.validation.webhook.disableHelmHook|bool|false|do not create the webhook as helm hook (default false)|
575576
|gateway.validation.webhook.timeoutSeconds|int||the timeout for the webhook, defaults to 10|

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ require (
4949
github.com/sergi/go-diff v1.2.0
5050
github.com/solo-io/go-list-licenses v0.1.4
5151
github.com/solo-io/go-utils v0.27.1
52-
github.com/solo-io/k8s-utils v0.8.0
52+
github.com/solo-io/k8s-utils v0.8.1
5353
github.com/solo-io/protoc-gen-ext v0.0.25
5454
github.com/solo-io/protoc-gen-openapi v0.2.5
5555
github.com/solo-io/skv2 v0.41.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -2697,8 +2697,8 @@ github.com/solo-io/go-list-licenses v0.1.4/go.mod h1:x6LSp/NrYgVXwNum7ZOiaAYTpg6
26972697
github.com/solo-io/go-utils v0.20.2/go.mod h1:6e8K1spnMWwlnJRSNp/J84GEyJbrcK4Gm7i+ehzCi8c=
26982698
github.com/solo-io/go-utils v0.27.1 h1:14XwaKv21EaYYeUF2wFfPe3DPz2Gbm9sfenGv/aRIls=
26992699
github.com/solo-io/go-utils v0.27.1/go.mod h1:cwbQIYO1/BeU4aPB0Yy8WzzS77dfVTZyCVqbA4YsRSY=
2700-
github.com/solo-io/k8s-utils v0.8.0 h1:jXd4HFDgbPWxHi04QDFYwA37D1nYr9XJI3MVa75oCD8=
2701-
github.com/solo-io/k8s-utils v0.8.0/go.mod h1:fOIFkh4+F45MmrUZEFx0pW75EvFYOR7v5/BIIQiSIwA=
2700+
github.com/solo-io/k8s-utils v0.8.1 h1:Xqqze6RLWsHCYetbaiXDEnuhFRXyqw0azyogggK43H8=
2701+
github.com/solo-io/k8s-utils v0.8.1/go.mod h1:fOIFkh4+F45MmrUZEFx0pW75EvFYOR7v5/BIIQiSIwA=
27022702
github.com/solo-io/protoc-gen-ext v0.0.25 h1:UqNW/A4UqCO5aUFg7LYdV82tK0R2mqu7RFftYtT/Fu8=
27032703
github.com/solo-io/protoc-gen-ext v0.0.25/go.mod h1:TZwUhbFtfd1fQQGBN6qWwtea0Fhi3V6DvGQnbqk3jf8=
27042704
github.com/solo-io/protoc-gen-openapi v0.2.5 h1:l8YKsVks6JDFRzA9liYZIqauqpYRxHXnmHi4TjTIRf4=

install/helm/gloo/generate/values.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ type GatewayValidation struct {
479479
DisableTransformationValidation *bool `json:"disableTransformationValidation,omitempty" desc:"set this to true to disable transformation validation. This may bring significant performance benefits if using many transformations, at the cost of possibly incorrect transformations being sent to Envoy. When using this value make sure to pre-validate transformations."`
480480
WarnRouteShortCircuiting *bool `json:"warnRouteShortCircuiting,omitempty" desc:"Write a warning to route resources if validation produced a route ordering warning (defaults to false). By setting to true, this means that Gloo Edge will start assigning warnings to resources that would result in route short-circuiting within a virtual host."`
481481
SecretName *string `json:"secretName,omitempty" desc:"Name of the Kubernetes Secret containing TLS certificates used by the validation webhook server. This secret will be created by the certGen Job if the certGen Job is enabled."`
482-
FailurePolicy *string `json:"failurePolicy,omitempty" desc:"failurePolicy defines how unrecognized errors from the Gateway validation endpoint are handled - allowed values are 'Ignore' or 'Fail'. Defaults to Ignore "`
482+
FailurePolicy *string `json:"failurePolicy,omitempty" desc:"Specify how to handle unrecognized errors for Gloo resources that are returned from the Gateway validation endpoint. Supported values are 'Ignore' or 'Fail'"`
483+
KubeCoreFailurePolicy *string `json:"kubeCoreFailurePolicy,omitempty" desc:"Specify how to handle unrecognized errors for Kubernetes core resources that are returned by the Gateway validation endpoint. Currently the [validation webhook](https://github.com/solo-io/gloo/blob/main/install/helm/gloo/templates/5-gateway-validation-webhook-configuration.yaml) is configured to handle errors for Kubernetes secrets and namespaces. Supported values are 'Ignore' or 'Fail'. If you set this value to 'Fail', you cannot modify these core resources if the 'gloo' service is unavailable."`
483484
Webhook *Webhook `json:"webhook,omitempty" desc:"webhook specific configuration"`
484485
ValidationServerGrpcMaxSizeBytes *int `json:"validationServerGrpcMaxSizeBytes,omitempty" desc:"gRPC max message size in bytes for the gloo validation server"`
485486
LivenessProbeEnabled *bool `json:"livenessProbeEnabled,omitempty" desc:"Set to true to enable a liveness probe for the gateway (default is false). You must also set the 'Probes' value to true."`

install/helm/gloo/templates/5-gateway-validation-webhook-configuration.yaml

+37-10
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,36 @@ specific resources, we will manage the resources that the webhook receives via t
5252
apiGroups: ["gloo.solo.io"]
5353
apiVersions: ["v1"]
5454
resources: ["upstreams"]{{/* TODO(https://github.com/solo-io/gloo/issues/2797): Extend to all gloo resources */}}
55-
{{/* Can't use the include for this one because if the operations are empty, we need to drop the whole list element */}}
55+
- operations: {{ include "gloo.webhookvalidation.operationsForResource" (list "ratelimitconfigs" .Values.gateway.validation.webhook.skipDeleteValidationResources) }}
56+
apiGroups: ["ratelimit.solo.io"]
57+
apiVersions: ["v1alpha1"]
58+
resources: ["ratelimitconfigs"]
59+
sideEffects: None
60+
matchPolicy: Exact
61+
{{- if .Values.gateway.validation.webhook.timeoutSeconds }}
62+
timeoutSeconds: {{ .Values.gateway.validation.webhook.timeoutSeconds }}
63+
{{- end }}
64+
admissionReviewVersions:
65+
- v1beta1 # v1beta1 still live in 1.22 https://github.com/kubernetes/api/blob/release-1.22/admission/v1beta1/types.go#L33
66+
{{- if .Values.gateway.validation.failurePolicy }}
67+
failurePolicy: {{ .Values.gateway.validation.failurePolicy }}
68+
{{- end }} {{- /* if .Values.gateway.validation.failurePolicy */}}
69+
70+
{{/* Webhook for core resources - only render if we need to */}}
71+
{{- if and
72+
(not (has "*" .Values.gateway.validation.webhook.skipDeleteValidationResources))
73+
(or (not (has "secrets" .Values.gateway.validation.webhook.skipDeleteValidationResources))
74+
(not (has "namespaces" .Values.gateway.validation.webhook.skipDeleteValidationResources)))
75+
}}
76+
- name: kube.{{ .Release.Namespace }}.svc # must be a domain with at least three segments separated by dots
77+
clientConfig:
78+
service:
79+
name: gloo
80+
namespace: {{ .Release.Namespace }}
81+
path: "/validation"
82+
caBundle: "" # update manually or use certgen job or cert-manager's ca-injector
83+
rules:
84+
{{- /* Can't use the include for this one because if the operations are empty, we need to drop the whole list element */}}
5685
{{- if and (not (has "*" .Values.gateway.validation.webhook.skipDeleteValidationResources)) (not (has "secrets" .Values.gateway.validation.webhook.skipDeleteValidationResources)) }}
5786
- operations: [ "DELETE" ]
5887
apiGroups: [""]{{/* We do not have internal secret CRDs. We want to validate the deletion of secrets such as TLS, so we add "" which refers to Kubernetes' core APIs. */}}
@@ -66,20 +95,18 @@ specific resources, we will manage the resources that the webhook receives via t
6695
apiVersions: ["v1"]
6796
resources: ["namespaces"]
6897
{{- end }}
69-
- operations: {{ include "gloo.webhookvalidation.operationsForResource" (list "ratelimitconfigs" .Values.gateway.validation.webhook.skipDeleteValidationResources) }}
70-
apiGroups: ["ratelimit.solo.io"]
71-
apiVersions: ["v1alpha1"]
72-
resources: ["ratelimitconfigs"]
7398
sideEffects: None
7499
matchPolicy: Exact
75100
{{- if .Values.gateway.validation.webhook.timeoutSeconds }}
76101
timeoutSeconds: {{ .Values.gateway.validation.webhook.timeoutSeconds }}
77102
{{- end }}
78103
admissionReviewVersions:
79104
- v1beta1 # v1beta1 still live in 1.22 https://github.com/kubernetes/api/blob/release-1.22/admission/v1beta1/types.go#L33
80-
{{- if .Values.gateway.validation.failurePolicy }}
81-
failurePolicy: {{ .Values.gateway.validation.failurePolicy }}
82-
{{- end }} {{/* if .Values.gateway.validation.failurePolicy */}}
105+
{{- if .Values.gateway.validation.kubeCoreFailurePolicy }}
106+
failurePolicy: {{ .Values.gateway.validation.kubeCoreFailurePolicy -}}
107+
{{- end }} {{/* if .Values.gateway.validation.kubeCoreFailurePolicy */}}
108+
{{- end }} {{/* render webhook if */}}
109+
83110
{{- end }} {{/* if and .Values.gateway.enabled .Values.gateway.validation.enabled .Values.gateway.validation.webhook.enabled */}}
84111
{{- end }} {{/* define "gateway.validationWebhookSpec" */}}
85112

@@ -88,6 +115,6 @@ specific resources, we will manage the resources that the webhook receives via t
88115
{{- if .Values.gateway.validation -}}
89116
{{- if .Values.gateway.validation.webhook -}}
90117
{{- $kubeResourceOverride = .Values.gateway.validation.webhook.kubeResourceOverride -}}
91-
{{- end -}} {{/* if .Values.gateway.validation.webhook */}}
92-
{{- end -}} {{/* if .Values.gateway.validation */}}
118+
{{- end -}} {{/* if .Values.gateway.validation.webhook */ -}}
119+
{{- end -}} {{/* if .Values.gateway.validation */ -}}
93120
{{- include "gloo.util.merge" (list . $kubeResourceOverride "gateway.validationWebhookSpec") -}}

install/helm/gloo/values-template.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ gateway:
131131
validation:
132132
enabled: true
133133
failurePolicy: "Ignore"
134+
# This is the recommended setting because if it set to "Fail" modifications to core resources such as secrets and namespace that are defined
135+
# in the validating webhook will be blocked if the Gloo Service is not available.
136+
kubeCoreFailurePolicy: "Ignore"
134137
secretName: gateway-validation-certs
135138
alwaysAcceptResources: true
136139
allowWarnings: true

0 commit comments

Comments
 (0)