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 76a4c12
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 47 deletions.
72 changes: 49 additions & 23 deletions .taskfiles/Talos/Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,66 @@
---
version: "3"

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

tasks:

genconfig:
desc: Generate talos config
gensecret:
desc: Generate Talos secret
prompt: This will overwrite the existing secret... continue?
dir: "{{.TALOS_DIR}}"
cmds:
- talhelper genconfig
- 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}}"
cmd: talhelper genconfig
preconditions:
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }

apply-config:
desc: Apply talos config on a node
desc: Apply Talos config to the nodes
dir: "{{.TALOS_DIR}}"
cmd: talhelper gencommand apply | bash

bootstrap:
desc: Bootstrap the Talos cluster
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" }
- talhelper gencommand apply --extra-flags=--insecure | bash
- talhelper gencommand bootstrap | bash

upgrade-talos:
desc: Upgrade talos on a node
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}} 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") }}'
- 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
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" }
34 changes: 10 additions & 24 deletions talos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
### Create Talos Secrets

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

### Apply Talos Config
### Boostrap Talos

```
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:bootstrap
task talos:kubeconfig
```

### Bootstrap Extras

```
task talos:apply-extras
```

### Update Mac EFI
Expand All @@ -30,18 +31,3 @@ _use reFINd ensure boot order and delete other boot entries_
3. Set boot order to Talos: `bcfg boot add 0 fs1:\EFI\BOOT\BOOTX64.efi "Talos"`

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
```

### Bootstrap CNI

```
kubectl kustomize --enable-helm ./cni | kubectl apply -f -
kubectl kustomize --enable-helm ./kubelet-csr-approver | kubectl apply -f -
```

0 comments on commit 76a4c12

Please sign in to comment.