Skip to content

Commit 03b6308

Browse files
committed
ci: test across several k8s versions
1 parent 5ec3f83 commit 03b6308

10 files changed

+72
-10
lines changed
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- node_image: kindest/node:v1.32.2@sha256:f226345927d7e348497136874b6d207e0b32cc52154ad8323129352923a3142f
2+
- node_image: kindest/node:v1.31.6@sha256:28b7cbb993dfe093c76641a0c95807637213c9109b761f1d422c2400e22b8e87
3+
- node_image: kindest/node:v1.30.10@sha256:4de75d0e82481ea846c0ed1de86328d821c1e6a6a91ac37bf804e5313670e507

.github/workflows/tests.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,28 @@ jobs:
106106

107107
- run: make lint
108108

109+
matrix_k8s_node_images:
110+
runs-on: ubuntu-latest
111+
outputs:
112+
matrix: ${{ steps.set-matrix.outputs.matrix }}
113+
steps:
114+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
115+
- id: set-matrix
116+
run: |
117+
(
118+
echo 'matrix<<EOF'
119+
yq eval -o=json '.' .github/supported_k8s_node_images.yaml
120+
echo 'EOF'
121+
) >> "${GITHUB_OUTPUT}"
122+
109123
apply:
110124
runs-on: ubuntu-latest
125+
needs:
126+
- matrix_k8s_node_images
127+
strategy:
128+
matrix:
129+
include: ${{ fromJson(needs.matrix_k8s_node_images.outputs.matrix) }}
130+
111131
steps:
112132
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
113133

@@ -121,6 +141,11 @@ jobs:
121141

122142
- name: Create k8s KinD Cluster
123143
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
144+
with:
145+
# NOTE: default is 0.26.0 https://github.com/helm/kind-action/blob/a1b0e391336a6ee6713a0583f8c6240d70863de3/kind.sh#L21
146+
# so bump this manually
147+
version: v0.27.0
148+
node_image: ${{ matrix.node_image }}
124149

125150
- name: Verify installing CRDs via kustomize works
126151
run: make install
@@ -130,6 +155,12 @@ jobs:
130155

131156
CRDs-validation:
132157
runs-on: ubuntu-latest
158+
needs:
159+
- matrix_k8s_node_images
160+
strategy:
161+
matrix:
162+
include: ${{ fromJson(needs.matrix_k8s_node_images.outputs.matrix) }}
163+
133164
steps:
134165
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
135166

@@ -143,6 +174,11 @@ jobs:
143174

144175
- name: Create k8s KinD Cluster
145176
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3 # v1.12.0
177+
with:
178+
# NOTE: default is 0.26.0 https://github.com/helm/kind-action/blob/a1b0e391336a6ee6713a0583f8c6240d70863de3/kind.sh#L21
179+
# so bump this manually
180+
version: v0.27.0
181+
node_image: ${{ matrix.node_image }}
146182

