Skip to content

Commit

Permalink
build: Move to the new Kubernetes upstream repository
Browse files Browse the repository at this point in the history
  • Loading branch information
TeddyAndrieux committed Jul 22, 2024
1 parent 3a96c62 commit b8b7555
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 28 deletions.
6 changes: 4 additions & 2 deletions buildchain/buildchain/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ def _builder_image(name: str, dockerfile: Path, **kwargs: Any) -> LocalImage:
REDHAT_REPOS_ROOT / "saltstack.repo",
],
build_args={
# Used to template the SaltStack repository definition
# Used to template the repository definition
"SALT_VERSION": versions.SALT_VERSION,
"K8S_SHORT_VERSION": versions.K8S_SHORT_VERSION,
},
),
"8": _builder_image(
Expand All @@ -68,8 +69,9 @@ def _builder_image(name: str, dockerfile: Path, **kwargs: Any) -> LocalImage:
REDHAT_REPOS_ROOT / "saltstack.repo",
],
build_args={
# Used to template the SaltStack repository definition
# Used to template the repository definition
"SALT_VERSION": versions.SALT_VERSION,
"K8S_SHORT_VERSION": versions.K8S_SHORT_VERSION,
},
),
}
Expand Down
3 changes: 2 additions & 1 deletion buildchain/buildchain/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ def _local_image(name: str, **kwargs: Any) -> targets.LocalImage:
"VCS_REF": constants.GIT_REF or "<unknown>",
"METALK8S_VERSION": versions.VERSION,
"SALT_VERSION": versions.SALT_VERSION,
"KUBERNETES_VERSION": versions.K8S_VERSION,
"K8S_SHORT_VERSION": versions.K8S_SHORT_VERSION,
"K8S_VERSION": versions.K8S_VERSION,
"ETCD_VERSION": f"v{versions.ETCD_VERSION}",
},
),
Expand Down
8 changes: 7 additions & 1 deletion buildchain/buildchain/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@

# Project-wide versions {{{

K8S_VERSION_MAJOR: str = "1"
K8S_VERSION_MINOR: str = "24"
K8S_VERSION_PATCH: str = "6"

K8S_SHORT_VERSION: str = f"{K8S_VERSION_MAJOR}.{K8S_VERSION_MINOR}"
K8S_VERSION: str = f"{K8S_SHORT_VERSION}.{K8S_VERSION_PATCH}"

CALICO_VERSION: str = "3.24.1"
K8S_VERSION: str = "1.24.6"
SALT_VERSION: str = "3002.9"
CONTAINERD_VERSION: str = "1.6.8"

Expand Down
7 changes: 4 additions & 3 deletions images/metalk8s-utils/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ ARG BASE_IMAGE=docker.io/rockylinux
FROM $BASE_IMAGE@sha256:$BASE_IMAGE_SHA256

# Kubernetes version
ARG KUBERNETES_VERSION
ARG K8S_SHORT_VERSION
ARG K8S_VERSION
# Salt version
ARG SALT_VERSION
# Etcd version
ARG ETCD_VERSION

COPY configure-repos.sh /
RUN /configure-repos.sh $SALT_VERSION && rm /configure-repos.sh
RUN /configure-repos.sh "$K8S_SHORT_VERSION" "$SALT_VERSION" && rm /configure-repos.sh

# Timestamp of the build, formatted as RFC3339
ARG BUILD_DATE
Expand Down Expand Up @@ -80,7 +81,7 @@ RUN dnf clean expire-cache && \
iptables \
ipvsadm \
jq \
"kubectl-${KUBERNETES_VERSION}" \
"kubectl-${K8S_VERSION}" \
less \
lsof \
ltrace \
Expand Down
9 changes: 4 additions & 5 deletions images/metalk8s-utils/configure-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

set -xue -o pipefail

SALT_VERSION=$1
K8S_SHORT_VERSION=$1
SALT_VERSION=$2

cat > /etc/yum.repos.d/kubernetes.repo << EOF
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
baseurl=https://pkgs.k8s.io/core:/stable:/v$K8S_SHORT_VERSION/rpm/
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
gpgkey=https://pkgs.k8s.io/core:/stable:/v$K8S_SHORT_VERSION/rpm/repodata/repomd.xml.key
EOF

cat > /etc/yum.repos.d/saltstack.repo << EOF
Expand Down
2 changes: 2 additions & 0 deletions packages/redhat/7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ARG BUILD_IMAGE=docker.io/centos
FROM ${BUILD_IMAGE}@sha256:${BUILD_IMAGE_SHA256} as build

ARG SALT_VERSION
ARG K8S_SHORT_VERSION
ARG GO_VERSION=1.16.14

# CentOS 7 is EOL and mirrorlist does no longer exists
Expand All @@ -14,6 +15,7 @@ RUN sed -i 's/^mirrorlist=/#mirrorlist=/; s/^#baseurl=/baseurl=/; s/mirror\.cent

