From 496d365a955ff09816e9c8d2f04442fe3f07e47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E8=B4=A4=E6=B6=9B?= <601803023@qq.com> Date: Thu, 24 Oct 2024 20:57:46 +0800 Subject: [PATCH] add PILOT_ENABLE_ALPHA_GATEWAY_API and fix gateway status update (#1421) --- helm/core/templates/controller-deployment.yaml | 6 ++++++ pkg/config/envs.go | 1 + pkg/ingress/kube/gateway/istio/conversion.go | 3 ++- pkg/ingress/kube/gateway/istio/conversion_test.go | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/helm/core/templates/controller-deployment.yaml b/helm/core/templates/controller-deployment.yaml index 98bfe8f6d..c3bc70aea 100644 --- a/helm/core/templates/controller-deployment.yaml +++ b/helm/core/templates/controller-deployment.yaml @@ -69,6 +69,10 @@ spec: fieldPath: spec.serviceAccountName - name: DOMAIN_SUFFIX value: {{ .Values.global.proxy.clusterDomain }} + - name: PILOT_ENABLE_ALPHA_GATEWAY_API + value: "true" + - name: GATEWAY_NAME + value: {{ include "gateway.name" . }} {{- if .Values.controller.env }} {{- range $key, $val := .Values.controller.env }} - name: {{ $key }} @@ -218,6 +222,8 @@ spec: {{- if .Values.global.enableGatewayAPI }} - name: PILOT_ENABLE_GATEWAY_API value: "true" + - name: PILOT_ENABLE_ALPHA_GATEWAY_API + value: "true" - name: PILOT_ENABLE_GATEWAY_API_STATUS value: "true" - name: PILOT_ENABLE_GATEWAY_API_DEPLOYMENT_CONTROLLER diff --git a/pkg/config/envs.go b/pkg/config/envs.go index 38ff64bf2..99a67edc6 100644 --- a/pkg/config/envs.go +++ b/pkg/config/envs.go @@ -19,6 +19,7 @@ import "istio.io/pkg/env" var ( PodNamespace = env.RegisterStringVar("POD_NAMESPACE", "higress-system", "").Get() PodName = env.RegisterStringVar("POD_NAME", "", "").Get() + GatewayName = env.RegisterStringVar("GATEWAY_NAME", "higress-gateway", "").Get() // Revision is the value of the Istio control plane revision, e.g. "canary", // and is the value used by the "istio.io/rev" label. Revision = env.Register("REVISION", "", "").Get() diff --git a/pkg/ingress/kube/gateway/istio/conversion.go b/pkg/ingress/kube/gateway/istio/conversion.go index 83c817a71..4cf5dee9e 100644 --- a/pkg/ingress/kube/gateway/istio/conversion.go +++ b/pkg/ingress/kube/gateway/istio/conversion.go @@ -25,6 +25,7 @@ import ( "strings" higressconfig "github.com/alibaba/higress/pkg/config" + "github.com/alibaba/higress/pkg/ingress/kube/util" istio "istio.io/api/networking/v1alpha3" "istio.io/istio/pilot/pkg/features" "istio.io/istio/pilot/pkg/model" @@ -1880,7 +1881,7 @@ func extractGatewayServices(r GatewayResources, kgw *k8s.GatewaySpec, obj config if len(name) > 0 { return []string{fmt.Sprintf("%s.%s.svc.%v", name, obj.Namespace, r.Domain)}, false, nil } - return []string{}, true, nil + return []string{fmt.Sprintf("%s.%s.svc.%s", higressconfig.GatewayName, higressconfig.PodNamespace, util.GetDomainSuffix())}, true, nil } gatewayServices := []string{} skippedAddresses := []string{} diff --git a/pkg/ingress/kube/gateway/istio/conversion_test.go b/pkg/ingress/kube/gateway/istio/conversion_test.go index 986aecbc6..28f8d2696 100644 --- a/pkg/ingress/kube/gateway/istio/conversion_test.go +++ b/pkg/ingress/kube/gateway/istio/conversion_test.go @@ -919,7 +919,7 @@ func TestExtractGatewayServices(t *testing.T) { Namespace: "default", }, }, - gatewayServices: []string{}, + gatewayServices: []string{"higress-gateway.higress-system.svc.cluster.local"}, useDefaultService: true, }, { @@ -1039,7 +1039,7 @@ func TestExtractGatewayServices(t *testing.T) { Namespace: "default", }, }, - gatewayServices: []string{}, + gatewayServices: []string{"higress-gateway.higress-system.svc.cluster.local"}, useDefaultService: true, }, }