Skip to content

Commit 8ffe4bb

Browse files
authored
rke2: refactor update-script and update rke2 channel versions (#344692)
1 parent 71a33cc commit 8ffe4bb

File tree

6 files changed

+68
-59
lines changed

6 files changed

+68
-59
lines changed
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# RKE2 Version
22

3-
RKE2, Kubernetes, and other clustered software has the property of not being able to update atomically. Most software in nixpkgs, like for example bash, can be updated as part of a `nixos-rebuild switch` without having to worry about the old and the new bash interacting in some way.
3+
RKE2, Kubernetes, and other clustered software has the property of not being able to update atomically.
4+
Most software in nixpkgs, like for example bash, can be updated as part of a `nixos-rebuild switch`
5+
without having to worry about the old and the new bash interacting in some way.
46

57
> [!NOTE]
68
> Upgrade the server nodes first, one at a time. Once all servers have been upgraded, you may then upgrade agent nodes.
79
810
## Release Channels
911

10-
RKE2 has there own release channels, which are: `stable`, `latest` and `testing`.
12+
RKE2 has three main release channels, which are: `stable`, `latest` and `testing`.
1113

12-
The `stable` channel is the default channel and is recommended for production use. The `latest` channel is the latest stable release. The `testing` channel is the latest release, including pre-releases.
14+
The `stable` channel is the default channel and is recommended for production use.
15+
The `latest` channel is the latest release.
16+
The `testing` channel is the latest release, including pre-releases.
1317

1418
| Channel | Description |
1519
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -19,7 +23,12 @@ The `stable` channel is the default channel and is recommended for production us
1923

2024
Learn more about the [RKE2 release channels](https://docs.rke2.io/upgrade/manual_upgrade).
2125

22-
For an exhaustive and up-to-date list of channels, you can visit the [rke2 channel service API](https://update.rke2.io/v1-release/channels). For more technical details on how channels work, you can see the [channelserver project](https://github.com/rancher/channelserver).
26+
For an exhaustive and up-to-date list of channels, you can visit the
27+
[rke2 channel service API](https://update.rke2.io/v1-release/channels).
28+
For more technical details on how channels work, you can see the [channelserver project](https://github.com/rancher/channelserver).
2329

2430
> [!TIP]
25-
> When attempting to upgrade to a new version of RKE2, the [Kubernetes version skew policy](https://kubernetes.io/docs/setup/release/version-skew-policy) applies. Ensure that your plan does not skip intermediate minor versions when upgrading. Nothing in the upgrade process will protect against unsupported changes to the Kubernetes version.
31+
> When attempting to upgrade to a new version of RKE2,
32+
> the [Kubernetes version skew policy](https://kubernetes.io/docs/setup/release/version-skew-policy) applies.
33+
> Ensure that your plan **does not skip intermediate minor versions** when upgrading. Nothing in the upgrade process will
34+
> protect you against unsupported changes to the Kubernetes version.

pkgs/applications/networking/cluster/rke2/builder.nix

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
lib: { rke2Version, rke2RepoSha256, rke2VendorHash, updateScript
1+
lib: { rke2Version, rke2Commit, rke2TarballHash, rke2VendorHash, updateScript
2+
, k8sImageTag, etcdVersion, pauseVersion, ccmVersion, dockerizedVersion, ... }:
23

3-
, rke2Commit, k8sImageTag, etcdVersion, pauseVersion, ccmVersion, dockerizedVersion, ... }:
4-
5-
{ lib, stdenv, buildGoModule, go, fetchgit, makeWrapper
4+
# Build dependencies
5+
{ lib, stdenv, buildGoModule, go, makeWrapper, fetchzip
66

77
# Runtime dependencies
88
, procps, coreutils, util-linux, ethtool, socat, iptables, bridge-utils, iproute2, kmod, lvm2
@@ -18,10 +18,9 @@ buildGoModule rec {
1818
pname = "rke2";
1919
version = rke2Version;
2020

21-
src = fetchgit {
22-
url = "https://github.com/rancher/rke2.git";
23-
rev = "v${version}";
24-
sha256 = rke2RepoSha256;
21+
src = fetchzip {
22+
url = "https://github.com/rancher/rke2/archive/refs/tags/v${rke2Version}.tar.gz";
23+
hash = "${rke2TarballHash}";
2524
};
2625

2726
vendorHash = rke2VendorHash;
@@ -52,7 +51,7 @@ buildGoModule rec {
5251
"-X github.com/k3s-io/k3s/pkg/version.Version=v${version}"
5352
"-X github.com/k3s-io/k3s/pkg/version.UpstreamGolang=go${go.version}"
5453
"-X github.com/rancher/rke2/pkg/images.DefaultRegistry=docker.io"
55-
"-X github.com/rancher/rke2/pkg/images.DefaultEtcdImage=rancher/hardened-etcd:${etcdVersion}-build20240418"
54+
"-X github.com/rancher/rke2/pkg/images.DefaultEtcdImage=rancher/hardened-etcd:${etcdVersion}"
5655
"-X github.com/rancher/rke2/pkg/images.DefaultKubernetesImage=rancher/hardened-kubernetes:${k8sImageTag}"
5756
"-X github.com/rancher/rke2/pkg/images.DefaultPauseImage=rancher/mirrored-pause:${pauseVersion}"
5857
"-X github.com/rancher/rke2/pkg/images.DefaultRuntimeImage=rancher/rke2-runtime:${dockerizedVersion}"
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
rke2Version = "1.31.0+rke2r1";
3-
rke2RepoSha256 = "1xf7yhpfwiydhl31dd8wc2bhq0j470ad8vazjzzsl76skcy07rbc";
4-
rke2Commit = "4bf1156f41631dc0e81d66a6834a53d14b48aaef";
5-
rke2VendorHash = "sha256-/ALzC2fYYI+DbF+2TSNBiMy57T8wfXGPpdyKtbqdrtE=";
6-
k8sVersion = "v1.31.0";
7-
k8sImageTag = "v1.31.0-rke2r1-build20240815";
8-
etcdVersion = "v3.5.13-k3s1";
2+
rke2Version = "1.31.1+rke2r1";
3+
rke2Commit = "909d20d6a28cd7656b7177190f06f69f57927613";
4+
rke2TarballHash = "sha256-9ZryOX6QMNpjDtsOXLOVNPjCc6AMAa+XDLOn1EpyCcg=";
5+
rke2VendorHash = "sha256-7nWbWi4oJTOWZ5iZr9ptECDJJakPg4qZ7hW+tU7LBsI=";
6+
k8sVersion = "v1.31.1";
7+
k8sImageTag = "v1.31.1-rke2r1-build20240912";
8+
etcdVersion = "v3.5.13-k3s1-build20240910";
99
pauseVersion = "3.6";
10-
ccmVersion = "v1.29.3-build20240515";
11-
dockerizedVersion = "v1.31.0-dev.";
12-
golangVersion = "go1.22.5";
10+
ccmVersion = "v1.31.0-build20240910";
11+
dockerizedVersion = "v1.31.1-rke2r1";
12+
golangVersion = "go1.22.6";
1313
eol = "2025-10-28";
1414
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
rke2Version = "1.30.4+rke2r1";
3-
rke2RepoSha256 = "1daxs8gxy775qn1yrf7zh77cyaj3nn3qlwj0vjqfpbv1gpkimfyi";
4-
rke2Commit = "9517eea519b780e154dd791c555c698e84a0e5cd";
5-
rke2VendorHash = "sha256-Q+Wt4Hyp6VyxfCXNsRQMyAo0QCGWhnY9tcV/NQrrSEY=";
6-
k8sVersion = "v1.30.4";
7-
k8sImageTag = "v1.30.4-rke2r1-build20240815";
8-
etcdVersion = "v3.5.13-k3s1";
2+
rke2Version = "1.30.5+rke2r1";
3+
rke2Commit = "0c83bc82315cd61664880d0b52a7e070e9fbd623";
4+
rke2TarballHash = "sha256-K5e7TNlL97PQ13IYnr4PSrXb4XaGJT9bPq55iWL0m1g=";
5+
rke2VendorHash = "sha256-QIcVyWnedKNF10OqJ2WmZqZeKA+8hvwDQ4Pl+WUOEJY=";
6+
k8sVersion = "v1.30.5";
7+
k8sImageTag = "v1.30.5-rke2r1-build20240912";
8+
etcdVersion = "v3.5.13-k3s1-build20240910";
99
pauseVersion = "3.6";
10-
ccmVersion = "v1.29.3-build20240515";
11-
dockerizedVersion = "v1.30.4-dev.877838a0-dirty";
12-
golangVersion = "go1.22.5";
10+
ccmVersion = "v1.30.4-build20240910";
11+
dockerizedVersion = "v1.30.5-rke2r1";
12+
golangVersion = "go1.22.6";
1313
eol = "2025-06-28";
1414
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
rke2Version = "1.31.1-rc3+rke2r1";
3-
rke2RepoSha256 = "1j09f95d99xk1jbsy08cl1rw5y1ljnrmq3nv1rixlc4hgqwz56pm";
43
rke2Commit = "909d20d6a28cd7656b7177190f06f69f57927613";
4+
rke2TarballHash = "sha256-9ZryOX6QMNpjDtsOXLOVNPjCc6AMAa+XDLOn1EpyCcg=";
55
rke2VendorHash = "sha256-7nWbWi4oJTOWZ5iZr9ptECDJJakPg4qZ7hW+tU7LBsI=";
66
k8sVersion = "v1.31.1";
77
k8sImageTag = "v1.31.1-rke2r1-build20240912";
8-
etcdVersion = "v3.5.13-k3s1";
8+
etcdVersion = "v3.5.13-k3s1-build20240910";
99
pauseVersion = "3.6";
1010
ccmVersion = "v1.31.0-build20240910";
11-
dockerizedVersion = "v1.31.1-dev.";
11+
dockerizedVersion = "v1.31.1-rc3-rke2r1";
1212
golangVersion = "go1.22.6";
1313
eol = "2025-10-28";
1414
}

pkgs/applications/networking/cluster/rke2/update-script.sh

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,46 @@
11
#!/usr/bin/env nix-shell
2-
#!nix-shell -i bash -p curl git gnugrep gnused yq-go nix-prefetch
2+
#!nix-shell -i bash -p curl git gnugrep gnused yq-go nix-prefetch go
33

4+
SHELL_FLAGS=$(set +o)
45
set -x -eu -o pipefail
56

67
CHANNEL_NAME="${1:?Must provide a release channel, like 'stable', as the only argument}"
78

89
WORKDIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd -P)
9-
1010
mkdir --parents --verbose "${WORKDIR}/${CHANNEL_NAME}"
1111

12-
LATEST_TAG_NAME=$(curl --silent --fail https://update.rke2.io/v1-release/channels | \
13-
yq eval ".data[] | select(.id == \"${CHANNEL_NAME}\").latest" - | \
14-
sort -rV | grep --extended-regexp "^v[0-9]+\.[0-9]+\.[0-9]+" | head -n1)
12+
LATEST_TAG_NAME=$(curl -sS --fail https://update.rke2.io/v1-release/channels | \
13+
yq ".data[] | select(.id == \"${CHANNEL_NAME}\") | .latest")
1514

1615
RKE2_VERSION=$(echo ${LATEST_TAG_NAME} | sed 's/^v//')
16+
RKE2_COMMIT=$(curl -sS --fail "https://api.github.com/repos/rancher/rke2/git/refs/tags/${LATEST_TAG_NAME}" | yq '.object.sha')
1717

18-
RKE2_REPO_SHA256=$(nix-prefetch-url --quiet --unpack \
19-
https://github.com/rancher/rke2/archive/refs/tags/${LATEST_TAG_NAME}.tar.gz)
20-
21-
RKE2_COMMIT=$(curl --silent --fail ${GITHUB_TOKEN:+-u ":${GITHUB_TOKEN}"} \
22-
https://api.github.com/repos/rancher/rke2/git/refs/tags | \
23-
yq eval ".[] | select(.ref == \"refs/tags/${LATEST_TAG_NAME}\").object.sha" -)
18+
PREFETCH_META=$(nix-prefetch-url --unpack --print-path "https://github.com/rancher/rke2/archive/refs/tags/${LATEST_TAG_NAME}.tar.gz")
19+
STORE_HASH="$(nix --extra-experimental-features nix-command hash to-sri --type sha256 ${PREFETCH_META%%$'\n'*})"
20+
STORE_PATH="${PREFETCH_META##*$'\n'}"
2421

25-
VERSIONS_SCRIPT=$(mktemp --suffix ".${RKE2_COMMIT:0:6}.sh")
26-
trap "rm --force ${VERSIONS_SCRIPT}" EXIT
22+
cd ${STORE_PATH}
23+
GITHUB_ACTION_TAG=${LATEST_TAG_NAME}
24+
DRONE_COMMIT=${RKE2_COMMIT}
2725

28-
curl --silent --fail --output ${VERSIONS_SCRIPT} \
29-
https://raw.githubusercontent.com/rancher/rke2/${RKE2_COMMIT}/scripts/version.sh
26+
set +u
27+
source scripts/version.sh
28+
set -u
3029

31-
set +eu
32-
DRONE_TAG=${LATEST_TAG_NAME} source ${VERSIONS_SCRIPT}
33-
set -eu
30+
ETCD_BUILD=$(grep "images.DefaultEtcdImage" scripts/build-binary | sed 's/.*-\(build[0-9]*\)$/\1/')
31+
ETCD_VERSION="${ETCD_VERSION}-${ETCD_BUILD}"
32+
cd ${WORKDIR}
3433

3534
KUBERNETES_CYCLES=$(echo ${KUBERNETES_VERSION} | grep -Eo "[0-9]+\.[0-9]+")
36-
KUBERNETES_EOL=$(curl --silent --fail \
37-
https://endoflife.date/api/kubernetes/${KUBERNETES_CYCLES}.json | \
38-
yq eval ".eol" -)
35+
KUBERNETES_EOL=$(curl -sS --fail https://endoflife.date/api/kubernetes/${KUBERNETES_CYCLES}.json | yq ".eol")
3936

4037
FAKE_HASH="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
4138

4239
cat << EOF > "${WORKDIR}/${CHANNEL_NAME}/versions.nix"
4340
{
4441
rke2Version = "${RKE2_VERSION}";
45-
rke2RepoSha256 = "${RKE2_REPO_SHA256}";
4642
rke2Commit = "${RKE2_COMMIT}";
43+
rke2TarballHash = "${STORE_HASH}";
4744
rke2VendorHash = "${FAKE_HASH}";
4845
k8sVersion = "${KUBERNETES_VERSION}";
4946
k8sImageTag = "${KUBERNETES_IMAGE_TAG}";
@@ -70,6 +67,7 @@ fi
7067

7168
# Implement commit
7269
# See: https://nixos.org/manual/nixpkgs/stable/#var-passthru-updateScript-commit
70+
set +u
7371
cat << EOF
7472
[
7573
{
@@ -82,3 +80,6 @@ cat << EOF
8280
}
8381
]
8482
EOF
83+
84+
set +x
85+
eval "$SHELL_FLAGS"

0 commit comments

Comments
 (0)