Skip to content

Commit

Permalink
PE-4942 define k8s version json (#266)
Browse files Browse the repository at this point in the history
* define k8s version json

Signed-off-by: Nianyu Shen <[email protected]>

* add K8S_DISTRIBUTION check

Signed-off-by: Nianyu Shen <[email protected]>

* fix merge

Signed-off-by: Nianyu Shen <[email protected]>

---------

Signed-off-by: Nianyu Shen <[email protected]>
  • Loading branch information
nianyush authored Sep 3, 2024
1 parent 636c039 commit 30e1bb7
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 157 deletions.
188 changes: 31 additions & 157 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ ARG TARGETARCH

# Default image repositories used in the builds.
ARG SPECTRO_PUB_REPO=gcr.io/spectro-images-public
ARG ALPINE_IMG=$SPECTRO_PUB_REPO/alpine:3.20.2
ARG SPECTRO_LUET_REPO=gcr.io/spectro-dev-public
ARG KAIROS_BASE_IMAGE_URL=gcr.io/spectro-images-public
ARG ETCD_REPO=https://github.com/etcd-io
ARG LUET_PROJECT=luet-repo
FROM $SPECTRO_PUB_REPO/canvos/alpine-cert:v1.0.0
ARG ALPINE_TAG=3.20
ARG ALPINE_IMG=$SPECTRO_PUB_REPO/canvos/alpine:$ALPINE_TAG
FROM $ALPINE_IMG

# Spectro Cloud and Kairos tags.
ARG PE_VERSION=v4.4.8
Expand Down Expand Up @@ -118,6 +119,16 @@ END
ARG IMAGE_PATH=$IMAGE_REGISTRY/$IMAGE_REPO:$K8S_DISTRIBUTION-$K8S_VERSION-$IMAGE_TAG
ARG CMDLINE="stylus.registration"

alpine-all:
BUILD --platform=linux/amd64 --platform=linux/arm64 +alpine

alpine:
FROM alpine:$ALPINE_TAG
RUN apk add --no-cache bash curl jq ca-certificates upx
RUN update-ca-certificates

SAVE IMAGE --push gcr.io/spectro-dev-public/canvos/alpine:$ALPINE_TAG

build-all-images:
IF $FIPS_ENABLED
BUILD +build-provider-images-fips
Expand All @@ -133,170 +144,33 @@ build-all-images:
END

build-provider-images:
FROM $ALPINE_IMG

IF [ !-n "$K8S_DISTRIBUTION"]
RUN echo "K8S_DISTRIBUTION is not set. Please set K8S_DISTRIBUTION to kubeadm, kubeadm-fips, k3s, or rke2." && exit 1
END

IF [ "$IS_UKI" = "true" ]
ARG TARGET=uki-provider-image
ELSE
ARG TARGET=provider-image
END
IF [ "$K8S_VERSION" = "" ]
IF [ "$K8S_DISTRIBUTION" = "kubeadm" ]
BUILD +$TARGET --K8S_VERSION=1.24.6
BUILD +$TARGET --K8S_VERSION=1.25.2
BUILD +$TARGET --K8S_VERSION=1.25.13
BUILD +$TARGET --K8S_VERSION=1.25.15
BUILD +$TARGET --K8S_VERSION=1.26.4
BUILD +$TARGET --K8S_VERSION=1.26.8
BUILD +$TARGET --K8S_VERSION=1.26.10
BUILD +$TARGET --K8S_VERSION=1.26.12
BUILD +$TARGET --K8S_VERSION=1.26.15
BUILD +$TARGET --K8S_VERSION=1.27.2
BUILD +$TARGET --K8S_VERSION=1.27.5
BUILD +$TARGET --K8S_VERSION=1.27.7
BUILD +$TARGET --K8S_VERSION=1.27.9
BUILD +$TARGET --K8S_VERSION=1.27.11
BUILD +$TARGET --K8S_VERSION=1.27.15
BUILD +$TARGET --K8S_VERSION=1.27.16
BUILD +$TARGET --K8S_VERSION=1.28.2
BUILD +$TARGET --K8S_VERSION=1.28.5
BUILD +$TARGET --K8S_VERSION=1.28.9
BUILD +$TARGET --K8S_VERSION=1.28.11
BUILD +$TARGET --K8S_VERSION=1.28.12
BUILD +$TARGET --K8S_VERSION=1.28.13
BUILD +$TARGET --K8S_VERSION=1.29.0
BUILD +$TARGET --K8S_VERSION=1.29.6
BUILD +$TARGET --K8S_VERSION=1.29.7
BUILD +$TARGET --K8S_VERSION=1.29.8
BUILD +$TARGET --K8S_VERSION=1.30.4
ELSE IF [ "$K8S_DISTRIBUTION" = "rke2" ]
BUILD +$TARGET --K8S_VERSION=1.24.6
BUILD +$TARGET --K8S_VERSION=1.25.2
BUILD +$TARGET --K8S_VERSION=1.25.13
BUILD +$TARGET --K8S_VERSION=1.25.15
BUILD +$TARGET --K8S_VERSION=1.26.4
BUILD +$TARGET --K8S_VERSION=1.26.8
BUILD +$TARGET --K8S_VERSION=1.26.10
BUILD +$TARGET --K8S_VERSION=1.26.12
BUILD +$TARGET --K8S_VERSION=1.26.14
BUILD +$TARGET --K8S_VERSION=1.26.15
BUILD +$TARGET --K8S_VERSION=1.27.2
BUILD +$TARGET --K8S_VERSION=1.27.5
BUILD +$TARGET --K8S_VERSION=1.27.7
BUILD +$TARGET --K8S_VERSION=1.27.9
BUILD +$TARGET --K8S_VERSION=1.27.11
BUILD +$TARGET --K8S_VERSION=1.27.13
BUILD +$TARGET --K8S_VERSION=1.27.14
BUILD +$TARGET --K8S_VERSION=1.27.15
BUILD +$TARGET --K8S_VERSION=1.28.2
BUILD +$TARGET --K8S_VERSION=1.28.5
BUILD +$TARGET --K8S_VERSION=1.28.7
BUILD +$TARGET --K8S_VERSION=1.28.9
BUILD +$TARGET --K8S_VERSION=1.28.10
BUILD +$TARGET --K8S_VERSION=1.28.11
BUILD +$TARGET --K8S_VERSION=1.28.12
BUILD +$TARGET --K8S_VERSION=1.29.3
BUILD +$TARGET --K8S_VERSION=1.29.4
BUILD +$TARGET --K8S_VERSION=1.29.5
BUILD +$TARGET --K8S_VERSION=1.29.6
BUILD +$TARGET --K8S_VERSION=1.29.7
BUILD +$TARGET --K8S_VERSION=1.30.3
ELSE IF [ "$K8S_DISTRIBUTION" = "k3s" ]
BUILD +$TARGET --K8S_VERSION=1.24.6
BUILD +$TARGET --K8S_VERSION=1.25.2
BUILD +$TARGET --K8S_VERSION=1.25.13
BUILD +$TARGET --K8S_VERSION=1.25.15
BUILD +$TARGET --K8S_VERSION=1.26.4
BUILD +$TARGET --K8S_VERSION=1.26.8
BUILD +$TARGET --K8S_VERSION=1.26.10
BUILD +$TARGET --K8S_VERSION=1.26.14
BUILD +$TARGET --K8S_VERSION=1.27.2
BUILD +$TARGET --K8S_VERSION=1.27.5
BUILD +$TARGET --K8S_VERSION=1.27.7
BUILD +$TARGET --K8S_VERSION=1.27.11
BUILD +$TARGET --K8S_VERSION=1.27.15
BUILD +$TARGET --K8S_VERSION=1.28.2
BUILD +$TARGET --K8S_VERSION=1.28.7
BUILD +$TARGET --K8S_VERSION=1.28.11
BUILD +$TARGET --K8S_VERSION=1.28.13
BUILD +$TARGET --K8S_VERSION=1.29.2
BUILD +$TARGET --K8S_VERSION=1.29.6
BUILD +$TARGET --K8S_VERSION=1.29.8
BUILD +$TARGET --K8S_VERSION=1.30.4
END
ELSE
BUILD +$TARGET --K8S_VERSION="$K8S_VERSION"
END

build-provider-images-fips:
IF [ "$K8S_VERSION" = "" ]
IF [ "$K8S_DISTRIBUTION" = "kubeadm-fips" ]
BUILD +provider-image --K8S_VERSION=1.24.13
BUILD +provider-image --K8S_VERSION=1.25.9
BUILD +provider-image --K8S_VERSION=1.26.4
BUILD +provider-image --K8S_VERSION=1.26.12
BUILD +provider-image --K8S_VERSION=1.26.15
BUILD +provider-image --K8S_VERSION=1.27.2
BUILD +provider-image --K8S_VERSION=1.27.9
BUILD +provider-image --K8S_VERSION=1.27.14
BUILD +provider-image --K8S_VERSION=1.27.15
BUILD +provider-image --K8S_VERSION=1.27.16
BUILD +provider-image --K8S_VERSION=1.28.5
BUILD +provider-image --K8S_VERSION=1.28.10
BUILD +provider-image --K8S_VERSION=1.28.11
BUILD +provider-image --K8S_VERSION=1.28.12
BUILD +provider-image --K8S_VERSION=1.28.13
BUILD +provider-image --K8S_VERSION=1.29.0
BUILD +provider-image --K8S_VERSION=1.29.5
BUILD +provider-image --K8S_VERSION=1.29.6
BUILD +provider-image --K8S_VERSION=1.29.7
BUILD +provider-image --K8S_VERSION=1.29.8
BUILD +provider-image --K8S_VERSION=1.30.4
ELSE IF [ "$K8S_DISTRIBUTION" = "rke2" ]
BUILD +provider-image --K8S_VERSION=1.24.6
BUILD +provider-image --K8S_VERSION=1.25.0
BUILD +provider-image --K8S_VERSION=1.25.2
BUILD +provider-image --K8S_VERSION=1.26.4
BUILD +provider-image --K8S_VERSION=1.26.12
BUILD +provider-image --K8S_VERSION=1.26.14
BUILD +provider-image --K8S_VERSION=1.27.2
BUILD +provider-image --K8S_VERSION=1.27.9
BUILD +provider-image --K8S_VERSION=1.27.11
BUILD +provider-image --K8S_VERSION=1.27.14
BUILD +provider-image --K8S_VERSION=1.27.15
BUILD +provider-image --K8S_VERSION=1.28.5
BUILD +provider-image --K8S_VERSION=1.28.7
BUILD +provider-image --K8S_VERSION=1.28.10
BUILD +provider-image --K8S_VERSION=1.28.11
BUILD +provider-image --K8S_VERSION=1.28.12
BUILD +provider-image --K8S_VERSION=1.29.0
BUILD +provider-image --K8S_VERSION=1.29.3
BUILD +provider-image --K8S_VERSION=1.29.5
BUILD +provider-image --K8S_VERSION=1.29.6
BUILD +provider-image --K8S_VERSION=1.29.7
BUILD +provider-image --K8S_VERSION=1.30.4
ELSE
BUILD +provider-image --K8S_VERSION=1.24.6
BUILD +provider-image --K8S_VERSION=1.25.2
BUILD +provider-image --K8S_VERSION=1.26.4
BUILD +provider-image --K8S_VERSION=1.26.12
BUILD +provider-image --K8S_VERSION=1.26.14
BUILD +provider-image --K8S_VERSION=1.27.2
BUILD +provider-image --K8S_VERSION=1.27.9
BUILD +provider-image --K8S_VERSION=1.27.11
BUILD +provider-image --K8S_VERSION=1.27.15
BUILD +provider-image --K8S_VERSION=1.28.5
BUILD +provider-image --K8S_VERSION=1.28.7
BUILD +provider-image --K8S_VERSION=1.28.11
BUILD +provider-image --K8S_VERSION=1.29.0
BUILD +provider-image --K8S_VERSION=1.29.2
BUILD +provider-image --K8S_VERSION=1.29.6
BUILD +provider-image --K8S_VERSION=1.28.13
BUILD +provider-image --K8S_VERSION=1.29.8
BUILD +provider-image --K8S_VERSION=1.30.4
WORKDIR /workdir
COPY k8s_version.json k8s_version.json
ENV K8S_DISTRIBUTION=$K8S_DISTRIBUTION
RUN jq -r ".$K8S_DISTRIBUTION[]" k8s_version.json > k8s_version.txt
FOR version IN $(cat k8s_version.txt)
BUILD +$TARGET --K8S_VERSION=$version
END
ELSE
BUILD +provider-image --K8S_VERSION="$K8S_VERSION"
BUILD +$TARGET --K8S_VERSION=$K8S_VERSION
END

build-provider-images-fips:
BUILD +build-provider-images

BASE_ALPINE:
COMMAND
IF [ ! -z $PROXY_CERT_PATH ]
Expand Down Expand Up @@ -534,6 +408,7 @@ uki-genkey:
END

download-sbctl:
FROM $ALPINE_IMG
DO +BASE_ALPINE
RUN curl -Ls https://github.com/Foxboron/sbctl/releases/download/0.13/sbctl-0.13-linux-amd64.tar.gz | tar -xvzf - && mv sbctl/sbctl /usr/bin/sbctl
SAVE ARTIFACT /usr/bin/sbctl
Expand Down Expand Up @@ -1008,9 +883,8 @@ download-third-party:
SAVE ARTIFACT /binaries/${binary}/latest/$BIN_TYPE/$TARGETARCH/${binary}.version ${binary}.version

third-party:
DO +BASE_ALPINE
FROM $ALPINE_IMG
ARG binary
RUN apk add upx
WORKDIR /WORKDIR

COPY (+download-third-party/${binary} --binary=${binary}) /WORKDIR/${binary}
Expand Down
106 changes: 106 additions & 0 deletions k8s_version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"k3s": [
"1.24.6",
"1.25.2",
"1.26.4",
"1.26.12",
"1.26.14",
"1.27.2",
"1.27.9",
"1.27.11",
"1.27.15",
"1.28.5",
"1.28.7",
"1.28.11",
"1.28.13",
"1.29.0",
"1.29.2",
"1.29.6",
"1.29.8",
"1.30.4"
],
"kubeadm": [
"1.24.6",
"1.25.2",
"1.25.13",
"1.25.15",
"1.26.4",
"1.26.8",
"1.26.10",
"1.26.12",
"1.26.15",
"1.27.2",
"1.27.5",
"1.27.7",
"1.27.9",
"1.27.11",
"1.27.15",
"1.27.16",
"1.28.2",
"1.28.5",
"1.28.9",
"1.28.11",
"1.28.12",
"1.28.13",
"1.29.0",
"1.29.6",
"1.29.7",
"1.29.8",
"1.30.4"
],
"rke2": [
"1.24.6",
"1.25.2",
"1.25.13",
"1.26.4",
"1.26.8",
"1.26.10",
"1.26.12",
"1.26.14",
"1.26.15",
"1.27.2",
"1.27.5",
"1.27.7",
"1.27.9",
"1.27.11",
"1.27.13",
"1.27.14",
"1.27.15",
"1.28.2",
"1.28.5",
"1.28.7",
"1.28.9",
"1.28.10",
"1.28.11",
"1.28.12",
"1.29.3",
"1.29.4",
"1.29.5",
"1.29.6",
"1.29.7",
"1.30.3"
],
"kubeadm-fips": [
"1.24.13",
"1.25.9",
"1.26.4",
"1.26.12",
"1.26.15",
"1.27.2",
"1.27.9",
"1.27.14",
"1.27.15",
"1.27.16",
"1.28.5",
"1.28.10",
"1.28.11",
"1.28.12",
"1.28.13",
"1.29.0",
"1.29.5",
"1.29.6",
"1.29.7",
"1.29.8",
"1.30.4"
]
}

0 comments on commit 30e1bb7

Please sign in to comment.