From e63315295c6a00bb565fcecb3a0208ee53214479 Mon Sep 17 00:00:00 2001 From: Ashley Dumaine <5779804+AshleyDumaine@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:14:27 -0500 Subject: [PATCH] use different k8s version vars for different flavors (#157) --- docs/src/topics/flavors/k3s.md | 2 +- docs/src/topics/flavors/rke2.md | 2 +- templates/flavors/k3s/k3sControlPlane.yaml | 2 +- templates/flavors/k3s/kustomization.yaml | 8 ++++++++ templates/flavors/rke2/kustomization.yaml | 8 ++++++++ templates/flavors/rke2/rke2ConfigTemplate.yaml | 2 +- templates/flavors/rke2/rke2ControlPlane.yaml | 2 +- 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/src/topics/flavors/k3s.md b/docs/src/topics/flavors/k3s.md index 3d47a221f..9192ccdee 100644 --- a/docs/src/topics/flavors/k3s.md +++ b/docs/src/topics/flavors/k3s.md @@ -7,7 +7,7 @@ * [Quickstart](../topics/getting-started.md) completed * Select a [k3s kubernetes version](https://github.com/k3s-io/k3s/releases) to set for the kubernetes version ```bash - export KUBERNETES_VERSION=v1.29.1+k3s2 + export K3S_KUBERNETES_VERSION=v1.29.1+k3s2 ``` * Installed [k3s bootstrap provider](https://github.com/k3s-io/cluster-api-k3s) into your management cluster * Add the following to `~/.cluster-api/clusterctl.yaml` for the k3s bootstrap/control plane providers diff --git a/docs/src/topics/flavors/rke2.md b/docs/src/topics/flavors/rke2.md index 309b33914..be70b6109 100644 --- a/docs/src/topics/flavors/rke2.md +++ b/docs/src/topics/flavors/rke2.md @@ -7,7 +7,7 @@ * [Quickstart](../topics/getting-started.md) completed * Select an [rke2 kubernetes version](https://github.com/rancher/rke2/releases) to set for the kubernetes version ```bash - export KUBERNETES_VERSION=v1.29.1+rke2r1 + export RKE2_KUBERNETES_VERSION=v1.29.1+rke2r1 ``` * Installed [rke2 bootstrap provider](https://github.com/rancher-sandbox/cluster-api-provider-rke2) into your management cluster ```shell diff --git a/templates/flavors/k3s/k3sControlPlane.yaml b/templates/flavors/k3s/k3sControlPlane.yaml index ec81c48f4..0b19633b3 100644 --- a/templates/flavors/k3s/k3sControlPlane.yaml +++ b/templates/flavors/k3s/k3sControlPlane.yaml @@ -47,4 +47,4 @@ spec: - sed -i '/swap/d' /etc/fstab - swapoff -a replicas: ${CONTROL_PLANE_MACHINE_COUNT} - version: ${KUBERNETES_VERSION} + version: ${K3S_KUBERNETES_VERSION} diff --git a/templates/flavors/k3s/kustomization.yaml b/templates/flavors/k3s/kustomization.yaml index 76801b133..82dd783db 100644 --- a/templates/flavors/k3s/kustomization.yaml +++ b/templates/flavors/k3s/kustomization.yaml @@ -22,3 +22,11 @@ patches: - op: replace path: /spec/template/spec/bootstrap/configRef/kind value: KThreesConfigTemplate + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + patch: |- + - op: replace + path: /spec/template/spec/version + value: ${K3S_KUBERNETES_VERSION} diff --git a/templates/flavors/rke2/kustomization.yaml b/templates/flavors/rke2/kustomization.yaml index fdfed62da..34108ba7f 100644 --- a/templates/flavors/rke2/kustomization.yaml +++ b/templates/flavors/rke2/kustomization.yaml @@ -22,3 +22,11 @@ patches: - op: replace path: /spec/template/spec/bootstrap/configRef/kind value: RKE2ConfigTemplate + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + patch: |- + - op: replace + path: /spec/template/spec/version + value: ${RKE2_KUBERNETES_VERSION} diff --git a/templates/flavors/rke2/rke2ConfigTemplate.yaml b/templates/flavors/rke2/rke2ConfigTemplate.yaml index cb559560c..61d2db041 100644 --- a/templates/flavors/rke2/rke2ConfigTemplate.yaml +++ b/templates/flavors/rke2/rke2ConfigTemplate.yaml @@ -7,7 +7,7 @@ spec: template: spec: agentConfig: - version: ${KUBERNETES_VERSION} + version: ${RKE2_KUBERNETES_VERSION} nodeName: '{{ ds.meta_data.label }}' kubelet: extraArgs: diff --git a/templates/flavors/rke2/rke2ControlPlane.yaml b/templates/flavors/rke2/rke2ControlPlane.yaml index 680a7f178..f066303fc 100644 --- a/templates/flavors/rke2/rke2ControlPlane.yaml +++ b/templates/flavors/rke2/rke2ControlPlane.yaml @@ -30,7 +30,7 @@ spec: kubernetesComponents: - "cloudController" agentConfig: - version: ${KUBERNETES_VERSION} + version: ${RKE2_KUBERNETES_VERSION} nodeName: '{{ ds.meta_data.label }}' kubelet: extraArgs: