From 54a5c1ff93c5eee9c966e62f8deb8951df50de6c Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:15:37 +0200 Subject: [PATCH] ci: switch to reusable workflow to install k3s Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/e2e.yml | 62 ++------------------------------------- 1 file changed, 2 insertions(+), 60 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 279dfe0cd40..eaf9a768ff2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -132,67 +132,9 @@ jobs: - name: Install k3s if: matrix.driver == 'kubernetes' - uses: actions/github-script@v7 + uses: crazy-max/.github/.github/actions/install-k3s@fa6141aedf23596fb8bdcceab9cce8dadaa31bd9 with: - script: | - const fs = require('fs'); - - let wait = function(milliseconds) { - return new Promise((resolve, reject) => { - if (typeof(milliseconds) !== 'number') { - throw new Error('milleseconds not a number'); - } - setTimeout(() => resolve("done!"), milliseconds) - }); - } - - try { - const kubeconfig="/tmp/buildkit-k3s/kubeconfig.yaml"; - core.info(`storing kubeconfig in ${kubeconfig}`); - - await exec.exec('docker', ["run", "-d", - "--privileged", - "--name=buildkit-k3s", - "-e", "K3S_KUBECONFIG_OUTPUT="+kubeconfig, - "-e", "K3S_KUBECONFIG_MODE=666", - "-v", "/tmp/buildkit-k3s:/tmp/buildkit-k3s", - "-p", "6443:6443", - "-p", "80:80", - "-p", "443:443", - "-p", "8080:8080", - "rancher/k3s:${{ env.K3S_VERSION }}", "server" - ]); - await wait(10000); - - core.exportVariable('KUBECONFIG', kubeconfig); - - let nodeName; - for (let count = 1; count <= 5; count++) { - try { - const nodeNameOutput = await exec.getExecOutput("kubectl get nodes --no-headers -oname"); - nodeName = nodeNameOutput.stdout - } catch (error) { - core.info(`Unable to resolve node name (${error.message}). Attempt ${count} of 5.`) - } finally { - if (nodeName) { - break; - } - await wait(5000); - } - } - if (!nodeName) { - throw new Error(`Unable to resolve node name after 5 attempts.`); - } - - await exec.exec(`kubectl wait --for=condition=Ready ${nodeName}`); - } catch (error) { - core.setFailed(error.message); - } - - - name: Print KUBECONFIG - if: matrix.driver == 'kubernetes' - run: | - yq ${{ env.KUBECONFIG }} + version: ${{ env.K3S_VERSION }} - name: Launch remote buildkitd if: matrix.driver == 'remote'