Skip to content

Commit

Permalink
add the ability to download kind/kubectl on macOS GHA runners
Browse files Browse the repository at this point in the history
Important note - This doesn't setup Docker on MacOS.
To setup Docker, you either need to use the Docker Desktop GHA (https://github.com/docker/desktop-action),
or you need to connect your MacOS runner to a remote Docker Daemon.

Signed-off-by: Nick Santos <nick.santos@docker.com>
  • Loading branch information
nicks committed Jul 11, 2023
1 parent dda0770 commit d466ec4
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,27 @@ main() {
exit 1
fi

local arch
case $(uname -m) in
i386) arch="386" ;;
i686) arch="386" ;;
x86_64) arch="amd64" ;;
arm|aarch64) dpkg --print-architecture | grep -q "arm64" && arch="arm64" || arch="arm" ;;
local os="linux"
case $(uname) in
Darwin) os="darwin" ;;
esac
local cache_dir="${RUNNER_TOOL_CACHE}/kind/${version}/${arch}"

local arch
if [[ "$os" == "darwin" ]]; then
case $(uname -m) in
x86_64) arch="amd64" ;;
arm) arch="arm64" ;;
esac
else
case $(uname -m) in
i386) arch="386" ;;
i686) arch="386" ;;
x86_64) arch="amd64" ;;
arm|aarch64) dpkg --print-architecture | grep -q "arm64" && arch="arm64" || arch="arm" ;;
esac
fi

local cache_dir="${RUNNER_TOOL_CACHE}/kind/${version}/${os}/${arch}"

local kind_dir="${cache_dir}/kind/bin/"
if [[ ! -x "${kind_dir}/kind" ]]; then
Expand Down Expand Up @@ -188,7 +201,7 @@ install_kind() {

mkdir -p "${kind_dir}"

curl -sSLo "${kind_dir}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-linux-${arch}"
curl -sSLo "${kind_dir}/kind" "https://github.com/kubernetes-sigs/kind/releases/download/${version}/kind-${os}-${arch}"
chmod +x "${kind_dir}/kind"
}

Expand All @@ -197,7 +210,7 @@ install_kubectl() {

mkdir -p "${kubectl_dir}"

curl -sSLo "${kubectl_dir}/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/linux/${arch}/kubectl"
curl -sSLo "${kubectl_dir}/kubectl" "https://storage.googleapis.com/kubernetes-release/release/${kubectl_version}/bin/${os}/${arch}/kubectl"
chmod +x "${kubectl_dir}/kubectl"
}

Expand Down

0 comments on commit d466ec4

Please sign in to comment.