From 636d2fd84018667c1f9ea500296cbc4132ee3a72 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Fri, 11 Oct 2024 07:35:08 -0400 Subject: [PATCH] feat: change talos upgrade task to support version instead of image (#1603) * feat: change talos upgrade task to support version instead of image * Update README.md * Update Taskfile.yaml * Update Taskfile.yaml * Update Taskfile.yaml * Update Taskfile.yaml --- .taskfiles/Talos/Taskfile.yaml | 12 ++++++++++-- README.md | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.taskfiles/Talos/Taskfile.yaml b/.taskfiles/Talos/Taskfile.yaml index 81092bcc..1a75fbfe 100644 --- a/.taskfiles/Talos/Taskfile.yaml +++ b/.taskfiles/Talos/Taskfile.yaml @@ -40,12 +40,14 @@ tasks: desc: Upgrade Talos on a node dir: '{{.KUBERNETES_DIR}}/bootstrap/talos' cmds: - - talosctl --nodes {{.NODE}} upgrade --image {{.IMAGE}} --timeout=10m --reboot-mode={{.MODE}} + - talosctl --nodes {{.NODE}} upgrade --image="factory.talos.dev/installer/{{.TALOS_SCHEMATIC_ID}}:{{.VERSION}}" --timeout=10m --reboot-mode={{.MODE}} - talosctl --nodes {{.NODE}} health --wait-timeout=10m --server=false vars: MODE: '{{.MODE | default "default"}}' + TALOS_SCEMATIC_ID: + sh: talosctl get nodeannotationspecs --nodes {{.NODE}} -o jsonpath='{.spec.value}' requires: - vars: ['NODE', 'IMAGE'] + vars: ['NODE', 'VERSION'] preconditions: - msg: Missing talosconfig sh: test -f {{.TALOSCONFIG}} @@ -53,6 +55,9 @@ tasks: sh: talosctl config info &>/dev/null - msg: Node not found sh: talosctl --nodes {{.NODE}} get machineconfig &>/dev/null + - msg: Upstream Talos version not found + sh: | + curl -fsSL -H "Authorization: Bearer $(curl -fsSL 'https://ghcr.io/token?scope=repository:siderolabs/talos:pull' | jq -r '.token')" https://ghcr.io/v2/siderolabs/talos/manifests/{{.VERSION}} &>/dev/null upgrade-k8s: desc: Upgrade Kubernetes across the cluster @@ -69,6 +74,9 @@ tasks: sh: talosctl --nodes {{.NODE}} get machineconfig &>/dev/null - msg: Node not controller sh: talosctl config info --output json | jq --exit-status '.endpoints | index("{{.NODE}}") != null' &>/dev/null + - msg: Upstream Kubernetes version not found + sh: | + curl -fsSL -H "Authorization: Bearer $(curl -fsSL 'https://ghcr.io/token?scope=repository:siderolabs/kubelet:pull' | jq -r '.token')" https://ghcr.io/v2/siderolabs/kubelet/manifests/{{.VERSION}} &>/dev/null nuke: desc: Resets nodes back to maintenance mode diff --git a/README.md b/README.md index db225e67..d5b11931 100644 --- a/README.md +++ b/README.md @@ -359,9 +359,9 @@ Resolving problems that you have could take some tweaking of your YAML manifests ```sh # Upgrade Talos to a newer version # NOTE: This needs to be run once on every node -task talos:upgrade NODE=? IMAGE=? +task talos:upgrade NODE=? VERSION=? # e.g. -# task talos:upgrade NODE=192.168.42.10 IMAGE=factory.talos.dev/installer/${schematic_id}:v1.7.4 +# task talos:upgrade NODE=192.168.42.10 VERSION=v1.8.1 ``` ```sh