diff --git a/config/crd/patches/webhook_in_metal3clusters.yaml b/config/crd/patches/webhook_in_metal3clusters.yaml index da9789ddd..ab75e2335 100644 --- a/config/crd/patches/webhook_in_metal3clusters.yaml +++ b/config/crd/patches/webhook_in_metal3clusters.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3dataclaims.yaml b/config/crd/patches/webhook_in_metal3dataclaims.yaml index ac2e73e3b..d07f2a254 100644 --- a/config/crd/patches/webhook_in_metal3dataclaims.yaml +++ b/config/crd/patches/webhook_in_metal3dataclaims.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3datas.yaml b/config/crd/patches/webhook_in_metal3datas.yaml index 5ecf4e893..ce6fd036d 100644 --- a/config/crd/patches/webhook_in_metal3datas.yaml +++ b/config/crd/patches/webhook_in_metal3datas.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3datatemplates.yaml b/config/crd/patches/webhook_in_metal3datatemplates.yaml index eb65c21d8..81d1660e7 100644 --- a/config/crd/patches/webhook_in_metal3datatemplates.yaml +++ b/config/crd/patches/webhook_in_metal3datatemplates.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3machines.yaml b/config/crd/patches/webhook_in_metal3machines.yaml index 7097af267..5565e821d 100644 --- a/config/crd/patches/webhook_in_metal3machines.yaml +++ b/config/crd/patches/webhook_in_metal3machines.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3machinetemplates.yaml b/config/crd/patches/webhook_in_metal3machinetemplates.yaml index 100c91050..5f37759af 100644 --- a/config/crd/patches/webhook_in_metal3machinetemplates.yaml +++ b/config/crd/patches/webhook_in_metal3machinetemplates.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3remediations.yaml b/config/crd/patches/webhook_in_metal3remediations.yaml index 802845fc0..143fec23a 100644 --- a/config/crd/patches/webhook_in_metal3remediations.yaml +++ b/config/crd/patches/webhook_in_metal3remediations.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/config/crd/patches/webhook_in_metal3remediationtemplates.yaml b/config/crd/patches/webhook_in_metal3remediationtemplates.yaml index 75d07e7f5..36c2a1026 100644 --- a/config/crd/patches/webhook_in_metal3remediationtemplates.yaml +++ b/config/crd/patches/webhook_in_metal3remediationtemplates.yaml @@ -10,9 +10,6 @@ spec: webhook: conversionReviewVersions: ["v1", "v1beta1"] clientConfig: - # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank, - # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager) - caBundle: Cg== service: namespace: system name: webhook-service diff --git a/docs/api.md b/docs/api.md index 182bed305..f648b32a5 100644 --- a/docs/api.md +++ b/docs/api.md @@ -127,7 +127,7 @@ spec: rollingUpdate: maxSurge: 1 type: RollingUpdate - version: v1.30.0 + version: v1.31.0 kubeadmConfigSpec: joinConfiguration: controlPlane: {} @@ -243,7 +243,7 @@ spec: namespace: metal3 nodeDrainTimeout: 0s providerID: metal3://68be298f-ed11-439e-9d51-6c5260faede6 - version: v1.30.0 + version: v1.31.0 ``` ## Metal3Machine @@ -413,10 +413,10 @@ metadata: spec: automatedCleaningMode: metadata image: - checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img.sha256sum + checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img.sha256sum checksumType: sha256 format: raw - url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img + url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img hostSelector: matchLabels: key1: value1 @@ -473,7 +473,7 @@ spec: name: md-0 apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 kind: Metal3MachineTemplate - version: v1.30.0 + version: v1.31.0 ``` ## KubeadmConfigTemplate @@ -557,10 +557,10 @@ spec: spec: automatedCleaningMode: metadata image: - checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img.sha256sum + checksum: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img.sha256sum checksumType: sha256 format: raw - url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img + url: http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img hostSelector: matchLabels: key1: value1 diff --git a/docs/architecture.md b/docs/architecture.md index 0f3a9663b..fc35b926a 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -404,7 +404,7 @@ spec: etcd: {} imageRepository: "" kind: ClusterConfiguration - kubernetesVersion: v1.30.0 + kubernetesVersion: v1.31.0 networking: dnsDomain: cluster.local podSubnet: 192.168.0.0/18 diff --git a/docs/dev-setup.md b/docs/dev-setup.md index fd499a13e..e246d784b 100644 --- a/docs/dev-setup.md +++ b/docs/dev-setup.md @@ -287,7 +287,7 @@ Please note, the precedence of variables is as follows: }, "metadata": {, "CONTROL_PLANE_MACHINE_COUNT": "1", - "KUBERNETES_VERSION": "v1.30.0", + "KUBERNETES_VERSION": "v1.31.0", "WORKER_MACHINE_COUNT": "2", } } diff --git a/examples/generate.sh b/examples/generate.sh index 964ac6f94..0144952e4 100755 --- a/examples/generate.sh +++ b/examples/generate.sh @@ -24,11 +24,11 @@ KUSTOMIZE="${SOURCE_DIR}/../hack/tools/bin/kustomize" # Cluster. export CLUSTER_NAME="${CLUSTER_NAME:-test1}" -export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.30.0}" +export KUBERNETES_VERSION="${KUBERNETES_VERSION:-v1.31.0}" export CLUSTER_APIENDPOINT_HOST="${CLUSTER_APIENDPOINT_HOST:-192.168.111.249}" export CLUSTER_APIENDPOINT_PORT="${CLUSTER_APIENDPOINT_PORT:-6443}" -export IMAGE_URL="${IMAGE_URL:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img}" -export IMAGE_CHECKSUM="${IMAGE_CHECKSUM:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.30.0-raw.img.sha256sum}" +export IMAGE_URL="${IMAGE_URL:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img}" +export IMAGE_CHECKSUM="${IMAGE_CHECKSUM:-http://172.22.0.1/images/UBUNTU_22.04_NODE_IMAGE_K8S_v1.31.0-raw.img.sha256sum}" export IMAGE_CHECKSUM_TYPE="${IMAGE_CHECKSUM_TYPE:-sha256}" export IMAGE_FORMAT="${IMAGE_FORMAT:-raw}" diff --git a/hack/ensure-kubectl.sh b/hack/ensure-kubectl.sh index 39b4f5352..ff6c7507b 100755 --- a/hack/ensure-kubectl.sh +++ b/hack/ensure-kubectl.sh @@ -19,7 +19,7 @@ set -o nounset set -o pipefail GOPATH_BIN="$(go env GOPATH)/bin/" -MINIMUM_KUBECTL_VERSION=${KUBERNETES_VERSION:-"v1.30.0"} +MINIMUM_KUBECTL_VERSION=${KUBERNETES_VERSION:-"v1.31.0"} # Ensure the kubectl tool exists and is a viable version, or installs it verify_kubectl_version() diff --git a/hack/gen_tilt_settings.sh b/hack/gen_tilt_settings.sh index 918a48694..003a4e339 100755 --- a/hack/gen_tilt_settings.sh +++ b/hack/gen_tilt_settings.sh @@ -63,7 +63,7 @@ cat <tilt-settings.json { "capi_version": "${CAPIRELEASE}", "cert_manager_version": "v1.12.3", - "kubernetes_version": "${KUBERNETES_VERSION:-v1.30.0}" + "kubernetes_version": "${KUBERNETES_VERSION:-v1.31.0}" } EOF fi diff --git a/scripts/environment.sh b/scripts/environment.sh index 8f01eae6a..7508dd5b1 100644 --- a/scripts/environment.sh +++ b/scripts/environment.sh @@ -48,8 +48,8 @@ else export EPHEMERAL_CLUSTER="minikube" fi -export FROM_K8S_VERSION=${FROM_K8S_VERSION:-"v1.29.0"} -export KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.30.0"} +export FROM_K8S_VERSION=${FROM_K8S_VERSION:-"v1.30.0"} +export KUBERNETES_VERSION=${KUBERNETES_VERSION:-"v1.31.0"} # Can be overriden from jjbs export CAPI_VERSION=${CAPI_VERSION:-"v1beta1"} diff --git a/test/e2e/common.go b/test/e2e/common.go index 4fe59da41..a472e6805 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -417,6 +417,25 @@ func ListNodes(ctx context.Context, c client.Client) { logTable("Listing Nodes", rows) } +func CreateNewM3MachineTemplate(ctx context.Context, namespace string, newM3MachineTemplateName string, m3MachineTemplateName string, clusterClient client.Client, imageURL string, imageChecksum string) { + checksumType := "sha256" + imageFormat := "raw" + + m3MachineTemplate := infrav1.Metal3MachineTemplate{} + Expect(clusterClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: m3MachineTemplateName}, &m3MachineTemplate)).To(Succeed()) + + newM3MachineTemplate := m3MachineTemplate.DeepCopy() + cleanObjectMeta(&newM3MachineTemplate.ObjectMeta) + + newM3MachineTemplate.Spec.Template.Spec.Image.URL = imageURL + newM3MachineTemplate.Spec.Template.Spec.Image.Checksum = imageChecksum + newM3MachineTemplate.Spec.Template.Spec.Image.DiskFormat = &imageFormat + newM3MachineTemplate.Spec.Template.Spec.Image.ChecksumType = &checksumType + newM3MachineTemplate.ObjectMeta.Name = newM3MachineTemplateName + + Expect(clusterClient.Create(ctx, newM3MachineTemplate)).To(Succeed(), "Failed to create new Metal3MachineTemplate") +} + type WaitForNumInput struct { Client client.Client Options []client.ListOption diff --git a/test/e2e/ip_reuse.go b/test/e2e/ip_reuse.go index a3d6e2b49..e9e11250e 100644 --- a/test/e2e/ip_reuse.go +++ b/test/e2e/ip_reuse.go @@ -8,7 +8,6 @@ import ( bmov1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "k8s.io/apimachinery/pkg/types" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework" "sigs.k8s.io/cluster-api/test/framework/clusterctl" @@ -116,24 +115,23 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Expect(machineDeployments).To(HaveLen(1), "Expected exactly 1 MachineDeployment") md := machineDeployments[0] + // Download node image + Byf("Download image %s", kubernetesVersion) + imageURL, imageChecksum := EnsureImage(kubernetesVersion) + + By("Create new worker Metal3MachineTemplate with upgraded image to boot") + m3MachineTemplateName := md.Spec.Template.Spec.InfrastructureRef.Name + newM3MachineTemplateName := fmt.Sprintf("%s-new", m3MachineTemplateName) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + Byf("Update MachineDeployment maxUnavailable to number of workers and k8s version from %s to %s", fromK8sVersion, kubernetesVersion) - patch := []byte(fmt.Sprintf(`{ - "spec": { - "strategy": { - "rollingUpdate": { - "maxSurge": 0, - "maxUnavailable": 3 - } - }, - "template": { - "spec": { - "version": "%s" - } - } - } - }`, kubernetesVersion)) - err = managementClusterClient.Patch(ctx, md, client.RawPatch(types.MergePatchType, patch)) - Expect(err).ToNot(HaveOccurred(), "Failed to patch MachineDeployment") + helper, err := patch.NewHelper(md, managementClusterClient) + Expect(err).NotTo(HaveOccurred()) + md.Spec.Template.Spec.InfrastructureRef.Name = newM3MachineTemplateName + md.Spec.Template.Spec.Version = &kubernetesVersion + md.Spec.Strategy.RollingUpdate.MaxSurge.IntVal = 0 + md.Spec.Strategy.RollingUpdate.MaxUnavailable.IntVal = 3 + Expect(helper.Patch(ctx, md)).To(Succeed()) Byf("Wait until %d BMH(s) in deprovisioning state", 3) WaitForNumBmhInState(ctx, bmov1alpha1.StateDeprovisioning, WaitForNumInput{ @@ -143,6 +141,11 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Intervals: input.E2EConfig.GetIntervals(input.SpecName, "wait-bmh-deprovisioning"), }) + ListBareMetalHosts(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMetal3Machines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMachines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListNodes(ctx, targetClusterClient) + Byf("Wait until all %d machine(s) become(s) running", 4) WaitForNumMachinesInState(ctx, clusterv1.MachinePhaseRunning, WaitForNumInput{ Client: managementClusterClient, @@ -151,6 +154,11 @@ func IPReuse(ctx context.Context, inputGetter func() IPReuseInput) { Intervals: input.E2EConfig.GetIntervals(input.SpecName, "wait-machine-running"), }) + ListBareMetalHosts(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMetal3Machines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListMachines(ctx, managementClusterClient, client.InNamespace(input.Namespace)) + ListNodes(ctx, targetClusterClient) + By("Get the IPPools in the cluster") baremetalv4Pool, provisioningPool = GetIPPools(ctx, managementClusterClient, input.ClusterName, input.Namespace) Expect(baremetalv4Pool).To(HaveLen(1)) diff --git a/test/e2e/node_reuse.go b/test/e2e/node_reuse.go index d26dcaf95..9272a4403 100644 --- a/test/e2e/node_reuse.go +++ b/test/e2e/node_reuse.go @@ -108,7 +108,7 @@ func nodeReuse(ctx context.Context, inputGetter func() NodeReuseInput) { m3MachineTemplateName := fmt.Sprintf("%s-controlplane", input.ClusterName) updateNodeReuse(ctx, input.Namespace, true, m3MachineTemplateName, managementClusterClient) newM3MachineTemplateName := fmt.Sprintf("%s-new-controlplane", input.ClusterName) - createNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) Byf("Update KCP to upgrade k8s version and binaries from %s to %s [node_reuse]", kubernetesVersion, upgradedK8sVersion) kcpObj := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{ @@ -330,7 +330,7 @@ func nodeReuse(ctx context.Context, inputGetter func() NodeReuseInput) { By("Set nodeReuse field to 'True' and create new Metal3MachineTemplate for MD with upgraded image to boot [node_reuse]") updateNodeReuse(ctx, input.Namespace, true, m3MachineTemplateName, managementClusterClient) newM3MachineTemplateName = fmt.Sprintf("%s-new-workers", input.ClusterName) - createNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, input.Namespace, newM3MachineTemplateName, m3MachineTemplateName, managementClusterClient, imageURL, imageChecksum) Byf("Update MD to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) // Note: We have only 4 nodes (3 control-plane and 1 worker) so we @@ -536,22 +536,3 @@ func deleteTaint(taints []corev1.Taint, taintsToDelete []corev1.Taint) ([]corev1 } return newTaints, deleted } - -func createNewM3MachineTemplate(ctx context.Context, namespace string, newM3MachineTemplateName string, m3MachineTemplateName string, clusterClient client.Client, imageURL string, imageChecksum string) { - checksumType := "sha256" - imageFormat := "raw" - - m3MachineTemplate := infrav1.Metal3MachineTemplate{} - Expect(clusterClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: m3MachineTemplateName}, &m3MachineTemplate)).To(Succeed()) - - newM3MachineTemplate := m3MachineTemplate.DeepCopy() - cleanObjectMeta(&newM3MachineTemplate.ObjectMeta) - - newM3MachineTemplate.Spec.Template.Spec.Image.URL = imageURL - newM3MachineTemplate.Spec.Template.Spec.Image.Checksum = imageChecksum - newM3MachineTemplate.Spec.Template.Spec.Image.DiskFormat = &imageFormat - newM3MachineTemplate.Spec.Template.Spec.Image.ChecksumType = &checksumType - newM3MachineTemplate.ObjectMeta.Name = newM3MachineTemplateName - - Expect(clusterClient.Create(ctx, newM3MachineTemplate)).To(Succeed(), "Failed to create new Metal3MachineTemplate") -} diff --git a/test/e2e/upgrade_kubernetes_test.go b/test/e2e/upgrade_kubernetes_test.go index ce4fa5514..e2b2d1e9a 100644 --- a/test/e2e/upgrade_kubernetes_test.go +++ b/test/e2e/upgrade_kubernetes_test.go @@ -108,7 +108,7 @@ func upgradeKubernetes(ctx context.Context, inputGetter func() upgradeKubernetes By("Create new KCP Metal3MachineTemplate with upgraded image to boot") m3MachineTemplateName := fmt.Sprintf("%s-controlplane", clusterName) newM3MachineTemplateName := fmt.Sprintf("%s-new-controlplane", clusterName) - createNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) Byf("Update KCP to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) kcpObj := framework.GetKubeadmControlPlaneByCluster(ctx, framework.GetKubeadmControlPlaneByClusterInput{ @@ -177,7 +177,7 @@ func upgradeKubernetes(ctx context.Context, inputGetter func() upgradeKubernetes By("Create new Metal3MachineTemplate for MD with upgraded image to boot") m3MachineTemplateName = fmt.Sprintf("%s-workers", clusterName) newM3MachineTemplateName = fmt.Sprintf("%s-new-workers", clusterName) - createNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) + CreateNewM3MachineTemplate(ctx, namespace, newM3MachineTemplateName, m3MachineTemplateName, clusterClient, imageURL, imageChecksum) Byf("Update MD to upgrade k8s version and binaries from %s to %s", kubernetesVersion, upgradedK8sVersion) helper, err = patch.NewHelper(machineDeploy, clusterClient)