From eaf846090b55b11a7092fe950f2c2f5a72d34830 Mon Sep 17 00:00:00 2001 From: lou-lan Date: Tue, 7 Nov 2023 18:48:33 +0800 Subject: [PATCH] Update validation of egress gateway (#943) --- pkg/egressgateway/egress_gateway_webhook.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/egressgateway/egress_gateway_webhook.go b/pkg/egressgateway/egress_gateway_webhook.go index ddc120b36..7b9e380eb 100644 --- a/pkg/egressgateway/egress_gateway_webhook.go +++ b/pkg/egressgateway/egress_gateway_webhook.go @@ -61,6 +61,11 @@ func (egw *EgressGatewayWebhook) EgressGatewayValidate(ctx context.Context, req return webhook.Denied(fmt.Sprintf("json unmarshal EgressGateway with error: %v", err)) } + if newEg.Spec.NodeSelector.Selector == nil || + (len(newEg.Spec.NodeSelector.Selector.MatchLabels) == 0 && len(newEg.Spec.NodeSelector.Selector.MatchExpressions) == 0) { + return webhook.Denied("The field spec.nodeSelector.selector is not set") + } + if egw.Config.FileConfig.EnableIPv4 && !egw.Config.FileConfig.EnableIPv6 { if len(newEg.Spec.Ippools.IPv6) != 0 { return webhook.Denied("Please do not configure spec.ippools.ipv6, as the current installation settings have not enabled IPv6")