Talos: One-liner deployment code (#1317)
* feat(talos): Create one-liner deployment and nuking options * Update Talos deployment docs * Update Taskfile.yaml * Update README.md * Update README.md * fix talos e2e tests --------- Co-authored-by: Devin Buhl <onedr0p@users.noreply.github.com>
This commit is contained in:
1 parent
7171793fab
commit
00fc89553f
3 files changed
+57
-44
No files matched your search
@@ -89,8 +89,8 @@ jobs:
|
|||||||
if: ${{ startsWith(matrix.config-files, 'talos') }}
|
if: ${{ startsWith(matrix.config-files, 'talos') }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
task talos:gensecret --yes
|
task talos:bootstrap-gensecret
|
||||||
task talos:genconfig
|
task talos:bootstrap-genconfig
|
||||||
|
|
||||||
- name: Run Ansible tasks
|
- name: Run Ansible tasks
|
||||||
if: ${{ startsWith(matrix.config-files, 'k3s') }}
|
if: ${{ startsWith(matrix.config-files, 'k3s') }}
|
||||||
|
|||||||
@@ -12,9 +12,20 @@ env:
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
gensecret:
|
bootstrap:
|
||||||
desc: Generate talos secret
|
desc: Bootstrap the Talos cluster
|
||||||
prompt: This will overwrite the existing secret... continue?
|
dir: "{{.TALOS_DIR}}"
|
||||||
|
cmds:
|
||||||
|
- task: bootstrap-gensecret
|
||||||
|
- task: bootstrap-genconfig
|
||||||
|
- task: bootstrap-apply
|
||||||
|
- task: bootstrap-install
|
||||||
|
- task: fetch-kubeconfig
|
||||||
|
- task: bootstrap-core-apps
|
||||||
|
- talosctl health --server=false
|
||||||
|
|
||||||
|
bootstrap-gensecret:
|
||||||
|
desc: Generate the Talos secrets
|
||||||
dir: "{{.TALOS_DIR}}"
|
dir: "{{.TALOS_DIR}}"
|
||||||
cmds:
|
cmds:
|
||||||
- talhelper gensecret > {{.TALHELPER_SECRET_FILE}}
|
- talhelper gensecret > {{.TALHELPER_SECRET_FILE}}
|
||||||
@@ -23,42 +34,41 @@ tasks:
|
|||||||
file: "{{.TALHELPER_SECRET_FILE}}"
|
file: "{{.TALHELPER_SECRET_FILE}}"
|
||||||
preconditions:
|
preconditions:
|
||||||
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
||||||
|
status:
|
||||||
|
- test -f "{{.TALHELPER_SECRET_FILE}}"
|
||||||
|
|
||||||
genconfig:
|
bootstrap-genconfig:
|
||||||
desc: Generate talos config
|
desc: Generate the Talos configs
|
||||||
dir: "{{.TALOS_DIR}}"
|
dir: "{{.TALOS_DIR}}"
|
||||||
cmd: talhelper genconfig
|
cmd: talhelper genconfig
|
||||||
preconditions:
|
preconditions:
|
||||||
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
||||||
|
|
||||||
apply:
|
bootstrap-apply:
|
||||||
desc: Apply talos config on a node
|
desc: Apply the Talos config on a node
|
||||||
dir: "{{.TALOS_DIR}}"
|
dir: "{{.TALOS_DIR}}"
|
||||||
cmd: talhelper gencommand apply --extra-flags=--insecure | bash
|
cmd: talhelper gencommand apply --extra-flags=--insecure | bash
|
||||||
preconditions:
|
preconditions:
|
||||||
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
||||||
|
|
||||||
bootstrap:
|
bootstrap-install:
|
||||||
desc: Bootstrap the talos cluster
|
desc: Install the Talos cluster
|
||||||
dir: "{{.TALOS_DIR}}"
|
dir: "{{.TALOS_DIR}}"
|
||||||
cmd: talhelper gencommand bootstrap | bash
|
cmds:
|
||||||
|
- echo "Installing Talos... ignore the errors and be patient"
|
||||||
|
- until talhelper gencommand bootstrap | bash; do sleep 10; done
|
||||||
|
- sleep 10
|
||||||
preconditions:
|
preconditions:
|
||||||
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
||||||
|
|
||||||
kubeconfig:
|
bootstrap-core-apps:
|
||||||
desc: Generate talos kubeconfig
|
desc: Bootstrap Helm apps
|
||||||
prompt: This will overwrite the existing kubeconfig... continue?
|
|
||||||
dir: "{{.TALOS_DIR}}"
|
|
||||||
cmd: talosctl --nodes {{.node}} kubeconfig {{.ROOT_DIR}} --force
|
|
||||||
requires:
|
|
||||||
vars: ["node"]
|
|
||||||
|
|
||||||
apply-extras:
|
|
||||||
desc: Apply extras
|
|
||||||
dir: "{{.TALOS_DIR}}"
|
dir: "{{.TALOS_DIR}}"
|
||||||
cmds:
|
cmds:
|
||||||
|
- until kubectl wait --for=condition=Ready=False nodes --all --timeout=600s; do sleep 10; done
|
||||||
- kubectl --kubeconfig {{.KUBECONFIG_FILE}} kustomize --enable-helm ./cilium | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename -
|
- kubectl --kubeconfig {{.KUBECONFIG_FILE}} kustomize --enable-helm ./cilium | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename -
|
||||||
- kubectl --kubeconfig {{.KUBECONFIG_FILE}} kustomize --enable-helm ./kubelet-csr-approver | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename -
|
- kubectl --kubeconfig {{.KUBECONFIG_FILE}} kustomize --enable-helm ./kubelet-csr-approver | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename -
|
||||||
|
- until kubectl wait --for=condition=Ready nodes --all --timeout=600s; do sleep 10; done
|
||||||
preconditions:
|
preconditions:
|
||||||
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
|
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
|
||||||
|
|
||||||
@@ -78,6 +88,23 @@ tasks:
|
|||||||
preconditions:
|
preconditions:
|
||||||
- { msg: "Node not found", sh: "talosctl --nodes {{.node}} get machineconfig" }
|
- { msg: "Node not found", sh: "talosctl --nodes {{.node}} get machineconfig" }
|
||||||
|
|
||||||
|
fetch-kubeconfig:
|
||||||
|
desc: Generate talos kubeconfig
|
||||||
|
dir: "{{.TALOS_DIR}}"
|
||||||
|
cmd: until talhelper gencommand kubeconfig --extra-flags "--force" | bash; do sleep 10; done
|
||||||
|
|
||||||
|
soft-nuke:
|
||||||
|
desc: Resets nodes back to maintenance mode so you can re-deploy again straight after
|
||||||
|
prompt: "This will destroy your cluster and reset the nodes back to maintenance mode. Are you sure?"
|
||||||
|
dir: "{{.TALOS_DIR}}"
|
||||||
|
cmd: talhelper gencommand reset --extra-flags "--reboot --system-labels-to-wipe STATE --system-labels-to-wipe EPHEMERAL --graceful=false --wait=false" | bash
|
||||||
|
|
||||||
|
hard-nuke:
|
||||||
|
desc: Resets nodes back completely and reboots them
|
||||||
|
prompt: "This will destroy your cluster and reset the nodes. Are you sure?"
|
||||||
|
dir: "{{.TALOS_DIR}}"
|
||||||
|
cmd: talhelper gencommand reset --extra-flags "--reboot --graceful=false --wait=false" | bash
|
||||||
|
|
||||||
.reset:
|
.reset:
|
||||||
internal: true
|
internal: true
|
||||||
cmd: rm -rf {{.TALOS_DIR}}
|
cmd: rm -rf {{.TALOS_DIR}}
|
||||||
@@ -283,30 +283,10 @@ You have two different options for setting up your local workstation.
|
|||||||
|
|
||||||
#### Talos
|
#### Talos
|
||||||
|
|
||||||
1. Create Talos Secrets and configuration
|
1. Deploy your cluster and bootstrap it. This generates secrets, generates the config files for your nodes and applies them. It bootstraps the cluster afterwards, fetches the kubeconfig file and installs Cilium and kubelet-csr-approver. It finishes with some health checks.
|
||||||
|
|
||||||
```sh
|
|
||||||
task talos:gensecret
|
|
||||||
task talos:genconfig
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Apply Talos Config
|
|
||||||
|
|
||||||
```sh
|
|
||||||
task talos:apply
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Boostrap Talos and get kubeconfig
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
task talos:bootstrap
|
task talos:bootstrap
|
||||||
task talos:kubeconfig node=$master_node_ip_address
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Install Cilium and kubelet-csr-approver into the cluster
|
|
||||||
|
|
||||||
```sh
|
|
||||||
task talos:apply-extras
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### k3s
|
#### k3s
|
||||||
@@ -448,8 +428,14 @@ By default Flux will periodically check your git repository for changes. In orde
|
|||||||
There might be a situation where you want to destroy your Kubernetes cluster. This will completely clean the OS of all traces of the Kubernetes distribution you chose and then reboot the nodes.
|
There might be a situation where you want to destroy your Kubernetes cluster. This will completely clean the OS of all traces of the Kubernetes distribution you chose and then reboot the nodes.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Nuke k3s
|
# k3s: Remove all traces of k3s from the nodes
|
||||||
task ansible:run playbook=cluster-nuke
|
task ansible:run playbook=cluster-nuke
|
||||||
|
|
||||||
|
# Talos: Reset your nodes back to maintenance mode and reboot
|
||||||
|
task talos:soft-nuke
|
||||||
|
|
||||||
|
# Talos: Comletely format your the Talos installation and reboot
|
||||||
|
task talos:hard-nuke
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🤖 Renovate
|
## 🤖 Renovate
|
||||||
|
|||||||
Reference in new issue
Block a user