From 6d15b29ce90c055fd2ba98d28b50578997997f5b Mon Sep 17 00:00:00 2001 From: Mathieu Tortuyaux Date: Thu, 9 Nov 2023 14:56:29 +0100 Subject: [PATCH] kubeadm: install helm via Ignition this can be used to ease the testing of complexe kubernetes deployment Signed-off-by: Mathieu Tortuyaux --- kola/tests/kubeadm/kubeadm.go | 3 +++ kola/tests/kubeadm/kubeadm_test.go | 2 ++ kola/tests/kubeadm/templates.go | 21 +++++++++++++++++++ .../testdata/master-cilium-amd64-config.yml | 21 +++++++++++++++++++ .../testdata/master-cilium-arm64-config.yml | 21 +++++++++++++++++++ 5 files changed, 68 insertions(+) diff --git a/kola/tests/kubeadm/kubeadm.go b/kola/tests/kubeadm/kubeadm.go index 3a0c4d44b..e1e6c8818 100644 --- a/kola/tests/kubeadm/kubeadm.go +++ b/kola/tests/kubeadm/kubeadm.go @@ -76,6 +76,7 @@ var ( // and the nested params are used to render script templates testConfig = map[string]map[string]interface{}{ "v1.28.1": map[string]interface{}{ + "HelmVersion": "v3.13.2", "MinMajorVersion": 3374, // from https://github.com/flannel-io/flannel/releases "FlannelVersion": "v0.22.0", @@ -108,6 +109,7 @@ var ( "cgroupv1": false, }, "v1.27.2": map[string]interface{}{ + "HelmVersion": "v3.13.2", "MinMajorVersion": 3374, // from https://github.com/flannel-io/flannel/releases "FlannelVersion": "v0.22.0", @@ -140,6 +142,7 @@ var ( "cgroupv1": false, }, "v1.26.5": map[string]interface{}{ + "HelmVersion": "v3.13.2", "MinMajorVersion": 3374, // from https://github.com/flannel-io/flannel/releases "FlannelVersion": "v0.20.2", diff --git a/kola/tests/kubeadm/kubeadm_test.go b/kola/tests/kubeadm/kubeadm_test.go index bde20e478..d333ac2d6 100644 --- a/kola/tests/kubeadm/kubeadm_test.go +++ b/kola/tests/kubeadm/kubeadm_test.go @@ -54,6 +54,7 @@ func TestRenderTemplate(t *testing.T) { res, err := render( masterScript, map[string]interface{}{ + "HelmVersion": "1.2.3", "CiliumVersion": "v0.11.1", "FlannelVersion": "v0.14.0", "CNI": CNI, @@ -84,6 +85,7 @@ func TestRenderTemplate(t *testing.T) { res, err := render( masterConfig, map[string]interface{}{ + "HelmVersion": "1.2.3", "CiliumVersion": "v0.11.1", "CNI": "cilium", "CiliumCLIVersion": "v0.9.0", diff --git a/kola/tests/kubeadm/templates.go b/kola/tests/kubeadm/templates.go index 81366b863..6eb4d9970 100644 --- a/kola/tests/kubeadm/templates.go +++ b/kola/tests/kubeadm/templates.go @@ -162,6 +162,21 @@ storage: ExecStart=/usr/bin/rm "/opt/crictl-${CRICTL_VERSION}-linux-{{ .Arch }}.tar.gz" [Install] WantedBy=multi-user.target + - name: prepare-helm.service + enabled: true + contents: | + [Unit] + Description=Unpack helm to /opt/bin + ConditionPathExists=!/opt/bin/helm + [Service] + Type=oneshot + RemainAfterExit=true + Restart=on-failure + ExecStartPre=/usr/bin/mkdir --parents "{{ .DownloadDir }}" + ExecStartPre=/usr/bin/tar -v --extract --file "/opt/helm-{{ .HelmVersion }}-linux-{{ .Arch }}.tar.gz" --directory "{{ .DownloadDir }}" --strip-components=1 --no-same-owner + ExecStart=/usr/bin/rm "/opt/helm-{{ .HelmVersion }}-linux-{{ .Arch }}.tar.gz" + [Install] + WantedBy=multi-user.target storage: files:{{ if .cgroupv1 }} - path: /etc/flatcar-cgroupv1 @@ -216,6 +231,12 @@ storage: hash: function: sha512 sum: {{ index (index . .Arch) "KubectlSum" }} + - path: /opt/helm-{{ .HelmVersion }}-linux-{{ .Arch }}.tar.gz + filesystem: root + mode: 0755 + contents: + remote: + url: https://get.helm.sh/helm-{{ .HelmVersion }}-linux-{{ .Arch }}.tar.gz - path: /etc/docker/daemon.json filesystem: root mode: 0644 diff --git a/kola/tests/kubeadm/testdata/master-cilium-amd64-config.yml b/kola/tests/kubeadm/testdata/master-cilium-amd64-config.yml index 21c2da38b..9c1749719 100644 --- a/kola/tests/kubeadm/testdata/master-cilium-amd64-config.yml +++ b/kola/tests/kubeadm/testdata/master-cilium-amd64-config.yml @@ -34,6 +34,21 @@ systemd: ExecStart=/usr/bin/rm "/opt/crictl-${CRICTL_VERSION}-linux-amd64.tar.gz" [Install] WantedBy=multi-user.target + - name: prepare-helm.service + enabled: true + contents: | + [Unit] + Description=Unpack helm to /opt/bin + ConditionPathExists=!/opt/bin/helm + [Service] + Type=oneshot + RemainAfterExit=true + Restart=on-failure + ExecStartPre=/usr/bin/mkdir --parents "/opt/bin" + ExecStartPre=/usr/bin/tar -v --extract --file "/opt/helm-1.2.3-linux-amd64.tar.gz" --directory "/opt/bin" --strip-components=1 --no-same-owner + ExecStart=/usr/bin/rm "/opt/helm-1.2.3-linux-amd64.tar.gz" + [Install] + WantedBy=multi-user.target storage: files: - path: /opt/cni-plugins-linux-amd64-v0.8.7.tgz @@ -86,6 +101,12 @@ storage: hash: function: sha512 sum: a93b2ca067629cb1fe9cbf1af1a195c12126488ed321e3652200d4dbfee9a577865647b7ef6bb673e1bdf08f03108b5dcb4b05812a649a0de5c7c9efc1407810 + - path: /opt/helm-1.2.3-linux-amd64.tar.gz + filesystem: root + mode: 0755 + contents: + remote: + url: https://get.helm.sh/helm-1.2.3-linux-amd64.tar.gz - path: /etc/docker/daemon.json filesystem: root mode: 0644 diff --git a/kola/tests/kubeadm/testdata/master-cilium-arm64-config.yml b/kola/tests/kubeadm/testdata/master-cilium-arm64-config.yml index 4d2a0396c..2ed77405c 100644 --- a/kola/tests/kubeadm/testdata/master-cilium-arm64-config.yml +++ b/kola/tests/kubeadm/testdata/master-cilium-arm64-config.yml @@ -34,6 +34,21 @@ systemd: ExecStart=/usr/bin/rm "/opt/crictl-${CRICTL_VERSION}-linux-arm64.tar.gz" [Install] WantedBy=multi-user.target + - name: prepare-helm.service + enabled: true + contents: | + [Unit] + Description=Unpack helm to /opt/bin + ConditionPathExists=!/opt/bin/helm + [Service] + Type=oneshot + RemainAfterExit=true + Restart=on-failure + ExecStartPre=/usr/bin/mkdir --parents "/opt/bin" + ExecStartPre=/usr/bin/tar -v --extract --file "/opt/helm-1.2.3-linux-arm64.tar.gz" --directory "/opt/bin" --strip-components=1 --no-same-owner + ExecStart=/usr/bin/rm "/opt/helm-1.2.3-linux-arm64.tar.gz" + [Install] + WantedBy=multi-user.target storage: files: - path: /opt/cni-plugins-linux-arm64-v0.8.7.tgz @@ -86,6 +101,12 @@ storage: hash: function: sha512 sum: b990b81d5a885a9d131aabcc3a5ca9c37dfaff701470f2beb896682a8643c7e0c833e479a26f21129b598ac981732bf52eecdbe73896fe0ff2d9c1ffd082d1fd + - path: /opt/helm-1.2.3-linux-arm64.tar.gz + filesystem: root + mode: 0755 + contents: + remote: + url: https://get.helm.sh/helm-1.2.3-linux-arm64.tar.gz - path: /etc/docker/daemon.json filesystem: root mode: 0644