Skip to content

Commit a64eda7

Browse files
authored
feat: add support for Kubernetes 1.25 dropping 1.19 & 1.20 (cloudnative-pg#733)
Update the following dependencies: - k8s.io/api v0.25.0 - k8s.io/apiextensions-apiserver v0.25.0 - k8s.io/apimachinery v0.25.0 - k8s.io/cli-runtime v0.25.0 - k8s.io/client-go v0.25.0 - sigs.k8s.io/controller-runtime v0.13.0 Drop support for Kubernetes 1.19 and 1.20 Temporarily disable the E2E upgrade test on 1.25 Documentation updated accordingly Closes cloudnative-pg#413 Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent 1513839 commit a64eda7

18 files changed

+206
-391
lines changed

.github/e2e-matrix-generator.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ def oldest(self):
6666
# and the supported releases https://kubernetes.io/releases/
6767
K8S = VersionList(
6868
[
69-
"v1.24.3",
70-
"v1.23.6",
71-
"v1.22.9",
69+
"v1.25.0",
70+
"v1.24.4",
71+
"v1.23.10",
72+
"v1.22.13",
7273
]
7374
)
7475

.github/workflows/continuous-delivery.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,11 @@ jobs:
192192
matrix:
193193
# The Unit test is performed per multiple supported k8s versions (each job for each k8s version) as below:
194194
k8s-version:
195-
- 1.19.x
196-
- 1.20.x
197195
- 1.21.x
198196
- 1.22.x
199197
- 1.23.x
200198
- 1.24.x
199+
- 1.25.x
201200
steps:
202201
-
203202
name: Checkout code
@@ -229,12 +228,12 @@ jobs:
229228
make test
230229
-
231230
name: Coverage Summary
232-
if: matrix.k8s-version == '1.24.x'
231+
if: matrix.k8s-version == '1.25.x'
233232
run: |
234233
go tool cover -func=cover.out -o coverage.out
235234
-
236235
name: Publish unit test summary
237-
if: matrix.k8s-version == '1.24.x'
236+
if: matrix.k8s-version == '1.25.x'
238237
run: |
239238
echo "Unit test coverage: $(tail -n 1 coverage.out | awk '{print $3}')" >> $GITHUB_STEP_SUMMARY
240239
apidoc:

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ BUILD_IMAGE ?= true
3636
POSTGRES_IMAGE_NAME ?= ghcr.io/cloudnative-pg/postgresql:14
3737
KUSTOMIZE_VERSION ?= v4.5.2
3838
KIND_CLUSTER_NAME ?= pg
39-
KIND_CLUSTER_VERSION ?= v1.24.3
39+
KIND_CLUSTER_VERSION ?= v1.25.0
4040
CONTROLLER_TOOLS_VERSION ?= v0.9.2
4141
GORELEASER_VERSION ?= v1.10.3
4242

config/crd/bases/postgresql.cnpg.io_clusters.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2557,8 +2557,8 @@ spec:
25572557
description: "Condition contains details for one aspect of the current
25582558
state of this API Resource. --- This struct is intended for direct
25592559
use as an array at the field path .status.conditions. For example,
2560-
type FooStatus struct{ // Represents the observations of a foo's
2561-
current state. // Known .status.conditions.type are: \"Available\",
2560+
\n type FooStatus struct{ // Represents the observations of a
2561+
foo's current state. // Known .status.conditions.type are: \"Available\",
25622562
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
25632563
// +listType=map // +listMapKey=type Conditions []metav1.Condition
25642564
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"

config/crd/bases/postgresql.cnpg.io_poolers.yaml

+75-29
Original file line numberDiff line numberDiff line change
@@ -1643,13 +1643,13 @@ spec:
16431643
type: string
16441644
ports:
16451645
description: List of ports to expose from the container.
1646-
Exposing a port here gives the system additional information
1647-
about the network connections a container uses, but
1648-
is primarily informational. Not specifying a port
1649-
here DOES NOT prevent that port from being exposed.
1650-
Any port which is listening on the default "0.0.0.0"
1651-
address inside a container will be accessible from
1652-
the network. Cannot be updated.
1646+
Not specifying a port here DOES NOT prevent that port
1647+
from being exposed. Any port which is listening on
1648+
the default "0.0.0.0" address inside a container will
1649+
be accessible from the network. Modifying this array
1650+
with strategic merge patch may corrupt the data. For
1651+
more information See https://github.com/kubernetes/kubernetes/issues/108255.
1652+
Cannot be updated.
16531653
items:
16541654
description: ContainerPort represents a network port
16551655
in a single container.
@@ -2407,8 +2407,6 @@ spec:
24072407
be specified when creating a pod, and it cannot be modified
24082408
by updating the pod spec. In order to add an ephemeral container
24092409
to an existing pod, use the pod's ephemeralcontainers subresource.
2410-
This field is beta-level and available on clusters that
2411-
haven't disabled the EphemeralContainers feature gate.
24122410
items:
24132411
description: "An EphemeralContainer is a temporary container
24142412
that you may add to an existing Pod for user-initiated
@@ -2419,9 +2417,7 @@ spec:
24192417
container causes the Pod to exceed its resource allocation.
24202418
\n To add an ephemeral container, use the ephemeralcontainers
24212419
subresource of an existing Pod. Ephemeral containers may
2422-
not be removed or restarted. \n This is a beta feature
2423-
available on clusters that haven't disabled the EphemeralContainers
2424-
feature gate."
2420+
not be removed or restarted."
24252421
properties:
24262422
args:
24272423
description: 'Arguments to the entrypoint. The image''s
@@ -3735,6 +3731,19 @@ spec:
37353731
description: 'Use the host''s pid namespace. Optional: Default
37363732
to false.'
37373733
type: boolean
3734+
hostUsers:
3735+
description: 'Use the host''s user namespace. Optional: Default
3736+
to true. If set to true or not present, the pod will be
3737+
run in the host user namespace, useful for when the pod
3738+
needs a feature only available to the host user namespace,
3739+
such as loading a kernel module with CAP_SYS_MODULE. When
3740+
set to false, a new userns is created for the pod. Setting
3741+
false is useful for mitigating container breakout vulnerabilities
3742+
even allowing users to run their containers as root without
3743+
actually having root privileges on the host. This field
3744+
is alpha-level and is only honored by servers that enable
3745+
the UserNamespacesSupport feature.'
3746+
type: boolean
37383747
hostname:
37393748
description: Specifies the hostname of the Pod If not specified,
37403749
the pod's hostname will be set to a system-defined value.
@@ -4361,13 +4370,13 @@ spec:
43614370
type: string
43624371
ports:
43634372
description: List of ports to expose from the container.
4364-
Exposing a port here gives the system additional information
4365-
about the network connections a container uses, but
4366-
is primarily informational. Not specifying a port
4367-
here DOES NOT prevent that port from being exposed.
4368-
Any port which is listening on the default "0.0.0.0"
4369-
address inside a container will be accessible from
4370-
the network. Cannot be updated.
4373+
Not specifying a port here DOES NOT prevent that port
4374+
from being exposed. Any port which is listening on
4375+
the default "0.0.0.0" address inside a container will
4376+
be accessible from the network. Modifying this array
4377+
with strategic merge patch may corrupt the data. For
4378+
more information See https://github.com/kubernetes/kubernetes/issues/108255.
4379+
Cannot be updated.
43714380
items:
43724381
description: ContainerPort represents a network port
43734382
in a single container.
@@ -5087,7 +5096,7 @@ spec:
50875096
set. \n If the OS field is set to linux, the following fields
50885097
must be unset: -securityContext.windowsOptions \n If the
50895098
OS field is set to windows, following fields must be unset:
5090-
- spec.hostPID - spec.hostIPC - spec.securityContext.seLinuxOptions
5099+
- spec.hostPID - spec.hostIPC - spec.hostUsers - spec.securityContext.seLinuxOptions
50915100
- spec.securityContext.seccompProfile - spec.securityContext.fsGroup
50925101
- spec.securityContext.fsGroupChangePolicy - spec.securityContext.sysctls
50935102
- spec.shareProcessNamespace - spec.securityContext.runAsUser
@@ -5096,8 +5105,7 @@ spec:
50965105
- spec.containers[*].securityContext.capabilities - spec.containers[*].securityContext.readOnlyRootFilesystem
50975106
- spec.containers[*].securityContext.privileged - spec.containers[*].securityContext.allowPrivilegeEscalation
50985107
- spec.containers[*].securityContext.procMount - spec.containers[*].securityContext.runAsUser
5099-
- spec.containers[*].securityContext.runAsGroup This is
5100-
a beta field and requires the IdentifyPodOS feature"
5108+
- spec.containers[*].securityContext.runAsGroup"
51015109
properties:
51025110
name:
51035111
description: 'Name is the name of the operating system.
@@ -5515,6 +5523,20 @@ spec:
55155523
type: object
55165524
type: object
55175525
x-kubernetes-map-type: atomic
5526+
matchLabelKeys:
5527+
description: MatchLabelKeys is a set of pod label keys
5528+
to select the pods over which spreading will be calculated.
5529+
The keys are used to lookup values from the incoming
5530+
pod labels, those key-value labels are ANDed with
5531+
labelSelector to select the group of existing pods
5532+
over which spreading will be calculated for the incoming
5533+
pod. Keys that don't exist in the incoming pod labels
5534+
will be ignored. A null or empty list means only match
5535+
against labelSelector.
5536+
items:
5537+
type: string
5538+
type: array
5539+
x-kubernetes-list-type: atomic
55185540
maxSkew:
55195541
description: 'MaxSkew describes the degree to which
55205542
pods may be unevenly distributed. When `whenUnsatisfiable=DoNotSchedule`,
@@ -5560,10 +5582,34 @@ spec:
55605582
new pod with the same labelSelector cannot be scheduled,
55615583
because computed skew will be 3(3 - 0) if new Pod
55625584
is scheduled to any of the three zones, it will violate
5563-
MaxSkew. \n This is an alpha field and requires enabling
5564-
MinDomainsInPodTopologySpread feature gate."
5585+
MaxSkew. \n This is a beta field and requires the
5586+
MinDomainsInPodTopologySpread feature gate to be enabled
5587+
(enabled by default)."
55655588
format: int32
55665589
type: integer
5590+
nodeAffinityPolicy:
5591+
description: "NodeAffinityPolicy indicates how we will
5592+
treat Pod's nodeAffinity/nodeSelector when calculating
5593+
pod topology spread skew. Options are: - Honor: only
5594+
nodes matching nodeAffinity/nodeSelector are included
5595+
in the calculations. - Ignore: nodeAffinity/nodeSelector
5596+
are ignored. All nodes are included in the calculations.
5597+
\n If this value is nil, the behavior is equivalent
5598+
to the Honor policy. This is a alpha-level feature
5599+
enabled by the NodeInclusionPolicyInPodTopologySpread
5600+
feature flag."
5601+
type: string
5602+
nodeTaintsPolicy:
5603+
description: "NodeTaintsPolicy indicates how we will
5604+
treat node taints when calculating pod topology spread
5605+
skew. Options are: - Honor: nodes without taints,
5606+
along with tainted nodes for which the incoming pod
5607+
has a toleration, are included. - Ignore: node taints
5608+
are ignored. All nodes are included. \n If this value
5609+
is nil, the behavior is equivalent to the Ignore policy.
5610+
This is a alpha-level feature enabled by the NodeInclusionPolicyInPodTopologySpread
5611+
feature flag."
5612+
type: string
55675613
topologyKey:
55685614
description: TopologyKey is the key of node labels.
55695615
Nodes that have a label with this key and identical
@@ -5572,11 +5618,11 @@ spec:
55725618
to put balanced number of pods into each bucket. We
55735619
define a domain as a particular instance of a topology.
55745620
Also, we define an eligible domain as a domain whose
5575-
nodes match the node selector. e.g. If TopologyKey
5576-
is "kubernetes.io/hostname", each Node is a domain
5577-
of that topology. And, if TopologyKey is "topology.kubernetes.io/zone",
5578-
each zone is a domain of that topology. It's a required
5579-
field.
5621+
nodes meet the requirements of nodeAffinityPolicy
5622+
and nodeTaintsPolicy. e.g. If TopologyKey is "kubernetes.io/hostname",
5623+
each Node is a domain of that topology. And, if TopologyKey
5624+
is "topology.kubernetes.io/zone", each zone is a domain
5625+
of that topology. It's a required field.
55805626
type: string
55815627
whenUnsatisfiable:
55825628
description: 'WhenUnsatisfiable indicates how to deal

contribute/e2e_testing_environment/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ All flags have corresponding environment variables labeled `(Env:...` in the tab
5858
|--------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
5959
| -r\|--registry | Enable local registry. (Env: `ENABLE_REGISTRY`) |
6060
| -e\|--engine <CLUSTER_ENGINE> | Use the provided ENGINE to run the cluster. Available options are 'kind' and 'k3d'. Default 'kind'. (Env: `CLUSTER_ENGINE`) |
61-
| -k\|--k8s-version <K8S_VERSION> | Use the specified Kubernetes full version number (e.g., `-k v1.24.2`). (Env: `K8S_VERSION`) |
61+
| -k\|--k8s-version <K8S_VERSION> | Use the specified Kubernetes full version number (e.g., `-k v1.25.0`). (Env: `K8S_VERSION`) |
6262
| -n\|--nodes <NODES> | Create a cluster with the required number of nodes. Used only during "create" command. Default: 3 (Env: `NODES`) |
6363

6464

@@ -160,7 +160,7 @@ the following ones can be defined:
160160
Default: `false`
161161
* `PRESERVE_NAMESPACES`: space separated list of namespace to be kept after
162162
the tests. Only useful if specified with `PRESERVE_CLUSTER=true`
163-
* `K8S_VERSION`: the version of K8s to run. Default: `v1.24.2`
163+
* `K8S_VERSION`: the version of K8s to run. Default: `v1.25.0`
164164
* `KIND_VERSION`: the version of `kind`. Defaults to the latest release
165165
* `BUILD_IMAGE`: true to build the Dockerfile and load it on kind,
166166
false to get the image from a registry. Default: `false`

controllers/cluster_controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
batchv1 "k8s.io/api/batch/v1"
3131
corev1 "k8s.io/api/core/v1"
32-
policyv1beta1 "k8s.io/api/policy/v1beta1"
32+
policyv1 "k8s.io/api/policy/v1"
3333
apierrs "k8s.io/apimachinery/pkg/api/errors"
3434
"k8s.io/apimachinery/pkg/api/resource"
3535
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -759,7 +759,7 @@ func (r *ClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manag
759759
Owns(&batchv1.Job{}).
760760
Owns(&corev1.Service{}).
761761
Owns(&corev1.PersistentVolumeClaim{}).
762-
Owns(&policyv1beta1.PodDisruptionBudget{}).
762+
Owns(&policyv1.PodDisruptionBudget{}).
763763
Watches(
764764
&source.Kind{Type: &corev1.ConfigMap{}},
765765
handler.EnqueueRequestsFromMapFunc(r.mapConfigMapsToClusters(ctx)),

controllers/cluster_create.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/sethvargo/go-password/password"
2727
batchv1 "k8s.io/api/batch/v1"
2828
corev1 "k8s.io/api/core/v1"
29-
"k8s.io/api/policy/v1beta1"
29+
policyv1 "k8s.io/api/policy/v1"
3030
rbacv1 "k8s.io/api/rbac/v1"
3131
apierrs "k8s.io/apimachinery/pkg/api/errors"
3232
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -313,13 +313,13 @@ func (r *ClusterReconciler) createPostgresServices(ctx context.Context, cluster
313313
func (r *ClusterReconciler) createOrPatchOwnedPodDisruptionBudget(
314314
ctx context.Context,
315315
cluster *apiv1.Cluster,
316-
pdb *v1beta1.PodDisruptionBudget,
316+
pdb *policyv1.PodDisruptionBudget,
317317
) error {
318318
if pdb == nil {
319319
return nil
320320
}
321321

322-
var oldPdb v1beta1.PodDisruptionBudget
322+
var oldPdb policyv1.PodDisruptionBudget
323323

324324
if err := r.Get(ctx, client.ObjectKey{Name: pdb.Name, Namespace: pdb.Namespace}, &oldPdb); err != nil {
325325
if !apierrs.IsNotFound(err) {
@@ -373,7 +373,7 @@ func (r *ClusterReconciler) deletePodDisruptionBudget(
373373
key types.NamespacedName,
374374
) error {
375375
// If we have a PDB, we need to delete it
376-
var targetPdb v1beta1.PodDisruptionBudget
376+
var targetPdb policyv1.PodDisruptionBudget
377377
err := r.Get(ctx, key, &targetPdb)
378378
if err != nil {
379379
if !apierrs.IsNotFound(err) {

controllers/cluster_create_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"context"
2121

2222
corev1 "k8s.io/api/core/v1"
23-
policyv1beta1 "k8s.io/api/policy/v1beta1"
23+
policyv1 "k8s.io/api/policy/v1"
2424
"k8s.io/apimachinery/pkg/types"
2525

2626
apiv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
@@ -184,12 +184,12 @@ var _ = Describe("cluster_create unit tests", func() {
184184
expectResourceExistsWithDefaultClient(
185185
pdbPrimaryName,
186186
namespace,
187-
&policyv1beta1.PodDisruptionBudget{},
187+
&policyv1.PodDisruptionBudget{},
188188
)
189189
expectResourceExistsWithDefaultClient(
190190
pdbReplicaName,
191191
namespace,
192-
&policyv1beta1.PodDisruptionBudget{},
192+
&policyv1.PodDisruptionBudget{},
193193
)
194194
})
195195

@@ -209,7 +209,7 @@ var _ = Describe("cluster_create unit tests", func() {
209209
expectResourceDoesntExistWithDefaultClient(
210210
pdbReplicaName,
211211
namespace,
212-
&policyv1beta1.PodDisruptionBudget{},
212+
&policyv1.PodDisruptionBudget{},
213213
)
214214
})
215215

@@ -226,12 +226,12 @@ var _ = Describe("cluster_create unit tests", func() {
226226
expectResourceDoesntExistWithDefaultClient(
227227
pdbPrimaryName,
228228
namespace,
229-
&policyv1beta1.PodDisruptionBudget{},
229+
&policyv1.PodDisruptionBudget{},
230230
)
231231
expectResourceDoesntExistWithDefaultClient(
232232
pdbReplicaName,
233233
namespace,
234-
&policyv1beta1.PodDisruptionBudget{},
234+
&policyv1.PodDisruptionBudget{},
235235
)
236236
})
237237
})

0 commit comments

Comments
 (0)