summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2024-03-15 19:06:05 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2024-03-15 19:09:05 +0000
commit54f80102b0245ae7ca37103dafcf63c52ea47c89 (patch)
tree87621ff53e602337f23d8cc7f75b8adab7094cdf
parent5984a2e4b640be44cec4988cdbd076ee12af9822 (diff)
downloadmeta-virtualization-54f80102b0245ae7ca37103dafcf63c52ea47c89.tar.gz
k3s: set version.UpstreamGolang in binaries
k3s will refuse to start if the golang version it was built with doesn't match the VERSION_GOLANG linker variable. As an example: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/61668 We query our version of the compiler and set it in the binaries to ensure they match. Note: this may cause issues if you bump the golang compiler, but k3s doesn't rebuild. We'll worry about that when it happens. With this change, k3s starts and the node becomes ready. root@qemux86-64:~# uname -a Linux qemux86-64 6.6.20-yocto-standard #1 SMP PREEMPT_DYNAMIC Sun Mar 3 16:28:22 UTC 2024 x86_64 GNU/Linux root@qemux86-64:~# kubectl get nodes NAME STATUS ROLES AGE VERSION qemux86-64 Ready control-plane,master 10m v1.28.7-k3s1 Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r--recipes-containers/k3s/k3s_git.bb3
1 files changed, 2 insertions, 1 deletions
diff --git a/recipes-containers/k3s/k3s_git.bb b/recipes-containers/k3s/k3s_git.bb
index 93a44e33..e33cb44b 100644
--- a/recipes-containers/k3s/k3s_git.bb
+++ b/recipes-containers/k3s/k3s_git.bb
@@ -76,7 +76,8 @@ do_compile() {
76 76
77 cp ${WORKDIR}/modules.txt vendor/ 77 cp ${WORKDIR}/modules.txt vendor/
78 78
79 ${GO} build -trimpath -tags "$TAGS" -ldflags "${GO_BUILD_LDFLAGS} -w -s" -o ./dist/artifacts/k3s ./cmd/server/main.go 79 VERSION_GOLANG="$(go version | cut -d" " -f3)"
80 ${GO} build -trimpath -tags "$TAGS" -ldflags "-X github.com/k3s-io/k3s/pkg/version.UpstreamGolang=$VERSION_GOLANG ${GO_BUILD_LDFLAGS} -w -s" -o ./dist/artifacts/k3s ./cmd/server/main.go
80 81
81 # Use UPX if it is enabled (and thus exists) to compress binary 82 # Use UPX if it is enabled (and thus exists) to compress binary
82 if command -v upx > /dev/null 2>&1; then 83 if command -v upx > /dev/null 2>&1; then