ADD common/yum_repositories/*.repo /etc/yum.repos.d/
RUN sed -i s/@SALT_VERSION@/$SALT_VERSION/ /etc/yum.repos.d/saltstack.repo
RUN sed -i s/@K8S_SHORT_VERSION@/$K8S_SHORT_VERSION/ /etc/yum.repos.d/kubernetes.repo

ENV GOROOT /usr/local/go

Expand Down
2 changes: 2 additions & 0 deletions packages/redhat/8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ FROM ${BUILD_IMAGE}@sha256:${BUILD_IMAGE_SHA256} as build
RUN useradd -m build

ARG SALT_VERSION
ARG K8S_SHORT_VERSION
ARG GO_VERSION=1.16.14

ADD common/yum_repositories/*.repo /etc/yum.repos.d/
RUN sed -i s/@SALT_VERSION@/$SALT_VERSION/ /etc/yum.repos.d/saltstack.repo
RUN sed -i s/@K8S_SHORT_VERSION@/$K8S_SHORT_VERSION/ /etc/yum.repos.d/kubernetes.repo

ENV GOPATH /go
ENV GOROOT /usr/local/go
Expand Down
5 changes: 3 additions & 2 deletions packages/redhat/common/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ download_repository_gpg_keys() {
for key_id in "${!gpg_keys[@]}"; do
gpg_key=RPM-GPG-KEY-metalk8s-$repo_name-${releasever}_$((
key_id + 1 ))
curl -s "${gpg_keys[$key_id]}" > "$gpg_key"
curl -Ls "${gpg_keys[$key_id]}" > "$gpg_key"
chown "$TARGET_UID:$TARGET_GID" "$gpg_key"
done
fi
Expand Down Expand Up @@ -205,7 +205,8 @@ download_packages() {
;;
esac

yumdownloader --disablerepo="*" \
yumdownloader --arch="x86_64,noarch" \
--disablerepo="*" \
--enablerepo="$repo" "${dependencies[@]}"
done

Expand Down
6 changes: 2 additions & 4 deletions packages/redhat/common/yum_repositories/kubernetes.repo
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
baseurl=https://pkgs.k8s.io/core:/stable:/v@K8S_SHORT_VERSION@/rpm/
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
gpgkey=https://pkgs.k8s.io/core:/stable:/v@K8S_SHORT_VERSION@/rpm/repodata/repomd.xml.key
2 changes: 0 additions & 2 deletions salt/metalk8s/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
'gpgcheck': 1,
'gpgkeys': [
'RPM-GPG-KEY-metalk8s-kubernetes-7_1',
'RPM-GPG-KEY-metalk8s-kubernetes-7_2',
],
'repo_gpg_check': 0,
'enabled': 1,
Expand Down Expand Up @@ -136,7 +135,6 @@
'gpgcheck': 1,
'gpgkeys': [
'RPM-GPG-KEY-metalk8s-kubernetes-8_1',
'RPM-GPG-KEY-metalk8s-kubernetes-8_2',
],
'repo_gpg_check': 0,
'enabled': 1,
Expand Down
9 changes: 4 additions & 5 deletions tools/get-kubeadm-manifests/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
FROM centos:7

ARG K8S_VERSION
ARG K8S_SHORT_VERSION

RUN printf "[kubernetes]\n\
name=Kubernetes\n\
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64\n\
baseurl=https://pkgs.k8s.io/core:/stable:/v${K8S_SHORT_VERSION}/rpm/\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg\n\
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg\n" \
gpgkey=https://pkgs.k8s.io/core:/stable:/v${K8S_SHORT_VERSION}/rpm/repodata/repomd.xml.key\n" \
> /etc/yum.repos.d/kubernetes.repo \
&& yum install -y "kubeadm-${K8S_VERSION}" --disableexcludes=kubernetes \
&& yum install -y kubeadm --disableexcludes=kubernetes \
&& yum clean all

RUN kubeadm init phase control-plane all \
Expand Down
6 changes: 3 additions & 3 deletions tools/get-kubeadm-manifests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ specific version
Build the docker container for the Kubernetes version you want

```shell
K8S_VERSION=$(grep 'K8S_VERSION.*=' "$(git rev-parse --show-toplevel)/buildchain/buildchain/versions.py" | cut -d '"' -f 2)
docker build "$(git rev-parse --show-toplevel)/tools/get-kubeadm-manifests" --build-arg "K8S_VERSION=$K8S_VERSION" -t "metalk8s-kubeadm:$K8S_VERSION"
K8S_SHORT_VERSION=<kube short version, e.g.: "1.26">
docker build "$(git rev-parse --show-toplevel)/tools/get-kubeadm-manifests" --build-arg "K8S_SHORT_VERSION=$K8S_SHORT_VERSION" -t "metalk8s-kubeadm:$K8S_SHORT_VERSION"
```

## Get Kubernetes control plane manifests
Expand All @@ -16,5 +16,5 @@ To retrieve the various Kubernetes control plane manifests,
you must run the previously built container.

```shell
docker run -it --rm "metalk8s-kubeadm:$K8S_VERSION"
docker run -it --rm "metalk8s-kubeadm:$K8S_SHORT_VERSION"
```

0 comments on commit b8b7555

Please sign in to comment.