Files
home-cluster/.taskfiles/K0s/Taskfile.yaml
T
2024-01-26 20:34:04 -05:00

47 lines
1.3 KiB
YAML

---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"
vars:
K0S_DIR: "{{.KUBERNETES_DIR}}/k0s"
K0S_CONFIG_FILE: "{{.K0S_DIR}}/k0sctl.yaml"
env:
DISABLE_TELEMETRY: "true"
DISABLE_UPGRADE_CHECK: "true"
tasks:
apply:
desc: Apply k0s cluster config
dir: "{{.K0S_DIR}}"
cmds:
- k0sctl apply --config {{.K0S_CONFIG_FILE}}
- task: kubeconfig
preconditions:
- { msg: "Missing K0s config file", sh: "test -f {{.K0S_CONFIG_FILE}}" }
nuke:
desc: Nuke the k0s cluster
dir: "{{.K0S_DIR}}"
cmd: k0sctl reset --config {{.K0S_CONFIG_FILE}}
preconditions:
- { msg: "Missing K0s config file", sh: "test -f {{.K0S_CONFIG_FILE}}" }
kubeconfig:
desc: Gets k0s kubeconfig
dir: "{{.K0S_DIR}}"
prompt: This will overwrite the existing kubeconfig... continue?
cmds:
- k0sctl kubeconfig --config {{.K0S_CONFIG_FILE}} > {{.KUBECONFIG_FILE}}
- sed -i {{if eq OS "darwin"}}''{{end}} 's|https://.+:6443|https://{{.kube_api_addr}}:6443|g' {{.KUBECONFIG_FILE}}
vars:
kube_api_addr:
sh: "yq '.bootstrap_kube_api_addr' {{.BOOTSTRAP_CONFIG_FILE}}"
preconditions:
- { msg: "Missing K0s config file", sh: "test -f {{.K0S_CONFIG_FILE}}" }
.reset:
internal: true
cmd: rm -rf {{.K0S_CONFIG_FILE}}