|
| 1 | +--- |
| 2 | +version: "3" |
| 3 | + |
| 4 | +vars: |
| 5 | + DOMAIN: "dfw.56k.sh" |
| 6 | + # renovate: datasource=github-releases depName=siderolabs/talos |
| 7 | + TALOS_VERSION: "v1.4.4" |
| 8 | + # renovate: datasource=github-releases depName=budimanjojo/talhelper |
| 9 | + TALHELPER_VERSION: "v1.7.3" |
| 10 | + # renovate: datasource=github-releases depName=siderolabs/kubelet |
| 11 | + KUBERNETES_VERSION: "v1.26.5" |
| 12 | + |
| 13 | +tasks: |
| 14 | + |
| 15 | + init: |
| 16 | + desc: Init talosctl and grab kubeconfig (task talos:init) |
| 17 | + cmds: |
| 18 | + - mkdir config || true |
| 19 | + - sudo curl -Lo /usr/local/bin/talosctl https://github.com/siderolabs/talos/releases/download/{{.TALOS_VERSION}}/talosctl-$(uname -s | tr "[:upper:]" "[:lower:]")-$(uname -m) && sudo chmod +x /usr/local/bin/talosctl |
| 20 | + - curl -Lo /tmp/talhelper-{{.TALHELPER_VERSION}}.tar.gz https://github.com/budimanjojo/talhelper/releases/download/{{.TALHELPER_VERSION}}/talhelper_$(uname -s | tr "[:upper:]" "[:lower:]")_$(uname -m).tar.gz && tar -xzf /tmp/talhelper-{{.TALHELPER_VERSION}}.tar.gz -C /tmp && sudo mv /tmp/talhelper /usr/local/bin/talhelper |
| 21 | + - task: generate |
| 22 | + - talosctl --talosconfig=talos/clusterconfig/talosconfig kubeconfig --nodes k8s-control01 $KUBECONFIG |
| 23 | + |
| 24 | + install:cni: |
| 25 | + desc: Install CNI and cert approver helm releases (task talos:cni) |
| 26 | + cmds: |
| 27 | + - kubectl kustomize talos --enable-helm | kubectl apply -f - |
| 28 | + |
| 29 | + upgrade:k8s: |
| 30 | + dir: talos |
| 31 | + desc: Upgrade Kubernetes to {{ .KUBERNETES_VERSION }} (task talos:upgrade:k8s) |
| 32 | + cmds: |
| 33 | + - talosctl --nodes k8s-control01 upgrade-k8s --to {{ .KUBERNETES_VERSION }} |
| 34 | + |
| 35 | + upgrade:all: |
| 36 | + desc: Upgrade all nodes to Talos version {{ .TALOS_VERSION }} (task talos:upgrade:all) |
| 37 | + dir: talos |
| 38 | + cmds: |
| 39 | + - task: generate |
| 40 | + # control-plane |
| 41 | + - task: upgrade |
| 42 | + vars: {NODE: k8s-control01} |
| 43 | + - task: upgrade |
| 44 | + vars: {NODE: k8s-control02} |
| 45 | + - task: upgrade |
| 46 | + vars: {NODE: k8s-control03} |
| 47 | + # workers |
| 48 | + - task: upgrade |
| 49 | + vars: {NODE: k8s-worker01} |
| 50 | + - task: upgrade |
| 51 | + vars: {NODE: k8s-worker02} |
| 52 | + - task: upgrade |
| 53 | + vars: {NODE: k8s-worker03} |
| 54 | + # Restart nginx, sometimes it has issues... |
| 55 | + - kubectl -n networking rollout restart deployment ingress-nginx-controller |
| 56 | + |
| 57 | + generate: |
| 58 | + internal: True |
| 59 | + desc: Generate Talos machine configurations (task talos:generate) |
| 60 | + dir: talos |
| 61 | + cmds: |
| 62 | + - talhelper genconfig |
| 63 | + sources: |
| 64 | + - talconfig.yaml |
| 65 | + - talenv.sops.yaml |
| 66 | + - talenv.yaml |
| 67 | + - talsecret.sops.yaml |
| 68 | + generates: |
| 69 | + - clusterconfig/*.yaml |
| 70 | + - clusterconfig/talosconfig |
| 71 | + |
| 72 | + apply: |
| 73 | + desc: Apply Talos config to a specific node (task talos:apply NODE=k8s-control01) |
| 74 | + dir: talos |
| 75 | + cmds: |
| 76 | + - task: generate |
| 77 | + - talosctl apply-config --nodes {{ .NODE }} --file clusterconfig/cluster01-{{ .NODE }}.{{ .DOMAIN }}.yaml {{ .CLI_ARGS }} |
| 78 | + |
| 79 | + upgrade: |
| 80 | + internal: True |
| 81 | + desc: Upgrade a single node to Talos version {{ .TALOS_VERSION }} (task talos:upgrade NODE=k8s-control01) |
| 82 | + dir: talos |
| 83 | + status: |
| 84 | + - talosctl version --nodes {{ .NODE }} --short | grep 'Tag.*{{ .TALOS_VERSION }}' |
| 85 | + cmds: |
| 86 | + - task: wait_for_health |
| 87 | + vars: {TIMEOUT: 10m} |
| 88 | + - task: apply |
| 89 | + vars: {NODE: "{{ .NODE }}", CLI_ARGS: "-m staged"} |
| 90 | + - talosctl upgrade --nodes {{ .NODE }} --image ghcr.io/siderolabs/installer:{{ .TALOS_VERSION }} |
| 91 | + |
| 92 | + wait_for_health: |
| 93 | + internal: True |
| 94 | + desc: Wait for services in cluster to be healthy |
| 95 | + cmds: |
| 96 | + # Ensure CephCluster is healthy |
| 97 | + - kubectl -n rook-ceph wait --for jsonpath='{.status.ceph.health}'='HEALTH_OK' --timeout {{ .TIMEOUT | default "30s" }} cephcluster rook-ceph |
| 98 | + # Ensure CloudNative-PG cluster has 3 ready instances |
| 99 | + - kubectl -n database wait --for jsonpath='{.status.readyInstances}'='3' --timeout {{ .TIMEOUT | default "30s" }} cluster postgres |
0 commit comments