Skip to content

Commit edf1b78

Browse files
authored
Merge branch 'main' into dataplane-nodeport
2 parents e45b17a + 5516989 commit edf1b78

File tree

9 files changed

+120
-10
lines changed

9 files changed

+120
-10
lines changed

.tools_versions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ gotestsum: "1.12.1"
1515
# renovate: datasource=github-releases depName=elastic/crd-ref-docs
1616
crd-ref-docs: "0.1.0"
1717
# renovate: datasource=github-releases depName=vektra/mockery
18-
mockery: "3.2.2"
18+
mockery: "3.2.3"
1919
# renovate: datasource=github-releases depName=kubernetes-sigs/controller-runtime
2020
setup-envtest: "0.20.4"
2121
# renovate: datasource=github-releases depName=rhysd/actionlint

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
- Bump default `DataPlane` image to 3.10
6666
Default image changes from `kong` to `kong/kong-gateway`.
6767
[#1405](https://github.com/Kong/gateway-operator/pull/1405)
68+
- Updated `kubernetes-configuration` dependency for adding `scale` subresource for `DataPlane` CRD.
69+
[#1523](https://github.com/Kong/gateway-operator/pull/1523)
6870

6971
### Fixes
7072

@@ -74,6 +76,8 @@
7476
[#1395](https://github.com/Kong/gateway-operator/pull/1395)
7577
- Fix ingress service name not being applied when using `GatewayConfiguration`.
7678
[#1515](https://github.com/Kong/gateway-operator/pull/1515)
79+
- Fix ingress service port name setting.
80+
[#1524](https://github.com/Kong/gateway-operator/pull/1524)
7781

7882
## [v1.5.1]
7983

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Builder
33
# ------------------------------------------------------------------------------
44

5-
FROM --platform=$BUILDPLATFORM golang:1.24.2@sha256:1ecc479bc712a6bdb56df3e346e33edcc141f469f82840bab9f4bc2bc41bf91d AS builder
5+
FROM --platform=$BUILDPLATFORM golang:1.24.2@sha256:d9db32125db0c3a680cfb7a1afcaefb89c898a075ec148fdc2f0f646cc2ed509 AS builder
66

77
WORKDIR /workspace
88
ARG GOPATH

controller/dataplane/owned_resources_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func TestEnsureIngressServiceForDataPlane(t *testing.T) {
166166
expectedServiceType: corev1.ServiceTypeLoadBalancer,
167167
expectedServicePorts: []corev1.ServicePort{
168168
{
169-
Name: "port-8080",
169+
Name: "http",
170170
Port: 8080,
171171
TargetPort: intstr.FromInt(8000),
172172
Protocol: corev1.ProtocolTCP,

debug.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Debug image
33
# ------------------------------------------------------------------------------
44

5-
FROM --platform=$BUILDPLATFORM golang:1.24.2@sha256:1ecc479bc712a6bdb56df3e346e33edcc141f469f82840bab9f4bc2bc41bf91d AS debug
5+
FROM --platform=$BUILDPLATFORM golang:1.24.2@sha256:d9db32125db0c3a680cfb7a1afcaefb89c898a075ec148fdc2f0f646cc2ed509 AS debug
66

77
ARG GOPATH
88
ARG GOCACHE

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,6 @@ github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zt
309309
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
310310
github.com/kong/go-kong v0.65.1 h1:CM+8NlF+VbJckTxP2hGmSPKhA1GMliitXjQ7vJiPkaE=
311311
github.com/kong/go-kong v0.65.1/go.mod h1:sqdysTKrXIJ6mpxHwTwjgZhLW7jR1/puczTXHLUwJaE=
312-
github.com/kong/kubernetes-configuration v1.3.2-0.20250418121302-ae2932af9c0d h1:0ArTLuANecKiI9/B5+Fxf80And1T1nb+pyob+l1LuVQ=
313-
github.com/kong/kubernetes-configuration v1.3.2-0.20250418121302-ae2932af9c0d/go.mod h1:3p31CROMO9LZmAB18Udn0luTPl/xu5XLls6DQj4IjB4=
314312
github.com/kong/kubernetes-configuration v1.3.2-0.20250422040405-9a4e025f1ccb h1:jQCvZ7rKYcYLLSR7QXmwpGKIK8j3P7mBYARP8WHYVf8=
315313
github.com/kong/kubernetes-configuration v1.3.2-0.20250422040405-9a4e025f1ccb/go.mod h1:3p31CROMO9LZmAB18Udn0luTPl/xu5XLls6DQj4IjB4=
316314
github.com/kong/kubernetes-telemetry v0.1.9 h1:XbDMZjZZclHO4oyJGW1mmZ6bzbTnANjcRAYsBg+jpno=

pkg/utils/kubernetes/resources/services.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func ServicePortsFromDataPlaneIngressOpt(dataplane *operatorv1beta1.DataPlane) S
145145
len(dataplane.Spec.Network.Services.Ingress.Ports) == 0 {
146146
return
147147
}
148-
newPorts := make([]corev1.ServicePort, 0)
148+
newPorts := make([]corev1.ServicePort, 0, len(dataplane.Spec.Network.Services.Ingress.Ports))
149149
alreadyUsedPorts := make(map[int32]struct{})
150150
for _, p := range dataplane.Spec.Network.Services.Ingress.Ports {
151151
targetPort := intstr.FromInt(consts.DataPlaneProxyPort)
@@ -154,9 +154,8 @@ func ServicePortsFromDataPlaneIngressOpt(dataplane *operatorv1beta1.DataPlane) S
154154
}
155155
if _, ok := alreadyUsedPorts[p.Port]; !ok {
156156
newPorts = append(newPorts, corev1.ServicePort{
157-
// Currently, only TCP protocol supported.
158-
Name: fmt.Sprintf("port-%d", p.Port),
159-
Protocol: corev1.ProtocolTCP,
157+
Name: p.Name,
158+
Protocol: corev1.ProtocolTCP, // Currently, only TCP protocol supported.
160159
Port: p.Port,
161160
TargetPort: targetPort,
162161
NodePort: p.NodePort,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package integration
2+
3+
import (
4+
"testing"
5+
6+
"github.com/samber/lo"
7+
"github.com/stretchr/testify/require"
8+
appsv1 "k8s.io/api/apps/v1"
9+
corev1 "k8s.io/api/core/v1"
10+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
"sigs.k8s.io/controller-runtime/pkg/client"
12+
13+
"github.com/kong/gateway-operator/pkg/consts"
14+
testutils "github.com/kong/gateway-operator/pkg/utils/test"
15+
"github.com/kong/gateway-operator/test/helpers"
16+
17+
operatorv1beta1 "github.com/kong/kubernetes-configuration/api/gateway-operator/v1beta1"
18+
)
19+
20+
// TestDataPlaneScaleSubresource tests the scale subresource of the DataPlane CRD.
21+
// It verifies that when a deployment is restarted using kubectl rollout restart,
22+
// the new ReplicaSet maintains the correct replica count.
23+
func TestDataPlaneScaleSubresource(t *testing.T) {
24+
t.Parallel()
25+
26+
namespace, cleaner := helpers.SetupTestEnv(t, GetCtx(), GetEnv())
27+
clients := GetClients()
28+
29+
t.Log("deploying dataplane resource with 2 replicas")
30+
dataplane := &operatorv1beta1.DataPlane{
31+
ObjectMeta: metav1.ObjectMeta{
32+
Namespace: namespace.Name,
33+
GenerateName: "dataplane-scale-test-",
34+
},
35+
Spec: operatorv1beta1.DataPlaneSpec{
36+
DataPlaneOptions: operatorv1beta1.DataPlaneOptions{
37+
Deployment: operatorv1beta1.DataPlaneDeploymentOptions{
38+
DeploymentOptions: operatorv1beta1.DeploymentOptions{
39+
Replicas: lo.ToPtr(int32(2)), // Set initial replica count to 2
40+
PodTemplateSpec: &corev1.PodTemplateSpec{
41+
ObjectMeta: metav1.ObjectMeta{
42+
Labels: map[string]string{
43+
"label-a": "value-a",
44+
"label-x": "value-x",
45+
},
46+
},
47+
Spec: corev1.PodSpec{
48+
Containers: []corev1.Container{
49+
{
50+
Env: []corev1.EnvVar{
51+
{
52+
Name: "TEST_ENV",
53+
Value: "test",
54+
},
55+
},
56+
Name: consts.DataPlaneProxyContainerName,
57+
Image: helpers.GetDefaultDataPlaneImage(),
58+
},
59+
},
60+
},
61+
},
62+
},
63+
},
64+
Network: operatorv1beta1.DataPlaneNetworkOptions{
65+
Services: &operatorv1beta1.DataPlaneServices{
66+
Ingress: &operatorv1beta1.DataPlaneServiceOptions{
67+
ServiceOptions: operatorv1beta1.ServiceOptions{
68+
Annotations: map[string]string{
69+
"purpose": "scale",
70+
},
71+
},
72+
},
73+
},
74+
},
75+
},
76+
},
77+
}
78+
79+
dataplaneClient := clients.OperatorClient.GatewayOperatorV1beta1().DataPlanes(namespace.Name)
80+
dataplane, err := dataplaneClient.Create(GetCtx(), dataplane, metav1.CreateOptions{})
81+
require.NoError(t, err)
82+
cleaner.Add(dataplane)
83+
84+
dataplaneName := client.ObjectKeyFromObject(dataplane)
85+
86+
t.Log("verifying dataplane gets marked ready")
87+
require.Eventually(t, testutils.DataPlaneIsReady(t, GetCtx(), dataplaneName, clients.OperatorClient), testutils.GatewayReadyTimeLimit, testutils.ObjectUpdateTick)
88+
89+
t.Log("verifying dataplane has 2 ready replicas")
90+
require.Eventually(t, testutils.DataPlaneHasNReadyPods(t, GetCtx(), dataplaneName, clients, 2), testutils.GatewayReadyTimeLimit, testutils.ObjectUpdateTick)
91+
92+
// Get the deployment created by the dataplane controller
93+
var deployment appsv1.Deployment
94+
require.Eventually(t, testutils.DataPlaneHasActiveDeployment(t, GetCtx(), dataplaneName, &deployment, client.MatchingLabels{
95+
consts.GatewayOperatorManagedByLabel: consts.DataPlaneManagedLabelValue,
96+
}, clients), testutils.GatewayReadyTimeLimit, testutils.ObjectUpdateTick)
97+
98+
// Test scaling through the scale subresource
99+
t.Log("testing scaling through scale subresource")
100+
require.Eventually(t,
101+
testutils.DataPlaneUpdateEventually(t, GetCtx(), dataplaneName, clients, func(dp *operatorv1beta1.DataPlane) {
102+
dp.Spec.Deployment.Replicas = lo.ToPtr(int32(3)) // Scale up to 3 replicas
103+
}),
104+
testutils.GatewayReadyTimeLimit, testutils.ObjectUpdateTick)
105+
106+
t.Log("verifying dataplane scales to 3 replicas")
107+
require.Eventually(t, testutils.DataPlaneHasNReadyPods(t, GetCtx(), dataplaneName, clients, 3), testutils.GatewayReadyTimeLimit, testutils.ObjectUpdateTick)
108+
}

test/integration/zz_generated.registered_testcases.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)