Enable resource validation
Enable or disable resource validation in Gloo Gateway and view the current alidating admission webhook configuration.
View the current validating admission webhook configuration
You can check whether strict or permissive validation is enabled in your Gloo Gateway installation by checking the Settings resource.
Get the details of the default settings resource.
kubectl get settings default -n gloo-system -o yaml
In your CLI output, find the
spec.gateway.validation.alwaysAccept
setting.- If set to
true
, permissive mode is enabled in your Gloo Gateway setup and invalid Gloo resources are only logged, but not rejected. - If set to
false
, strict validation mode is enabled and invalid resource configuration is rejected before being applied in the cluster. - If
allowWarnings=false
is set alongsidealwaysAccept=false
, resources that result in aWarning
status are also rejected.
- If set to
Enable strict resource validation
Configure the validating admission webhook to reject invalid Gloo Gateway custom resources before they are applied in the cluster.
Enable strict resource validation. Resource validation is enabled by using the Settings resource in Gloo Gateway. You can update the Settings resource by editing it directly or by enabling it in your Gloo Gateway Helm installation.
Verify that the validating admission webhook is enabled.
Create a RouteOption resource with an invalid fault injection configuration. The following example aborts 50% of all incoming requests. However, no HTTP status code is defined.
kubectl apply -n httpbin -f- <<EOF apiVersion: gateway.solo.io/v1 kind: RouteOption metadata: name: faults namespace: httpbin spec: options: faults: abort: percentage: 50 # httpStatus: 503 EOF
Verify that the RouteOption resource is rejected. You see an error message similar to the following.
Error from server: error when creating "STDIN": admission webhook "gloo.gloo-system.svc" denied the request: resource incompatible with current Gloo snapshot: [Validating *v1.RouteOption failed: 1 error occurred: * Validating *v1.RouteOption failed: validating *v1.RouteOption name:"faults" namespace:"httpbin": 1 error occurred: * Route Error: ProcessingError. Reason: *faultinjection.plugin: invalid abort status code '0', must be in range of [200,600). Route Name:
You can also use the validating admission webhook by running thekubectl apply --dry-run=server
command to test your Gloo configuration before you apply it to your cluster. For more information, see Test resource configurations.
Disable resource validation
Because the validation admission webhook is set up automatically in Gloo Gateway, a ValidationWebhookConfiguration
resource is created in your cluster. You can disable the webhook, which prevents the ValidationWebhookConfiguration
resource from being created. When validation is disabled, any Gloo resources that you create in your cluster are translated to Envoy proxy config, even if the config has errors or warnings.
To disable validation, use the following --set
options during your Helm installation.
--set gateway.enabled=false
--set gateway.validation.enabled=false
--set gateway.validation.webhook.enabled=false