From 5f581a5b52a63376b571fe9e347cf707acf56840 Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Mon, 8 Apr 2024 17:34:19 +0800 Subject: [PATCH] Promote binary runtime for all --- .github/workflows/test.yaml | 16 ---------------- pkg/config/vars.go | 18 ++++++++++++++---- pkg/consts/consts.go | 7 ++++--- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5bef3b863c..d63410e34e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -176,22 +176,6 @@ jobs: run: | brew install coreutils bash - # No binary is provided by default for control plane components outside of Linux - # https://kwok.sigs.k8s.io/docs/user/kwokctl-platform-specific-binaries/ - - name: Setup Kubernetes Binary - if: ${{ matrix.kwokctl-runtime == 'binary' && matrix.os != 'ubuntu-latest' }} - shell: bash - env: - KUBE_VERSION: v1.29.0 - run: | - mkdir -p "${GITHUB_WORKSPACE//\\//}/workdir" - cat << EOF >"${GITHUB_WORKSPACE//\\//}/workdir/kwok.yaml" - kind: KwokctlConfiguration - apiVersion: config.kwok.x-k8s.io/v1alpha1 - options: - kubeBinaryPrefix: "https://github.com/kwok-ci/k8s/releases/download/${KUBE_VERSION}-kwok.0-$(go env GOOS)-$(go env GOARCH)" - EOF - # TODO: workaround for https://github.com/actions/runner-images/issues/7753 (caused by https://bugs.launchpad.net/ubuntu/+source/libpod/+bug/2024394). # Remove this when this issue is fixed and available in the ubuntu runner image - name: Setup Podman for Ubuntu diff --git a/pkg/config/vars.go b/pkg/config/vars.go index 00bf9ed1eb..d934636ef2 100644 --- a/pkg/config/vars.go +++ b/pkg/config/vars.go @@ -202,9 +202,11 @@ func setKwokctlConfigurationDefaults(config *configv1alpha1.KwokctlConfiguration conf.Runtimes = append(conf.Runtimes, consts.RuntimeTypePodman, consts.RuntimeTypeNerdctl, - consts.RuntimeTypeBinary, ) } + conf.Runtimes = append(conf.Runtimes, + consts.RuntimeTypeBinary, + ) } if conf.Runtime == "" && len(conf.Runtimes) == 1 { conf.Runtime = conf.Runtimes[0] @@ -275,13 +277,21 @@ func setKwokctlKubernetesConfig(conf *configv1alpha1.KwokctlConfigurationOptions conf.KubeAuditPolicy = envs.GetEnvWithPrefix("KUBE_AUDIT_POLICY", conf.KubeAuditPolicy) - if conf.KubeBinaryPrefix == "" { - conf.KubeBinaryPrefix = consts.KubeBinaryPrefix + "/" + conf.KubeVersion + "/bin/" + GOOS + "/" + GOARCH + // kubectl is provided to be used directly by default. + kubeBinaryPrefix := conf.KubeBinaryPrefix + + if kubeBinaryPrefix == "" { + kubeBinaryPrefix = consts.KubeBinaryPrefix + "/" + conf.KubeVersion + "/bin/" + GOOS + "/" + GOARCH + if GOOS == linux { + conf.KubeBinaryPrefix = kubeBinaryPrefix + } else { + conf.KubeBinaryPrefix = consts.KubeBinaryUnofficialPrefix + "/" + conf.KubeVersion + "-kwok.0-" + GOOS + "-" + GOARCH + } } conf.KubeBinaryPrefix = envs.GetEnvWithPrefix("KUBE_BINARY_PREFIX", conf.KubeBinaryPrefix) if conf.KubectlBinary == "" { - conf.KubectlBinary = conf.KubeBinaryPrefix + "/kubectl" + conf.BinSuffix + conf.KubectlBinary = kubeBinaryPrefix + "/kubectl" + conf.BinSuffix } conf.KubectlBinary = envs.GetEnvWithPrefix("KUBECTL_BINARY", conf.KubectlBinary) diff --git a/pkg/consts/consts.go b/pkg/consts/consts.go index 351f36d82f..0891023337 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -34,9 +34,10 @@ var ( // KubeVersion is the version of Kubernetes. // It will be overwritten during the `make build` process. - KubeVersion = "1.29.0" - KubeBinaryPrefix = "https://dl.k8s.io/release" - KubeImagePrefix = "registry.k8s.io" + KubeVersion = "1.29.0" + KubeBinaryPrefix = "https://dl.k8s.io/release" + KubeBinaryUnofficialPrefix = "https://github.com/kwok-ci/k8s/releases/download" + KubeImagePrefix = "registry.k8s.io" EtcdBinaryPrefix = "https://github.com/etcd-io/etcd/releases/download"