kube-hetzner / terraform-hcloud-kube-hetzner

Optimized and Maintenance-free Kubernetes on Hetzner Cloud in one command!
MIT License
2.42k stars 371 forks source link

Allows specifying k3s version #1436

Closed gmautner closed 3 months ago

gmautner commented 4 months ago

Sometimes a cluster operator might prefer to specify the k3s version (e.g. v1.29.6+k3s2) instead of the channel (e.g. v1.29, stable etc.)

Reasons for that could be not wanting the system upgrade controller to run at unpredictable times, or having more fine-grained control over the running version.

This PR introduces a new variable install_k3s_version in kube.tf. If undefined, the present behavior is preserved such that current installations are not affected. However, when defined, this variable takes precedence over initial_k3s_channel.

The mechanism for upgrades in either case continues to be the system upgrade controller.

gmautner commented 4 months ago

By the way, the following scenarios were tested and worked according to expected:

mysticaltech commented 3 months ago

Sorry @gmautner, I had to revert the PR as it did not did not deploy on my test. If you manage to fix it with or without channel and with or without version, please don't hesitate to submit a new one.

Screenshot from 2024-08-09 03-36-09

gmautner commented 3 months ago

I think this was caused by a network connectivity issue unrelated to my PR.

When the server https://update.k3s.io/v1-release/channels is down, the behaviour of the k3s installation script is to return the input channel instead of the release, because curl follows all redirects and uses the called URL when there are no redirects.

I manually tested and was able to reproduce the problem with the following commands:

version_url='https://update.k3s.io/v1-release/channels/v1.29'
curl -w '%{url_effective}' -L -s -S ${version_url} -o /dev/null | sed -e 's|.*/||'
v1.29.7+k3s1

Turning off the network:

curl -w '%{url_effective}' -L -s -S ${version_url} -o /dev/null | sed -e 's|.*/||'
curl: (6) Could not resolve host: update.k3s.io
v1.29

This behaviour has been documented by other users of kube-hetzner, like:

https://github.com/k3s-io/k3s/issues/10578#issuecomment-2257389559

So probably it has no relationship to the PR. Could you please test it again?

mysticaltech commented 3 months ago

@gmautner Thanks for the info. This is a crazy coincidence because I've ever seen this very error before.

mysticaltech commented 3 months ago

Ok, I see it's a new feature to allow specifying the version. Please let's wait a bit until it's more stable then we can try again.