Skip to content

Commit

Permalink
chore(taskfiles): update talos tasks
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Kreitzer <[email protected]>
  • Loading branch information
buroa committed Jan 19, 2024
1 parent 2b46e26 commit 6e4ab81
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 34 deletions.
64 changes: 44 additions & 20 deletions .taskfiles/Talos/Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,64 @@
---
version: "3"

vars:
TALHELPER_SECRET_FILE: "{{.TALOS_DIR}}/talsecret.sops.yaml"
TALHELPER_CONFIG_FILE: "{{.TALOS_DIR}}/talconfig.yaml"

tasks:

gensecret:
desc: Generate talos secret
prompt: This will overwrite the existing secret... continue?
dir: "{{.TALOS_DIR}}"
cmds:
- talhelper gensecret > {{.TALHELPER_SECRET_FILE}}
- sops --encrypt --in-place {{.TALHELPER_SECRET_FILE}}
preconditions:
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }

genconfig:
desc: Generate talos config
dir: "{{.TALOS_DIR}}"
cmds:
- talhelper genconfig
cmd: talhelper genconfig
preconditions:
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }

apply-config:
desc: Apply talos config on a node
dir: "{{.TALOS_DIR}}"
cmd: talhelper gencommand apply --extra-flags=--insecure | bash

bootstrap:
desc: Bootstrap the talos cluster
dir: "{{.TALOS_DIR}}"
cmd: talhelper gencommand bootstrap | bash

kubeconfig:
desc: Generate talos kubeconfig
prompt: This will overwrite the existing kubeconfig... continue?
dir: "{{.TALOS_DIR}}"
cmd: talosctl kubeconfig {{.ROOT_DIR}} --force

apply-extras:
desc: Apply extras
dir: "{{.TALOS_DIR}}"
cmds:
- talosctl -n {{.node}} apply-config -f "{{.TALOS_DIR}}/clusterconfig/k8s-{{.node}}.yaml"
vars:
node: '{{ or .node (fail "Argument (node) is required") }}'
preconditions:
- { msg: "Node not found", sh: "talosctl -n {{.node}} get mc" }
- { msg: "Talos config not found", sh: "test -f {{.TALOS_DIR}}/clusterconfig/k8s-{{.node}}.yaml" }
- kubectl kustomize --enable-helm ./cni | kubectl apply --server-side --filename -
- kubectl kustomize --enable-helm ./kubelet-csr-approver | kubectl apply --server-side --filename -

upgrade-talos:
desc: Upgrade talos on a node
cmds:
- talosctl -n {{.node}} upgrade --image {{.image}} --preserve=true --reboot-mode=powercycle
vars:
image: '{{ or .image (fail "Argument (image) is required") }}'
node: '{{ or .node (fail "Argument (node) is required") }}'
cmd: talosctl --nodes {{.node}} upgrade --image {{.image}} --preserve=true --reboot-mode=powercycle
requires:
vars: ["node", "to"]
preconditions:
- { msg: "Node not found", sh: "talosctl -n {{.node}} get mc" }
- { msg: "Node not found", sh: "talosctl --nodes {{.node}} get machineconfig" }

upgrade-k8s:
desc: Upgrade k8s on a node
cmds:
- talosctl -n {{.node}} upgrade-k8s --to {{.to}}
vars:
node: '{{ or .node (fail "Argument (node) is required") }}'
to: '{{ or .to (fail "Argument (to) is required") }}'
cmd: talosctl --nodes {{.node}} upgrade-k8s --to {{.to}}
requires:
vars: ["node", "to"]
preconditions:
- { msg: "Node not found", sh: "talosctl -n {{.node}} get mc" }
- { msg: "Node not found", sh: "talosctl --nodes {{.node}} get machineconfig" }
20 changes: 6 additions & 14 deletions talos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@
### Create Talos Secrets

```
talhelper gensecret > talsecret.sops.yaml
sops -e -i talsecret.sops.yaml
task talos:gensecret
task talos:genconfig
```

### Apply Talos Config

```
task talos:apply-config node=m0.k8s.ktwo.io
task talos:apply-config node=m1.k8s.ktwo.io
task talos:apply-config node=m2.k8s.ktwo.io
task talos:apply-config node=w0.k8s.ktwo.io
task talos:apply-config node=w1.k8s.ktwo.io
task talos:apply-config node=w2.k8s.ktwo.io
task talos:apply-config
```

### Update Mac EFI
Expand All @@ -34,14 +28,12 @@ If you don't do this, your system reboots will be _extremely_ slow.
### Boostrap Talos

```
talosctl -n m0.k8s.ktwo.io bootstrap
talosctl -n m0.k8s.ktwo.io kubeconfig -f
kubectl get no -o wide
task talos:bootstrap
task talos:kubeconfig
```

### Bootstrap CNI
### Bootstrap Extras

```
kubectl kustomize --enable-helm ./cni | kubectl apply -f -
kubectl kustomize --enable-helm ./kubelet-csr-approver | kubectl apply -f -
task talos:apply-extras
```

0 comments on commit 6e4ab81

Please sign in to comment.