Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add external traffic policy for gw2 gw params #10420

Merged
merged 59 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
9faf84e
add external traffic policy for gw2 gw params
kevin-shelaga Nov 28, 2024
0270141
fix missing bracket for gwp helm template
kevin-shelaga Dec 2, 2024
25c5c20
add missing value for docs gen
kevin-shelaga Dec 2, 2024
295afd2
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 2, 2024
25c3058
add description to helm values, add IF to service template
kevin-shelaga Dec 2, 2024
3c7c2a2
Merge branch 'gw2-externaltrafficpolicy' of https://github.com/solo-i…
kevin-shelaga Dec 2, 2024
d604eec
Adding changelog file to new location
Dec 2, 2024
ca84ee2
Deleting changelog file from old location
Dec 2, 2024
06f6301
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 2, 2024
66c5e75
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 2, 2024
cd03f53
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 4, 2024
f2a7b53
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 5, 2024
079682c
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 5, 2024
25c7e86
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 5, 2024
7e4319b
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 5, 2024
72241a7
Adding changelog file to new location
Dec 6, 2024
9ade27b
Deleting changelog file from old location
Dec 6, 2024
67c754f
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 7, 2024
44ba6e3
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 10, 2024
41d8403
Adding changelog file to new location
Dec 10, 2024
7bd43d9
Deleting changelog file from old location
Dec 10, 2024
7dcc023
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 11, 2024
2ed3297
Adding changelog file to new location
Dec 12, 2024
497470c
Deleting changelog file from old location
Dec 12, 2024
7854d44
Refactors TCPRoute e2e tests (#10418)
danehans Dec 2, 2024
434f3b3
attempt to deflake ggv2 setup test (#10410)
yuval-k Dec 2, 2024
602ab2a
Adding changelog file to new location
Dec 2, 2024
38ac7a6
Deleting changelog file from old location
Dec 2, 2024
a0179c7
Feat/large validation (#10417)
nfuden Dec 2, 2024
b687623
skip explicitly (#10426)
nfuden Dec 2, 2024
a003e70
.github: add v1.18.x to the nightly tests (#10429)
sam-heilbron Dec 3, 2024
6b1d334
Bump moby OSS 1.18 (#10435)
bewebi Dec 4, 2024
f6c6ecb
Docs - Deprecate aerospike (#10422)
Rachael-Graham Dec 4, 2024
fb061b3
multiarch updates (#10421)
rpunia1 Dec 5, 2024
ca7d880
Adds ReferenceGrant Tests for TCPRoute (#10419)
danehans Dec 5, 2024
b926308
Make cluster stats names more parseable (#10439)
jenshu Dec 5, 2024
0e11c88
Adding changelog file to new location
Dec 6, 2024
771b990
Deleting changelog file from old location
Dec 6, 2024
8a7d4a1
fix broken GA CI build (#10453)
rpunia1 Dec 6, 2024
0d81f42
Doc: watchNamespaceSelectors (#10447)
Rachael-Graham Dec 6, 2024
c6545eb
Eitanya/ai tracing (#10427)
EItanya Dec 10, 2024
9a09e43
Bumps Gateway API Dependencies (#10457)
danehans Dec 10, 2024
2d0b687
Adding changelog file to new location
Dec 10, 2024
391419d
Deleting changelog file from old location
Dec 10, 2024
17c4cda
don't attempt to read v1 DestinationRules when istio is too old (#10459)
stevenctl Dec 10, 2024
8135934
Additional CLI debug commands (#10450)
arianaw66 Dec 10, 2024
c40c7b4
Zero downtime upgrade test (#10436)
jenshu Dec 11, 2024
4bea7c7
Adding changelog file to new location
Dec 12, 2024
f0601c0
Deleting changelog file from old location
Dec 12, 2024
c4b7e72
Merge branch 'gw2-externaltrafficpolicy' of https://github.com/solo-i…
kevin-shelaga Dec 13, 2024
862d7d7
move to 1.19.0-beta3, address concerns with review
kevin-shelaga Dec 13, 2024
53359c5
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 13, 2024
686b160
code gen
kevin-shelaga Dec 13, 2024
1fd013d
Merge branch 'gw2-externaltrafficpolicy' of https://github.com/solo-i…
kevin-shelaga Dec 13, 2024
0aba5f3
fix deployer test
kevin-shelaga Dec 13, 2024
01818f0
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 27, 2024
5486cb3
fix tests
kevin-shelaga Dec 27, 2024
e51e26f
Merge branch 'gw2-externaltrafficpolicy' of github.com:solo-io/gloo i…
kevin-shelaga Dec 27, 2024
d946524
Merge branch 'main' into gw2-externaltrafficpolicy
kevin-shelaga Dec 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/v1.19.0-beta3/external-traffic-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: NEW_FEATURE
issueLink: https://github.com/k8sgateway/k8sgateway/issues/9879
resolvesIssue: true
description: >-
Add ability to configure proxy service External Traffic Policy via Gateway Params
Original file line number Diff line number Diff line change
Expand Up @@ -7735,6 +7735,13 @@ Resource Types:
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>externalTrafficPolicy</b></td>
<td>string</td>
<td>
<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>extraAnnotations</b></td>
<td>map[string]string</td>
Expand Down
5 changes: 3 additions & 2 deletions docs/content/reference/values.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
|kubeGateway.gatewayParameters.glooGateway.service.type|string|LoadBalancer|K8s service type. If set to null, a default of LoadBalancer will be imposed.|
|kubeGateway.gatewayParameters.glooGateway.service.extraLabels.NAME|string||Extra labels to add to the service.|
|kubeGateway.gatewayParameters.glooGateway.service.extraAnnotations.NAME|string||Extra annotations to add to the service.|
|kubeGateway.gatewayParameters.glooGateway.service.externalTrafficPolicy|string||Set the external traffic policy on the provisioned service.|
|kubeGateway.gatewayParameters.glooGateway.serviceAccount.extraLabels.NAME|string||Extra labels to add to the service account.|
|kubeGateway.gatewayParameters.glooGateway.serviceAccount.extraAnnotations.NAME|string||Extra annotations to add to the service account.|
|kubeGateway.gatewayParameters.glooGateway.sdsContainer.image.tag|string|<release_version, ex: 1.2.3>|The image tag for the container.|
Expand Down Expand Up @@ -1002,7 +1003,7 @@
|gatewayProxies.NAME.service.httpsNodePort|int||HTTPS nodeport for the gateway service if using type NodePort|
|gatewayProxies.NAME.service.clusterIP|string||static clusterIP (or `None`) when `gatewayProxies[].gatewayProxy.service.type` is `ClusterIP`|
|gatewayProxies.NAME.service.extraAnnotations.NAME|string|||
|gatewayProxies.NAME.service.externalTrafficPolicy|string|||
|gatewayProxies.NAME.service.externalTrafficPolicy|string||Set the external traffic policy on the provisioned service.|
|gatewayProxies.NAME.service.name|string||Custom name override for the service resource of the proxy|
|gatewayProxies.NAME.service.httpsFirst|bool||List HTTPS port before HTTP|
|gatewayProxies.NAME.service.loadBalancerIP|string||IP address of the load balancer|
Expand Down Expand Up @@ -1255,7 +1256,7 @@
|gatewayProxies.gatewayProxy.service.httpsNodePort|int||HTTPS nodeport for the gateway service if using type NodePort|
|gatewayProxies.gatewayProxy.service.clusterIP|string||static clusterIP (or `None`) when `gatewayProxies[].gatewayProxy.service.type` is `ClusterIP`|
|gatewayProxies.gatewayProxy.service.extraAnnotations.NAME|string|||
|gatewayProxies.gatewayProxy.service.externalTrafficPolicy|string|||
|gatewayProxies.gatewayProxy.service.externalTrafficPolicy|string||Set the external traffic policy on the provisioned service.|
|gatewayProxies.gatewayProxy.service.name|string||Custom name override for the service resource of the proxy|
|gatewayProxies.gatewayProxy.service.httpsFirst|bool||List HTTPS port before HTTP|
|gatewayProxies.gatewayProxy.service.loadBalancerIP|string||IP address of the load balancer|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,8 @@ spec:
properties:
clusterIP:
type: string
externalTrafficPolicy:
type: string
extraAnnotations:
additionalProperties:
type: string
Expand Down
9 changes: 5 additions & 4 deletions install/helm/gloo/generate/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,10 @@ type ProvisionedDeployment struct {
}

type ProvisionedService struct {
Type *string `json:"type,omitempty" desc:"K8s service type. If set to null, a default of LoadBalancer will be imposed."`
ExtraLabels map[string]string `json:"extraLabels,omitempty" desc:"Extra labels to add to the service."`
ExtraAnnotations map[string]string `json:"extraAnnotations,omitempty" desc:"Extra annotations to add to the service."`
Type *string `json:"type,omitempty" desc:"K8s service type. If set to null, a default of LoadBalancer will be imposed."`
ExtraLabels map[string]string `json:"extraLabels,omitempty" desc:"Extra labels to add to the service."`
ExtraAnnotations map[string]string `json:"extraAnnotations,omitempty" desc:"Extra annotations to add to the service."`
ExternalTrafficPolicy *string `json:"externalTrafficPolicy,omitempty" desc:"Set the external traffic policy on the provisioned service."`
}

type ProvisionedServiceAccount struct {
Expand Down Expand Up @@ -717,7 +718,7 @@ type GatewayProxyService struct {
HttpsNodePort *int `json:"httpsNodePort,omitempty" desc:"HTTPS nodeport for the gateway service if using type NodePort"`
ClusterIP *string "json:\"clusterIP,omitempty\" desc:\"static clusterIP (or `None`) when `gatewayProxies[].gatewayProxy.service.type` is `ClusterIP`\""
ExtraAnnotations map[string]string `json:"extraAnnotations,omitempty"`
ExternalTrafficPolicy *string `json:"externalTrafficPolicy,omitempty"`
ExternalTrafficPolicy *string `json:"externalTrafficPolicy,omitempty" desc:"Set the external traffic policy on the provisioned service."`
Name *string `json:"name,omitempty" desc:"Custom name override for the service resource of the proxy"`
HttpsFirst *bool `json:"httpsFirst,omitempty" desc:"List HTTPS port before HTTP"`
LoadBalancerIP *string `json:"loadBalancerIP,omitempty" desc:"IP address of the load balancer"`
Expand Down
3 changes: 3 additions & 0 deletions install/helm/gloo/templates/43-gatewayparameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ spec:
{{- end }}{{/* if $gg.service */}}
service:
type: {{ $serviceType }}
{{- with ($gg.service).externalTrafficPolicy }}
externalTrafficPolicy: {{ . }}
{{- end }}
{{- with ($gg.service).extraLabels }}
extraLabels:
{{- toYaml . | nindent 8 }}
Expand Down
4 changes: 4 additions & 0 deletions install/test/k8sgateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ var _ = Describe("Kubernetes Gateway API integration", func() {
fmt.Sprintf("kubeGateway.gatewayParameters.glooGateway.envoyContainer.resources.limits.cpu=%s", envoyLimits["cpu"].ToUnstructured()),
"kubeGateway.gatewayParameters.glooGateway.proxyDeployment.replicas=5",
"kubeGateway.gatewayParameters.glooGateway.service.type=ClusterIP",
"kubeGateway.gatewayParameters.glooGateway.service.externalTrafficPolicy=Local",
"kubeGateway.gatewayParameters.glooGateway.service.extraLabels.svclabel1=x",
"kubeGateway.gatewayParameters.glooGateway.service.extraAnnotations.svcanno1=y",
"kubeGateway.gatewayParameters.glooGateway.serviceAccount.extraLabels.label1=a",
Expand Down Expand Up @@ -246,6 +247,7 @@ var _ = Describe("Kubernetes Gateway API integration", func() {
Expect(gwpKube.GetSdsContainer().GetResources().Limits).To(matchers.ContainMapElements(sdsLimits))

Expect(*gwpKube.GetService().GetType()).To(Equal(corev1.ServiceTypeClusterIP))
Expect(gwpKube.GetService().GetExternalTrafficPolicy()).To(HaveValue(Equal(corev1.ServiceExternalTrafficPolicyLocal)))
Expect(gwpKube.GetService().GetExtraLabels()).To(matchers.ContainMapElements(map[string]string{"svclabel1": "x"}))
Expect(gwpKube.GetService().GetExtraAnnotations()).To(matchers.ContainMapElements(map[string]string{"svcanno1": "y"}))

Expand Down Expand Up @@ -282,6 +284,7 @@ var _ = Describe("Kubernetes Gateway API integration", func() {
"kubeGateway.gatewayParameters.glooGateway.envoyContainer.image.pullPolicy=Always",
"kubeGateway.gatewayParameters.glooGateway.proxyDeployment.replicas=5",
"kubeGateway.gatewayParameters.glooGateway.service.type=ClusterIP",
"kubeGateway.gatewayParameters.glooGateway.service.externalTrafficPolicy=Local",
"kubeGateway.gatewayParameters.glooGateway.service.extraLabels.svclabel1=a",
"kubeGateway.gatewayParameters.glooGateway.service.extraAnnotations.svcanno1=b",
"kubeGateway.gatewayParameters.glooGateway.serviceAccount.extraLabels.label1=a",
Expand Down Expand Up @@ -324,6 +327,7 @@ var _ = Describe("Kubernetes Gateway API integration", func() {
Expect(*gwpKube.GetSdsContainer().GetBootstrap().GetLogLevel()).To(Equal("debug"))

Expect(*gwpKube.GetService().GetType()).To(Equal(corev1.ServiceTypeClusterIP))
Expect(gwpKube.GetService().GetExternalTrafficPolicy()).To(HaveValue(Equal(corev1.ServiceExternalTrafficPolicyLocal)))
Expect(gwpKube.GetService().GetExtraLabels()).To(matchers.ContainMapElements(map[string]string{"svclabel1": "a"}))
Expect(gwpKube.GetService().GetExtraAnnotations()).To(matchers.ContainMapElements(map[string]string{"svcanno1": "b"}))

Expand Down
12 changes: 12 additions & 0 deletions projects/gateway2/api/v1alpha1/kube_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ type Service struct {
//
// +kubebuilder:validation:Optional
ExtraAnnotations map[string]string `json:"extraAnnotations,omitempty"`

// External Traffic Policy on the Service object.
//
// +kubebuilder:validation:Optional
ExternalTrafficPolicy *corev1.ServiceExternalTrafficPolicy `json:"externalTrafficPolicy,omitempty"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider setting the default value of this field for CRD validation purposes:

// +kubebuilder:default=Cluster

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to set a default? i think we should just leave it unset if user doesn't specify a value

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we want default values to be explicitly represented in our APIs (xref).

}

func (in *Service) GetType() *corev1.ServiceType {
Expand Down Expand Up @@ -126,6 +131,13 @@ func (in *Service) GetExtraAnnotations() map[string]string {
return in.ExtraAnnotations
}

func (in *Service) GetExternalTrafficPolicy() *corev1.ServiceExternalTrafficPolicy {
if in == nil {
return nil
}
return in.ExternalTrafficPolicy
}

type ServiceAccount struct {
// Additional labels to add to the ServiceAccount object metadata.
//
Expand Down
5 changes: 5 additions & 0 deletions projects/gateway2/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions projects/gateway2/deployer/deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ var _ = Describe("Deployer", func() {
ExtraAnnotations: map[string]string{
"foo": "bar",
},
ExternalTrafficPolicy: ptr.To(corev1.ServiceExternalTrafficPolicyCluster),
},
ServiceAccount: &gw2_v1alpha1.ServiceAccount{
ExtraLabels: map[string]string{
Expand Down Expand Up @@ -598,6 +599,7 @@ var _ = Describe("Deployer", func() {
ExtraAnnotations: map[string]string{
"override-foo": "override-bar",
},
ExternalTrafficPolicy: ptr.To(corev1.ServiceExternalTrafficPolicyLocal),
},
ServiceAccount: &gw2_v1alpha1.ServiceAccount{
ExtraLabels: map[string]string{
Expand Down Expand Up @@ -665,6 +667,7 @@ var _ = Describe("Deployer", func() {
"foo": "bar",
"override-foo": "override-bar",
},
ExternalTrafficPolicy: ptr.To(corev1.ServiceExternalTrafficPolicyLocal),
},
ServiceAccount: &gw2_v1alpha1.ServiceAccount{
ExtraLabels: map[string]string{
Expand Down Expand Up @@ -832,6 +835,7 @@ var _ = Describe("Deployer", func() {
Expect(svc.GetLabels()).To(matchers.ContainMapElements(expectedGwp.Service.ExtraLabels))
Expect(svc.Spec.Type).To(Equal(*expectedGwp.Service.Type))
Expect(svc.Spec.ClusterIP).To(Equal(*expectedGwp.Service.ClusterIP))
Expect(svc.Spec.ExternalTrafficPolicy).To(Equal(*expectedGwp.Service.ExternalTrafficPolicy))

sa := objs.findServiceAccount(defaultNamespace, defaultServiceAccountName)
Expect(sa).ToNot(BeNil())
Expand Down Expand Up @@ -948,6 +952,7 @@ var _ = Describe("Deployer", func() {
Expect(svc.GetLabels()).To(matchers.ContainMapElements(expectedGwp.Service.ExtraLabels))
Expect(svc.Spec.Type).To(Equal(*expectedGwp.Service.Type))
Expect(svc.Spec.ClusterIP).To(Equal(*expectedGwp.Service.ClusterIP))
Expect(svc.Spec.ExternalTrafficPolicy).To(Equal(*expectedGwp.Service.ExternalTrafficPolicy))

sa := objs.findServiceAccount(defaultNamespace, defaultServiceAccountName)
Expect(sa).ToNot(BeNil())
Expand Down Expand Up @@ -1552,6 +1557,7 @@ func fullyDefinedGatewayParameters(name, namespace string) *gw2_v1alpha1.Gateway
ExtraLabels: map[string]string{
"service-label": "foo",
},
ExternalTrafficPolicy: ptr.To(corev1.ServiceExternalTrafficPolicyLocal),
},
ServiceAccount: &gw2_v1alpha1.ServiceAccount{
ExtraLabels: map[string]string{
Expand Down
4 changes: 4 additions & 0 deletions projects/gateway2/deployer/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ func deepMergeService(dst, src *v1alpha1.Service) *v1alpha1.Service {
dst.ExtraLabels = deepMergeMaps(dst.GetExtraLabels(), src.GetExtraLabels())
dst.ExtraAnnotations = deepMergeMaps(dst.GetExtraAnnotations(), src.GetExtraAnnotations())

if src.GetExternalTrafficPolicy() != nil {
dst.ExternalTrafficPolicy = src.GetExternalTrafficPolicy()
}

return dst
}

Expand Down
26 changes: 26 additions & 0 deletions projects/gateway2/deployer/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
gw2_v1alpha1 "github.com/solo-io/gloo/projects/gateway2/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"
)

Expand Down Expand Up @@ -134,4 +135,29 @@ var _ = Describe("deepMergeGatewayParameters", func() {
Expect(out.Spec.Kube.ServiceAccount.ExtraLabels).To(Equal(expectedMap))
Expect(out.Spec.Kube.ServiceAccount.ExtraAnnotations).To(Equal(expectedMap))
})

It("merges service strings", func() {

dst := &gw2_v1alpha1.GatewayParameters{
Spec: gw2_v1alpha1.GatewayParametersSpec{
Kube: &gw2_v1alpha1.KubernetesProxyConfig{
Service: &gw2_v1alpha1.Service{
ExternalTrafficPolicy: ptr.To(corev1.ServiceExternalTrafficPolicyLocal),
},
},
},
}
src := &gw2_v1alpha1.GatewayParameters{
Spec: gw2_v1alpha1.GatewayParametersSpec{
Kube: &gw2_v1alpha1.KubernetesProxyConfig{
Service: &gw2_v1alpha1.Service{
ExternalTrafficPolicy: ptr.To(corev1.ServiceExternalTrafficPolicyCluster),
},
},
},
}

out := deepMergeGatewayParameters(dst, src)
Expect(out.Spec.Kube.Service.ExternalTrafficPolicy).To(Equal(ptr.To(corev1.ServiceExternalTrafficPolicyCluster)))
})
})
9 changes: 5 additions & 4 deletions projects/gateway2/deployer/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ type helmImage struct {
}

type helmService struct {
Type *string `json:"type,omitempty"`
ClusterIP *string `json:"clusterIP,omitempty"`
ExtraAnnotations map[string]string `json:"extraAnnotations,omitempty"`
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
Type *string `json:"type,omitempty"`
ClusterIP *string `json:"clusterIP,omitempty"`
ExtraAnnotations map[string]string `json:"extraAnnotations,omitempty"`
ExtraLabels map[string]string `json:"extraLabels,omitempty"`
ExternalTrafficPolicy *string `json:"externalTrafficPolicy,omitempty"`
}

type helmServiceAccount struct {
Expand Down
13 changes: 9 additions & 4 deletions projects/gateway2/deployer/values_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ func getServiceValues(svcConfig *v1alpha1.Service) *helmService {
if svcConfig.GetType() != nil {
svcType = ptr.To(string(*svcConfig.GetType()))
}
var svcExternalTrafficPolicy *string
if svcConfig.GetExternalTrafficPolicy() != nil {
svcExternalTrafficPolicy = ptr.To(string(*svcConfig.GetExternalTrafficPolicy()))
}
return &helmService{
Type: svcType,
ClusterIP: svcConfig.GetClusterIP(),
ExtraAnnotations: svcConfig.GetExtraAnnotations(),
ExtraLabels: svcConfig.GetExtraLabels(),
Type: svcType,
ClusterIP: svcConfig.GetClusterIP(),
ExtraAnnotations: svcConfig.GetExtraAnnotations(),
ExtraLabels: svcConfig.GetExtraLabels(),
ExternalTrafficPolicy: svcExternalTrafficPolicy,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ metadata:
{{- end }}
spec:
type: {{ $gateway.service.type }}
{{- if $gateway.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ $gateway.service.externalTrafficPolicy }}
{{- end }}
{{- with $gateway.service.clusterIP }}
clusterIP: {{ . }}
{{- end }}
Expand Down
9 changes: 9 additions & 0 deletions test/kubernetes/e2e/features/deployer/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ func (s *testingSuite) TestConfigureProxiesFromGatewayParameters() {
s.testInstallation.Assertions.Gomega.Expect(svc.GetAnnotations()).To(
gomega.HaveKeyWithValue("svc-anno-key", "svc-anno-val"))

// check that external traffic policy got passwed through from GatewayParameters to the Service
s.testInstallation.Assertions.Gomega.Expect(svc.Spec.ExternalTrafficPolicy).To(
gomega.Equal(corev1.ServiceExternalTrafficPolicyCluster))

// Update the Gateway to use the custom GatewayParameters
gwName := types.NamespacedName{Name: gw.Name, Namespace: gw.Namespace}
err = s.testInstallation.ClusterContext.Client.Get(s.ctx, gwName, gw)
Expand Down Expand Up @@ -181,6 +185,11 @@ func (s *testingSuite) TestProvisionResourcesUpdatedWithValidParameters() {
// the GatewayParameters modification should cause the deployer to re-run and update the
// deployment to have 2 replicas
s.testInstallation.Assertions.EventuallyRunningReplicas(s.ctx, proxyDeployment.ObjectMeta, gomega.Equal(2))

// modify the external traffic policy in the GatewayParameters
s.patchGatewayParameters(gwParamsDefault.ObjectMeta, func(parameters *v1alpha1.GatewayParameters) {
parameters.Spec.Kube.Service.ExternalTrafficPolicy = ptr.To(corev1.ServiceExternalTrafficPolicyLocal)
})
}

func (s *testingSuite) TestProvisionResourcesNotUpdatedWithInvalidParameters() {
Expand Down