--- # yaml-language-server: $schema=https://taskfile.dev/schema.json version: "3" vars: TALHELPER_CLUSTER_DIR: "{{.KUBERNETES_DIR}}/bootstrap/talos/clusterconfig" TALHELPER_SECRET_FILE: "{{.KUBERNETES_DIR}}/bootstrap/talos/talsecret.sops.yaml" TALHELPER_CONFIG_FILE: "{{.KUBERNETES_DIR}}/bootstrap/talos/talconfig.yaml" HELMFILE_FILE: "{{.KUBERNETES_DIR}}/bootstrap/helmfile.yaml" env: TALOSCONFIG: "{{.TALHELPER_CLUSTER_DIR}}/talosconfig" tasks: bootstrap: desc: Bootstrap the Talos cluster cmds: - | if [ ! -f "{{.TALHELPER_SECRET_FILE}}" ]; then talhelper gensecret > {{.TALHELPER_SECRET_FILE}} sops --encrypt --in-place {{.TALHELPER_SECRET_FILE}} fi - talhelper genconfig --config-file {{.TALHELPER_CONFIG_FILE}} --secret-file {{.TALHELPER_SECRET_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} - talhelper gencommand apply --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} --extra-flags="--insecure" | bash - until talhelper gencommand bootstrap --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} | bash; do sleep 10; done - task: fetch-kubeconfig - task: install-helm-apps - talosctl health --server=false preconditions: - msg: Missing talhelper config file sh: test -f {{.TALHELPER_CONFIG_FILE}} - msg: Missing Sops config file sh: test -f {{.SOPS_CONFIG_FILE}} - msg: Missing Sops Age key file sh: test -f {{.AGE_FILE}} fetch-kubeconfig: desc: Fetch kubeconfig cmd: until talhelper gencommand kubeconfig --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} --extra-flags="{{.ROOT_DIR}} --force" | bash; do sleep 10; done preconditions: - msg: Missing talhelper config file sh: test -f {{.TALHELPER_CONFIG_FILE}} install-helm-apps: desc: Bootstrap core apps needed for Talos cmds: - until kubectl --kubeconfig {{.KUBECONFIG_FILE}} wait --for=condition=Ready=False nodes --all --timeout=600s; do sleep 10; done - helmfile --kubeconfig {{.KUBECONFIG_FILE}} --file {{.HELMFILE_FILE}} apply --skip-diff-on-install --suppress-diff - until kubectl --kubeconfig {{.KUBECONFIG_FILE}} wait --for=condition=Ready nodes --all --timeout=600s; do sleep 10; done preconditions: - msg: Missing kubeconfig sh: test -f {{.KUBECONFIG_FILE}} - msg: Missing helmfile sh: test -f {{.HELMFILE_FILE}} upgrade-talos: desc: Upgrade talos on a node cmd: talosctl --nodes {{.node}} upgrade --image {{.image}} --preserve=true --reboot-mode=default requires: vars: ["node", "image"] preconditions: - msg: Node not found sh: talosctl --nodes {{.node}} get machineconfig upgrade-k8s: desc: Upgrade k8s on a node cmd: talosctl --nodes {{.node}} upgrade-k8s --to {{.to}} requires: vars: ["node", "to"] preconditions: - msg: Node not found sh: talosctl --nodes {{.node}} get machineconfig nuke: desc: Resets nodes back to maintenance mode prompt: This will destroy your cluster and reset the nodes back to maintenance mode... continue? cmd: talhelper gencommand reset --config-file {{.TALHELPER_CONFIG_FILE}} --out-dir {{.TALHELPER_CLUSTER_DIR}} --extra-flags="--reboot {{- if eq .CLI_FORCE false }} --system-labels-to-wipe STATE --system-labels-to-wipe EPHEMERAL{{ end }} --graceful=false --wait=false" | bash .reset: internal: true cmd: rm -rf {{.TALHELPER_CLUSTER_DIR}} {{.TALHELPER_SECRET_FILE}} {{.TALHELPER_CONFIG_FILE}}