Skip to content

Commit

Permalink
Refactor kube binary download (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermckinnon authored Dec 3, 2023
1 parent 84f6259 commit 22707fc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ jobs:
- run: make build
build-kubetest2:
runs-on: ubuntu-latest
strategy:
# don't bail out of all sub-tasks if one fails
fail-fast: false
matrix:
k8s_version: ["1.23", "1.24", "1.25", "1.26", "1.27", "1.28"]
steps:
- uses: actions/checkout@v3
- run: docker build --build-arg=KUBERNETES_MINOR_VERSION=${{ matrix.k8s_version }} --file Dockerfile.kubetest2 .
- run: docker build --build-arg=KUBERNETES_MINOR_VERSION=latest --file Dockerfile.kubetest2 .
11 changes: 3 additions & 8 deletions Dockerfile.kubetest2
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,11 @@ RUN wget -O eksctl.tar.gz "https://github.com/eksctl-io/eksctl/releases/${EKSCTL
tar xzf eksctl.tar.gz -C /bin/ && \
rm eksctl.tar.gz
ARG KUBERNETES_MINOR_VERSION
RUN wget -O kubernetes-version.txt https://storage.googleapis.com/kubernetes-release/release/stable-${KUBERNETES_MINOR_VERSION}.txt
COPY hack/download-kubernetes-binaries.sh .
RUN ./download-kubernetes-binaries.sh "${KUBERNETES_MINOR_VERSION}" "${TARGETOS}" "${TARGETARCH}"
RUN mkdir /info
ENV PATH=$PATH:/info
RUN cp kubernetes-version.txt /info/
RUN wget -O kubernetes-client.tar.gz https://storage.googleapis.com/kubernetes-release/release/$(cat kubernetes-version.txt)/kubernetes-client-${TARGETOS}-${TARGETARCH}.tar.gz && \
tar xzf kubernetes-client.tar.gz -C / && \
rm kubernetes-client.tar.gz
RUN wget -O kubernetes-test.tar.gz https://storage.googleapis.com/kubernetes-release/release/$(cat kubernetes-version.txt)/kubernetes-test-${TARGETOS}-${TARGETARCH}.tar.gz && \
tar xzf kubernetes-test.tar.gz -C / && \
rm kubernetes-test.tar.gz
RUN mv /kubernetes/*/bin/* /bin/
RUN mv kubernetes/*/bin/* /bin/
RUN rm -rf /workdir
COPY --from=builder /usr/local/go/bin/* /bin/
39 changes: 39 additions & 0 deletions hack/download-kubernetes-binaries.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset

BUNDLES=(
"kubernetes-client"
"kubernetes-test"
)

if [ "$#" -ne 3 ]; then
echo >&2 "usage: $0 (KUBERNETES_MINOR_VERSION|latest) OS ARCH"
exit 1
fi

if [ "$1" = "latest" ]; then
RELEASE_MARKER="latest.txt"
else
RELEASE_MARKER="latest-$1.txt"
fi

echo >&2 "Release marker: ${RELEASE_MARKER}"

OS="$2"
ARCH="$3"

KUBERNETES_VERSION=$(curl --silent "https://storage.googleapis.com/kubernetes-release/release/${RELEASE_MARKER}")

echo "Kubernetes version: ${KUBERNETES_VERSION}"
echo "${KUBERNETES_VERSION}" > kubernetes-version.txt

for BUNDLE in ${BUNDLES[@]}; do
echo >&2 "Downloading bundle: ${BUNDLE}"
TARBALL="${BUNDLE}.tar.gz"
wget --quiet --output-document=${TARBALL} https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/${BUNDLE}-${OS}-${ARCH}.tar.gz
tar xzf ${TARBALL}
rm ${TARBALL}
done

0 comments on commit 22707fc

Please sign in to comment.