summaryrefslogtreecommitdiff
path: root/playbooks.d
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-04-04 21:35:50 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-04-04 21:35:50 +0200
commitad04ba4f26dc3ed516d015beeb11ce95861a1d9f (patch)
tree56fd407a0af9e1324f40446bb22e6f438f6afd54 /playbooks.d
parent55f34fa8b8e276e1ba5f295ed963b490f861e24d (diff)
Reconstruct k3s-master as k3s-hurzak
Diffstat (limited to 'playbooks.d')
m---------playbooks.d/k3s-hurzak0
-rw-r--r--playbooks.d/k3s-master/description.txt1
-rw-r--r--playbooks.d/k3s-master/etc/defaults4
-rw-r--r--playbooks.d/k3s-master/etc/os.d/linux-gentoo2
-rw-r--r--playbooks.d/k3s-master/playbook.bash91
5 files changed, 0 insertions, 98 deletions
diff --git a/playbooks.d/k3s-hurzak b/playbooks.d/k3s-hurzak
new file mode 160000
+Subproject ec25e79c434a072603f3e278fbc266d509ba6d5
diff --git a/playbooks.d/k3s-master/description.txt b/playbooks.d/k3s-master/description.txt
deleted file mode 100644
index bf1fbab..0000000
--- a/playbooks.d/k3s-master/description.txt
+++ /dev/null
@@ -1 +0,0 @@
-Playbook for a k3s node
diff --git a/playbooks.d/k3s-master/etc/defaults b/playbooks.d/k3s-master/etc/defaults
deleted file mode 100644
index 51e58ad..0000000
--- a/playbooks.d/k3s-master/etc/defaults
+++ /dev/null
@@ -1,4 +0,0 @@
-pkg.curl=curl
-pkg.helm=helm
-pkg.k3s=k3s
-pkg.kubectl=kubectl
diff --git a/playbooks.d/k3s-master/etc/os.d/linux-gentoo b/playbooks.d/k3s-master/etc/os.d/linux-gentoo
deleted file mode 100644
index 4aaaabf..0000000
--- a/playbooks.d/k3s-master/etc/os.d/linux-gentoo
+++ /dev/null
@@ -1,2 +0,0 @@
-pkg.k3s=sys-cluster/k3s
-pkg.helm=app-admin/helm
diff --git a/playbooks.d/k3s-master/playbook.bash b/playbooks.d/k3s-master/playbook.bash
deleted file mode 100644
index a2a301b..0000000
--- a/playbooks.d/k3s-master/playbook.bash
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env bash
-
-playbook_add() {
- pkg install curl
-
- case "${BASHTARD_PLATFORM[key]}" in
- linux-debian|linux-ubuntu)
- info "$BASHTARD_PLAYBOOK" "Configure package manager repositories"
- curl https://baltocdn.com/helm/signing.asc | gpg --dearmor > /usr/share/keyrings/helm.gpg
- printf "deb [arch=%s signed-by=%s] %s all main\n" \
- "$(dpkg --print-architecture)" \
- "/usr/share/keyrings/helm.gpg" \
- "https://baltocdn.com/helm/stable/debian/" \
- > "/etc/apt/sources.list.d/$BASHTARD_PLAYBOOK.list"
- apt update
- ;;
- esac
-
- info "$BASHTARD_PLAYBOOK" "Installing additional programs"
- pkg install helm
-
- info "$BASHTARD_PLAYBOOK" "Writing config.yaml for k3s"
- mkdir -pv -- /etc/rancher/k3s
- cat <<-EOF > /etc/rancher/k3s/config.yaml
- node-name: "${BASHTARD_PLATFORM[fqdn]}"
- cluster-cidr: 172.19.0.0/16
- service-cidr: 172.20.0.0/16
- cluster-domain: cluster.local
- EOF
-
- info "$BASHTARD_PLAYBOOK" "Installing k3s"
- curl -sfL https://get.k3s.io | sh - # I hate this
-
- notice "$BASHTARD_PLAYBOOK" "Creating data directories"
- mkdir -pv -- "$(playbook_path "data")/manifests.d"
- mkdir -pv -- "$(playbook_path "data")/helm.d"
-
- notice "$BASHTARD_PLAYBOOK" "Waiting for node to become available"
- { grep -q -m 1 "${BASHTARD_PLATFORM[fqdn]}[[:space:]]\+Ready"; kill $!; } < <(k3s kubectl get node -w)
-
- playbook_sync
-}
-
-playbook_sync() {
- local data
- local helm_cmd
- local kubeconfig
-
- data="$(playbook_path "data")"
- kubeconfig="$(config "fs.etcdir")/rancher/k3s/k3s.yaml"
-
- notice "$BASHTARD_PLAYBOOK/manifests" "Applying manifests.d"
- kubectl --kubeconfig "$kubeconfig" apply --recursive --filename "$data/manifests.d"
-
- notice "$BASHTARD_PLAYBOOK/helm" "Ensure all Helm repos exist"
- while read -r repo
- do
- helm repo add "$repo" "$(config "$BASHTARD_PLAYBOOK.helm.repos.$repo.url")"
- done < <(config_subkeys "$BASHTARD_PLAYBOOK.helm.repos")
-
- notice "$BASHTARD_PLAYBOOK/helm" "Updating Helm repository contents"
- helm repo update
-
- notice "$BASHTARD_PLAYBOOK/helm" "Upgrading Helm charts"
- while read -r app
- do
- helm_cmd=(
- "helm" "upgrade"
- "--install"
- "--kubeconfig" "$kubeconfig"
- "--timeout" "$(config "$BASHTARD_PLAYBOOK.helm.timeout" "30s")"
- "--namespace" "$(config "$BASHTARD_PLAYBOOK.helm.apps.$app.namespace" "default")"
- )
-
- # Add values
- helm_cmd+=("--values" "$data/helm.d/$(config "$BASHTARD_PLAYBOOK.helm.apps.$app.values")")
-
- # Set which chart to upgrade
- helm_cmd+=("$app")
- helm_cmd+=("$(config "$BASHTARD_PLAYBOOK.helm.apps.$app.repo")/$(config "$BASHTARD_PLAYBOOK.helm.apps.$app.chart")")
-
- notice "$BASHTARD_PLAYBOOK/helm/$app" "> ${helm_cmd[*]}"
- ${helm_cmd[@]}
-
- unset helm_cmd
- done < <(config_subkeys "$BASHTARD_PLAYBOOK.helm.apps")
-}
-
-playbook_del() {
- /usr/local/bin/k3s-uninstall.sh
-}