feat!: Remove support for k3s and go full-on Talos (#1482)
This commit is contained in:
1 parent
f4eb701ac6
commit
21afc0baa2
96 files changed
+508
-1845
No files matched your search
@@ -1,88 +0,0 @@
|
||||
---
|
||||
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
ANSIBLE_LINT_FILE: "{{.ANSIBLE_DIR}}/.ansible-lint"
|
||||
ANSIBLE_INVENTORY_FILE: "{{.ANSIBLE_DIR}}/inventory/hosts.yaml"
|
||||
ANSIBLE_REQUIREMENTS_FILE: "{{.ANSIBLE_DIR}}/requirements.yaml"
|
||||
ANSIBLE_PIP_REQUIREMENTS_FILE: "{{.ANSIBLE_DIR}}/requirements.txt"
|
||||
|
||||
env:
|
||||
ANSIBLE_COLLECTIONS_PATH: "{{.VIRTUAL_ENV}}/galaxy"
|
||||
ANSIBLE_ROLES_PATH: "{{.VIRTUAL_ENV}}/galaxy/ansible_roles"
|
||||
ANSIBLE_VARS_ENABLED: "host_group_vars"
|
||||
ANSIBLE_LOCALHOST_WARNING: "False"
|
||||
ANSIBLE_INVENTORY_UNPARSED_WARNING: "False"
|
||||
|
||||
tasks:
|
||||
|
||||
deps:
|
||||
desc: Set up Ansible dependencies
|
||||
deps: [":workstation:venv"]
|
||||
cmds:
|
||||
- '{{.VIRTUAL_ENV}}/bin/python3 -m pip install --upgrade --requirement "{{.ANSIBLE_PIP_REQUIREMENTS_FILE}}"'
|
||||
- '{{.VIRTUAL_ENV}}/bin/ansible-galaxy install --role-file "{{.ANSIBLE_REQUIREMENTS_FILE}}" {{if eq .force "true"}}--force{{end}}'
|
||||
preconditions:
|
||||
- { msg: "Missing Ansible requirements file", sh: "test -f {{.ANSIBLE_REQUIREMENTS_FILE}}" }
|
||||
- { msg: "Missing Pip requirements file", sh: "test -f {{.ANSIBLE_PIP_REQUIREMENTS_FILE}}" }
|
||||
sources:
|
||||
- "{{.ANSIBLE_REQUIREMENTS_FILE}}"
|
||||
- "{{.ANSIBLE_PIP_REQUIREMENTS_FILE}}"
|
||||
generates:
|
||||
- "{{.VIRTUAL_ENV}}/bin/ansible"
|
||||
- "{{.VIRTUAL_ENV}}/bin/ansible-galaxy"
|
||||
vars:
|
||||
force: '{{.force | default "true"}}'
|
||||
|
||||
run:
|
||||
desc: Run an Ansible playbook for configuring a cluster
|
||||
summary: |
|
||||
Args:
|
||||
playbook: Playbook to run (required)
|
||||
prompt: Run Ansible playbook '{{.playbook}}'... continue?
|
||||
deps: ["deps"]
|
||||
cmd: "{{.VIRTUAL_ENV}}/bin/ansible-playbook --inventory {{.ANSIBLE_INVENTORY_FILE}} {{.ANSIBLE_DIR}}/playbooks/{{.playbook}}.yaml {{.CLI_ARGS}}"
|
||||
requires:
|
||||
vars: ["playbook"]
|
||||
preconditions:
|
||||
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
||||
|
||||
poweroff:
|
||||
desc: Shutdown all the k8s nodes
|
||||
deps: ["deps"]
|
||||
cmd: "{{.VIRTUAL_ENV}}/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} -a '/usr/bin/systemctl poweroff' --become"
|
||||
preconditions:
|
||||
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
||||
|
||||
list:
|
||||
desc: List all the hosts
|
||||
deps: ["deps"]
|
||||
cmd: "{{.VIRTUAL_ENV}}/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} --list-hosts"
|
||||
preconditions:
|
||||
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
||||
|
||||
ping:
|
||||
desc: Ping all the hosts
|
||||
deps: ["deps"]
|
||||
cmd: "{{.VIRTUAL_ENV}}/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} --one-line -m 'ping'"
|
||||
preconditions:
|
||||
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
||||
|
||||
uptime:
|
||||
desc: Uptime of all the hosts
|
||||
deps: ["deps"]
|
||||
cmd: "{{.VIRTUAL_ENV}}/bin/ansible kubernetes --inventory {{.ANSIBLE_INVENTORY_FILE}} --one-line -a 'uptime'"
|
||||
preconditions:
|
||||
- { msg: "Missing Ansible inventory file", sh: "test -f {{.ANSIBLE_INVENTORY_FILE}}" }
|
||||
|
||||
lint:
|
||||
desc: Lint Ansible
|
||||
deps: ["deps"]
|
||||
cmd: "{{.VIRTUAL_ENV}}/bin/ansible-lint --config-file {{.ANSIBLE_LINT_FILE}} {{.ANSIBLE_DIR}}/**/*.yaml"
|
||||
preconditions:
|
||||
- { msg: "Missing Ansible lint file", sh: "test -f {{.ANSIBLE_LINT_FILE}}" }
|
||||
|
||||
.reset:
|
||||
internal: true
|
||||
cmd: rm -rf {{.ANSIBLE_DIR}}
|
||||
@@ -3,8 +3,6 @@
|
||||
version: "3"
|
||||
|
||||
vars:
|
||||
# renovate: datasource=github-releases depName=prometheus-operator/prometheus-operator
|
||||
PROMETHEUS_OPERATOR_VERSION: v0.74.0
|
||||
CLUSTER_SECRET_SOPS_FILE: "{{.KUBERNETES_DIR}}/flux/vars/cluster-secrets.sops.yaml"
|
||||
CLUSTER_SETTINGS_FILE: "{{.KUBERNETES_DIR}}/flux/vars/cluster-settings.yaml"
|
||||
GITHUB_DEPLOY_KEY_FILE: "{{.KUBERNETES_DIR}}/bootstrap/flux/github-deploy-key.sops.yaml"
|
||||
@@ -14,18 +12,16 @@ tasks:
|
||||
bootstrap:
|
||||
desc: Bootstrap Flux into a Kubernetes cluster
|
||||
cmds:
|
||||
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/{{.PROMETHEUS_OPERATOR_VERSION}}/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml
|
||||
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/{{.PROMETHEUS_OPERATOR_VERSION}}/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml
|
||||
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/{{.PROMETHEUS_OPERATOR_VERSION}}/example/prometheus-operator-crd/monitoring.coreos.com_scrapeconfigs.yaml
|
||||
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/{{.PROMETHEUS_OPERATOR_VERSION}}/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
|
||||
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --kustomize {{.KUBERNETES_DIR}}/bootstrap/flux
|
||||
- cat {{.AGE_FILE}} | kubectl -n flux-system create secret generic sops-age --from-file=age.agekey=/dev/stdin
|
||||
- sops --decrypt {{.CLUSTER_SECRET_SOPS_FILE}} | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename -
|
||||
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename {{.CLUSTER_SETTINGS_FILE}}
|
||||
- kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --kustomize {{.KUBERNETES_DIR}}/flux/config
|
||||
preconditions:
|
||||
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
|
||||
- { msg: "Missing Sops Age key file", sh: "test -f {{.AGE_FILE}}" }
|
||||
- msg: Missing kubeconfig
|
||||
sh: test -f {{.KUBECONFIG_FILE}}
|
||||
- msg: Missing Sops Age key file
|
||||
sh: test -f {{.AGE_FILE}}
|
||||
|
||||
apply:
|
||||
desc: Apply a Flux Kustomization resource for a cluster
|
||||
@@ -49,20 +45,26 @@ tasks:
|
||||
ks:
|
||||
sh: flux --kubeconfig {{.KUBECONFIG_FILE}} --namespace {{.ns}} get kustomizations $(basename {{.path}}) 2>&1
|
||||
preconditions:
|
||||
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
|
||||
- { msg: "Missing Flux Kustomization for app {{.path}}", sh: "test -f {{.KUBERNETES_DIR}}/apps/{{.path}}/ks.yaml" }
|
||||
- msg: Missing kubeconfig
|
||||
sh: test -f {{.KUBECONFIG_FILE}}
|
||||
- msg: Missing Flux Kustomization for app {{.path}}
|
||||
sh: test -f {{.KUBERNETES_DIR}}/apps/{{.path}}/ks.yaml
|
||||
|
||||
reconcile:
|
||||
desc: Force update Flux to pull in changes from your Git repository
|
||||
cmd: flux --kubeconfig {{.KUBECONFIG_FILE}} reconcile --namespace flux-system kustomization cluster --with-source
|
||||
preconditions:
|
||||
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
|
||||
- msg: Missing kubeconfig
|
||||
sh: test -f {{.KUBECONFIG_FILE}}
|
||||
|
||||
github-deploy-key:
|
||||
cmds:
|
||||
- kubectl create namespace flux-system --dry-run=client -o yaml | kubectl --kubeconfig {{.KUBECONFIG_FILE}} apply --filename -
|
||||
- sops --decrypt {{.GITHUB_DEPLOY_KEY_FILE}} | kubectl apply --kubeconfig {{.KUBECONFIG_FILE}} --server-side --filename -
|
||||
preconditions:
|
||||
- { msg: "Missing kubeconfig", sh: "test -f {{.KUBECONFIG_FILE}}" }
|
||||
- { msg: "Missing Sops Age key file", sh: "test -f {{.AGE_FILE}}" }
|
||||
- { msg: "Missing Github deploy key file", sh: "test -f {{.GITHUB_DEPLOY_KEY_FILE}}" }
|
||||
- msg: Missing kubeconfig
|
||||
sh: test -f {{.KUBECONFIG_FILE}}
|
||||
- msg: Missing Sops Age key file
|
||||
sh: test -f {{.AGE_FILE}}
|
||||
- msg: Missing Github deploy key file
|
||||
sh: test -f {{.GITHUB_DEPLOY_KEY_FILE}}
|
||||
@@ -28,7 +28,8 @@ tasks:
|
||||
desc: Validate Kubernetes manifests with kubeconform
|
||||
cmd: bash {{.KUBECONFORM_SCRIPT}} {{.KUBERNETES_DIR}}
|
||||
preconditions:
|
||||
- { msg: "Missing kubeconform script", sh: "test -f {{.KUBECONFORM_SCRIPT}}" }
|
||||
- msg: Missing kubeconform script
|
||||
sh: test -f {{.KUBECONFORM_SCRIPT}}
|
||||
|
||||
.reset:
|
||||
internal: true
|
||||
|
||||
@@ -20,14 +20,15 @@ tasks:
|
||||
# Update renovate.json5
|
||||
- sed -i {{if eq OS "darwin"}}''{{end}} 's/(..\.j2)\?//g' {{.ROOT_DIR}}/.github/renovate.json5
|
||||
preconditions:
|
||||
- { msg: "Missing bootstrap directory", sh: "test -d {{.BOOTSTRAP_DIR}}" }
|
||||
- { msg: "Missing Renovate config file", sh: "test -f {{.ROOT_DIR}}/.github/renovate.json5" }
|
||||
- msg: Missing bootstrap directory
|
||||
sh: test -d {{.BOOTSTRAP_DIR}}
|
||||
- msg: Missing Renovate config file
|
||||
sh: test -f {{.ROOT_DIR}}/.github/renovate.json5
|
||||
|
||||
reset:
|
||||
desc: Reset templated configuration files
|
||||
prompt: Reset templated configuration files... continue?
|
||||
cmds:
|
||||
- task: :ansible:.reset
|
||||
- task: :kubernetes:.reset
|
||||
- task: :sops:.reset
|
||||
- task: :talos:.reset
|
||||
|
||||
@@ -10,8 +10,7 @@ tasks:
|
||||
age-keygen:
|
||||
desc: Initialize Age Key for Sops
|
||||
cmd: age-keygen --output {{.AGE_FILE}}
|
||||
status:
|
||||
- test -f "{{.AGE_FILE}}"
|
||||
status: ["test -f {{.AGE_FILE}}"]
|
||||
|
||||
encrypt:
|
||||
desc: Encrypt all Kubernetes SOPS secrets that are not already encrypted
|
||||
@@ -33,8 +32,10 @@ tasks:
|
||||
requires:
|
||||
vars: ["file"]
|
||||
preconditions:
|
||||
- { msg: "Missing Sops config file", sh: "test -f {{.SOPS_CONFIG_FILE}}" }
|
||||
- { msg: "Missing Sops Age key file", sh: "test -f {{.AGE_FILE}}" }
|
||||
- msg: Missing Sops config file
|
||||
sh: test -f {{.SOPS_CONFIG_FILE}}
|
||||
- msg: Missing Sops Age key file
|
||||
sh: test -f {{.AGE_FILE}}
|
||||
|
||||
.reset:
|
||||
internal: true
|
||||
|
||||
@@ -32,25 +32,28 @@ tasks:
|
||||
- task: :sops:.encrypt-file
|
||||
vars:
|
||||
file: "{{.TALHELPER_SECRET_FILE}}"
|
||||
status: ["test -f {{.TALHELPER_SECRET_FILE}}"]
|
||||
preconditions:
|
||||
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
||||
status:
|
||||
- test -f "{{.TALHELPER_SECRET_FILE}}"
|
||||
- msg: Missing talhelper config file
|
||||
sh: test -f {{.TALHELPER_CONFIG_FILE}}
|
||||
|
||||
bootstrap-genconfig:
|
||||
desc: Generate the Talos configs
|
||||
dir: "{{.TALOS_DIR}}"
|
||||
cmd: talhelper genconfig --secret-file {{.TALHELPER_SECRET_FILE}}
|
||||
preconditions:
|
||||
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
||||
- { msg: "Missing talhelper secret file", sh: "test -f {{.TALHELPER_SECRET_FILE}}" }
|
||||
- msg: Missing talhelper config file
|
||||
sh: test -f {{.TALHELPER_CONFIG_FILE}}
|
||||
- msg: Missing talhelper secret file
|
||||
sh: test -f {{.TALHELPER_SECRET_FILE}}
|
||||
|
||||
bootstrap-apply:
|
||||
desc: Apply the Talos configs to the nodes
|
||||
dir: "{{.TALOS_DIR}}"
|
||||
cmd: talhelper gencommand apply --extra-flags=--insecure | bash
|
||||
preconditions:
|
||||
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
||||
- msg: Missing talhelper config file
|
||||
sh: test -f {{.TALHELPER_CONFIG_FILE}}
|
||||
|
||||
bootstrap-install:
|
||||
desc: Install the Talos cluster
|
||||
@@ -60,17 +63,19 @@ tasks:
|
||||
- until talhelper gencommand bootstrap | bash; do sleep 10; done
|
||||
- sleep 10
|
||||
preconditions:
|
||||
- { msg: "Missing talhelper config file", sh: "test -f {{.TALHELPER_CONFIG_FILE}}" }
|
||||
- msg: Missing talhelper config file
|
||||
sh: test -f {{.TALHELPER_CONFIG_FILE}}
|
||||
|
||||
bootstrap-apps:
|
||||
desc: Bootstrap core apps needed for Talos
|
||||
dir: "{{.TALOS_DIR}}"
|
||||
cmds:
|
||||
- until kubectl --kubeconfig {{.KUBECONFIG_FILE}} wait --for=condition=Ready=False nodes --all --timeout=600s; do sleep 10; done
|
||||
- helmfile --kubeconfig {{.KUBECONFIG_FILE}} --file ./apps/helmfile.yaml apply --skip-diff-on-install --suppress-diff
|
||||
- helmfile --kubeconfig {{.KUBECONFIG_FILE}} --file helmfile.yaml 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 kubeconfig
|
||||
sh: test -f {{.KUBECONFIG_FILE}}
|
||||
|
||||
upgrade-talos:
|
||||
desc: Upgrade talos on a node
|
||||
@@ -78,7 +83,8 @@ tasks:
|
||||
requires:
|
||||
vars: ["node", "image"]
|
||||
preconditions:
|
||||
- { msg: "Node not found", sh: "talosctl --nodes {{.node}} get machineconfig" }
|
||||
- msg: Node not found
|
||||
sh: talosctl --nodes {{.node}} get machineconfig
|
||||
|
||||
upgrade-k8s:
|
||||
desc: Upgrade k8s on a node
|
||||
@@ -86,24 +92,19 @@ tasks:
|
||||
requires:
|
||||
vars: ["node", "to"]
|
||||
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 "{{.ROOT_DIR}} --force" | bash; do sleep 10; done
|
||||
|
||||
soft-nuke:
|
||||
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... continue?
|
||||
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... continue?
|
||||
dir: "{{.TALOS_DIR}}"
|
||||
cmd: talhelper gencommand reset --extra-flags "--reboot --graceful=false --wait=false" | bash
|
||||
cmd: talhelper gencommand reset --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
|
||||
|
||||
Reference in new issue
Block a user