From a9e06ae98167fa429df4aee759d59bd44915005c Mon Sep 17 00:00:00 2001 From: Yuvraj Date: Wed, 24 Nov 2021 20:21:34 +0530 Subject: [PATCH] Added helm registry in sandbox (#1846) * Added helm registry in sandbox Signed-off-by: Yuvraj * Added build arg in workflow Signed-off-by: Yuvraj * fix typo Signed-off-by: Yuvraj --- .github/workflows/sandbox.yml | 10 ++++++++++ docker/sandbox/Dockerfile | 10 ++++++++-- docker/sandbox/flyte-entrypoint-default.sh | 12 ++++++++++-- docker/sandbox/flyte-entrypoint-dind.sh | 12 ++++++++++-- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sandbox.yml b/.github/workflows/sandbox.yml index 129aa2db35..3f6d6ca467 100644 --- a/.github/workflows/sandbox.yml +++ b/.github/workflows/sandbox.yml @@ -13,6 +13,14 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: "0" + - name: Set flyte version to release + id: set_version + run: | + if [ ${{ github.event_name}} = "release" ]; then + echo ::set-output name=flyte_version::$(echo ${{ github.event.release.tag_name }}) + else + echo ::set-output name=flyte_version::latest + fi - name: Prepare sandbox Image Names id: sandbox-names uses: docker/metadata-action@v3 @@ -59,6 +67,7 @@ jobs: platforms: linux/arm64, linux/amd64 push: ${{ github.event_name == 'release' }} target: default + build-args: "FLYTE_VERSION=${{ steps.set_version.outputs.flyte_version }}" tags: ${{ steps.sandbox-names.outputs.tags }} file: docker/sandbox/Dockerfile cache-from: type=local,src=/tmp/.buildx-cache @@ -71,6 +80,7 @@ jobs: push: ${{ github.event_name == 'release' }} target: dind tags: ${{ steps.dind-names.outputs.tags }} + build-args: "FLYTE_VERSION=${{ steps.set_version.outputs.flyte_version }}" file: docker/sandbox/Dockerfile cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new diff --git a/docker/sandbox/Dockerfile b/docker/sandbox/Dockerfile index 8776956dbf..e3b30ed6e1 100644 --- a/docker/sandbox/Dockerfile +++ b/docker/sandbox/Dockerfile @@ -59,12 +59,15 @@ COPY docker/sandbox/kubectl docker/sandbox/cgroup-v2-hack.sh docker/sandbox/wait FROM base_ AS default # Install dependencies -RUN apk add --no-cache bash git make tini +RUN apk add --no-cache bash git make tini curl jq # Copy entrypoints COPY docker/sandbox/flyte-entrypoint-default.sh /flyteorg/bin/flyte-entrypoint.sh COPY docker/sandbox/bashrc /root/.bashrc +ARG FLYTE_VERSION="latest" +ENV FLYTE_VERSION "${FLYTE_VERSION}" + # Update PATH variable ENV PATH "/flyteorg/bin:${PATH}" @@ -83,7 +86,7 @@ ENTRYPOINT ["tini", "flyte-entrypoint.sh"] FROM docker:20.10.8-dind AS dind # Install dependencies -RUN apk add --no-cache bash git make tini +RUN apk add --no-cache bash git make tini curl jq # Copy artifacts from base COPY --from=base_ /flyteorg/ /flyteorg/ @@ -91,6 +94,9 @@ COPY --from=base_ /flyteorg/ /flyteorg/ # Copy entrypoints COPY docker/sandbox/flyte-entrypoint-dind.sh /flyteorg/bin/flyte-entrypoint.sh +ARG FLYTE_VERSION="latest" +ENV FLYTE_VERSION "${FLYTE_VERSION}" + # Update PATH variable ENV PATH "/flyteorg/bin:${PATH}" diff --git a/docker/sandbox/flyte-entrypoint-default.sh b/docker/sandbox/flyte-entrypoint-default.sh index a30293e6a9..48ce51827d 100755 --- a/docker/sandbox/flyte-entrypoint-default.sh +++ b/docker/sandbox/flyte-entrypoint-default.sh @@ -15,10 +15,18 @@ K3S_PID=$! timeout 600 sh -c "until k3s kubectl explain deployment &> /dev/null; do sleep 1; done" || ( echo >&2 "Timed out while waiting for the Kubernetes cluster to start"; exit 1 ) echo "Done." +FLYTE_VERSION=${FLYTE_VERSION:-latest} +if [[ $FLYTE_VERSION = "latest" ]] +then + FLYTE_VERSION=$(curl --silent "https://api.github.com/repos/flyteorg/flyte/releases/latest" | jq -r .tag_name) +fi + # Deploy flyte echo "Deploying Flyte..." -helm dep update /flyteorg/share/flyte/ -helm upgrade -n flyte -f /flyteorg/share/flyte/values-sandbox.yaml --create-namespace flyte /flyteorg/share/flyte --kubeconfig /etc/rancher/k3s/k3s.yaml --install +helm repo add flyteorg https://flyteorg.github.io/flyte +helm repo update +helm fetch flyteorg/flyte --version=$FLYTE_VERSION +helm upgrade -n flyte -f /flyteorg/share/flyte/values-sandbox.yaml --create-namespace flyte flyteorg/flyte --kubeconfig /etc/rancher/k3s/k3s.yaml --install --version $FLYTE_VERSION wait-for-flyte.sh diff --git a/docker/sandbox/flyte-entrypoint-dind.sh b/docker/sandbox/flyte-entrypoint-dind.sh index 8b037765bc..bfd66496cb 100755 --- a/docker/sandbox/flyte-entrypoint-dind.sh +++ b/docker/sandbox/flyte-entrypoint-dind.sh @@ -32,10 +32,18 @@ K3S_PID=$! timeout 600 sh -c "until k3s kubectl explain deployment &> /dev/null; do sleep 1; done" || ( echo >&2 "Timed out while waiting for the Kubernetes cluster to start"; exit 1 ) echo "Done." +FLYTE_VERSION=${FLYTE_VERSION:-latest} +if [[ $FLYTE_VERSION = "latest" ]] +then + FLYTE_VERSION=$(curl --silent "https://api.github.com/repos/flyteorg/flyte/releases/latest" | jq -r .tag_name) +fi + # Deploy flyte echo "Deploying Flyte..." -helm dep update /flyteorg/share/flyte/ -helm upgrade -n flyte -f /flyteorg/share/flyte/values-sandbox.yaml --create-namespace flyte /flyteorg/share/flyte --kubeconfig /etc/rancher/k3s/k3s.yaml --install +helm repo add flyteorg https://flyteorg.github.io/flyte +helm repo update +helm fetch flyteorg/flyte --version=$FLYTE_VERSION +helm upgrade -n flyte -f /flyteorg/share/flyte/values-sandbox.yaml --create-namespace flyte flyteorg/flyte --kubeconfig /etc/rancher/k3s/k3s.yaml --install --version $FLYTE_VERSION wait-for-flyte.sh