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

🌱 Bump k8s to v1.31.0 and drop caBundle from CRDs to support Kubernetes 1.31 #1866

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions config/crd/patches/webhook_in_metal3clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions config/crd/patches/webhook_in_metal3dataclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions config/crd/patches/webhook_in_metal3datas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions config/crd/patches/webhook_in_metal3datatemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions config/crd/patches/webhook_in_metal3machines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions config/crd/patches/webhook_in_metal3machinetemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions config/crd/patches/webhook_in_metal3remediations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions config/crd/patches/webhook_in_metal3remediationtemplates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ spec:
rollingUpdate:
maxSurge: 1
type: RollingUpdate
version: v1.30.0
version: v1.31.0
kubeadmConfigSpec:
joinConfiguration:
controlPlane: {}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/dev-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down
2 changes: 1 addition & 1 deletion hack/ensure-kubectl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion hack/gen_tilt_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ cat <<EOF >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
4 changes: 2 additions & 2 deletions scripts/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
19 changes: 19 additions & 0 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 26 additions & 18 deletions test/e2e/ip_reuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand All @@ -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,
Expand All @@ -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))
Expand Down
23 changes: 2 additions & 21 deletions test/e2e/node_reuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
4 changes: 2 additions & 2 deletions test/e2e/upgrade_kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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)
Expand Down
Loading