147183
- name: Verify installing CRDs via kustomize works
148184
run: make install

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Adding a new version? You'll need three changes:
3030
[#381](https://github.com/Kong/kubernetes-configuration/pull/381)
3131
- Add Type and KonnectID fields to the `KonnectGatewayControlPlane` CRD.
3232
[#387](https://github.com/Kong/kubernetes-configuration/pull/387)
33+
- Removed `namespace` field validation on `KonnectConfigurationDataPlaneGroup` `networkRef` field.
34+
Using CEL reserved keywords is only available in Kubernetes 1.32+.
35+
Added CRD validation test for all supported Kubernetes versions.
36+
[#394](https://github.com/Kong/kubernetes-configuration/pull/394)
3337

3438
## [v1.3.1]
3539

api/konnect/v1alpha1/konnect_cloudgateway_dataplane_configuration_types.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ type KonnectConfigurationDataPlaneGroup struct {
9292

9393
// NetworkRef is the reference to the network that this data-plane group will be deployed on.
9494
//
95+
// Cross namespace references are not supported for networkRef of type namespacedRef.
96+
// This will be enforced in the future but currently (due to limitation in CEL validation
97+
// in Kubernetes 1.31 and older) it is not.
98+
//
9599
// +kubebuilder:validation:Required
96-
// +kubebuilder:validation:XValidation:rule="self.type == 'namespacedRef' && has(self.namespacedRef) ? !has(self.namespacedRef.namespace) : true", message="cross namespace references are not supported for networkRef of type namespacedRef"
97100
NetworkRef commonv1alpha1.ObjectRef `json:"networkRef"`
98101

99102
// Autoscale configuration for the data-plane group.

config/crd/gateway-operator/konnect.konghq.com_konnectcloudgatewaydataplanegroupconfigurations.yaml

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

docs/all-api-reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3847,7 +3847,7 @@ KonnectConfigurationDataPlaneGroup is the schema for the KonnectConfiguration ty
38473847
| --- | --- |
38483848
| `provider` _[ProviderName](#providername)_ | Name of cloud provider. |
38493849
| `region` _string_ | Region for cloud provider region. |
3850-
| `networkRef` _[ObjectRef](#objectref)_ | NetworkRef is the reference to the network that this data-plane group will be deployed on. |
3850+
| `networkRef` _[ObjectRef](#objectref)_ | NetworkRef is the reference to the network that this data-plane group will be deployed on.<br /><br /> Cross namespace references are not supported for networkRef of type namespacedRef. This will be enforced in the future but currently (due to limitation in CEL validation in Kubernetes 1.31 and older) it is not. |
38513851
| `autoscale` _[ConfigurationDataPlaneGroupAutoscale](#configurationdataplanegroupautoscale)_ | Autoscale configuration for the data-plane group. |
38523852
| `environment` _[ConfigurationDataPlaneGroupEnvironmentField](#configurationdataplanegroupenvironmentfield) array_ | Array of environment variables to set for a data-plane group. |
38533853

docs/konnect-api-reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ KonnectConfigurationDataPlaneGroup is the schema for the KonnectConfiguration ty
489489
| --- | --- |
490490
| `provider` _[ProviderName](#providername)_ | Name of cloud provider. |
491491
| `region` _string_ | Region for cloud provider region. |
492-
| `networkRef` _[ObjectRef](#objectref)_ | NetworkRef is the reference to the network that this data-plane group will be deployed on. |
492+
| `networkRef` _[ObjectRef](#objectref)_ | NetworkRef is the reference to the network that this data-plane group will be deployed on.<br /><br /> Cross namespace references are not supported for networkRef of type namespacedRef. This will be enforced in the future but currently (due to limitation in CEL validation in Kubernetes 1.31 and older) it is not. |
493493
| `autoscale` _[ConfigurationDataPlaneGroupAutoscale](#configurationdataplanegroupautoscale)_ | Autoscale configuration for the data-plane group. |
494494
| `environment` _[ConfigurationDataPlaneGroupEnvironmentField](#configurationdataplanegroupenvironmentfield) array_ | Array of environment variables to set for a data-plane group. |
495495

test/crdsvalidation/common/testcase.go

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ type TestCase[T client.Object] struct {
5353
// Name is the name of the test case.
5454
Name string
5555

56+
// SkipReason is the reason to skip the test case.
57+
SkipReason string
58+
5659
// TestObject is the object to be tested.
5760
TestObject T
5861

@@ -73,6 +76,10 @@ type TestCase[T client.Object] struct {
7376

7477
// RunWithConfig runs the test case against the provided rest.Config's cluster.
7578
func (tc *TestCase[T]) RunWithConfig(t *testing.T, cfg *rest.Config, scheme *runtime.Scheme) {
79+
if tc.SkipReason != "" {
80+
t.Skip(tc.SkipReason)
81+
}
82+
7683
timeout := DefaultEventuallyTimeout
7784
if tc.ExpectedErrorEventuallyConfig.Timeout != 0 {
7885
timeout = tc.ExpectedErrorEventuallyConfig.Timeout

test/crdsvalidation/konnect.konghq.com/konnectcloudgatewaydataplanegroupconfiguration_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ func TestKonnectDataPlaneGroupConfiguration(t *testing.T) {
303303
},
304304
{
305305
Name: "networkRef namespacedRef cannot specify namespace",
306+
SkipReason: "cross namespace references are not allowed but using the CEL reserved fields like 'namespace' " +
307+
"is only allowed in Kubernetes 1.32+ (https://github.com/kubernetes/kubernetes/pull/126977). " +
308+
"Re-enable this test and reintroduce the rule that enforces this when 1.32 becomes the oldest supported version.",
306309
TestObject: &konnectv1alpha1.KonnectCloudGatewayDataPlaneGroupConfiguration{
307310
ObjectMeta: common.CommonObjectMeta,
308311
Spec: konnectv1alpha1.KonnectCloudGatewayDataPlaneGroupConfigurationSpec{

test/crdsvalidation/konnect.konghq.com/konnectextension_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,13 @@ func TestKonnectExtension(t *testing.T) {
326326
},
327327
},
328328
},
329-
ExpectedErrorMessage: lo.ToPtr("Too long: may not be more than 63 bytes"),
329+
// NOTE: Kubernetes 1.32 changed the validation error for values exceeding the maximum length.
330+
// It used to be:
331+
// "Too long: may not be longer than 63"
332+
// In 1.32+ it is:
333+
// "Too long: may not be more than 63 bytes"
334+
// We're using here the common part of the error message to avoid breaking the test when upgrading Kubernetes.
335+
ExpectedErrorMessage: lo.ToPtr("Too long: may not be "),
330336
},
331337
{
332338
Name: "invalid label key 1",

0 commit comments

Comments
 (0)