summaryrefslogtreecommitdiff
path: root/playbooks.d/k3s-legacy/playbook.bash
diff options
context:
space:
mode:
Diffstat (limited to 'playbooks.d/k3s-legacy/playbook.bash')
-rw-r--r--playbooks.d/k3s-legacy/playbook.bash42
1 files changed, 42 insertions, 0 deletions
diff --git a/playbooks.d/k3s-legacy/playbook.bash b/playbooks.d/k3s-legacy/playbook.bash
new file mode 100644
index 0000000..351064c
--- /dev/null
+++ b/playbooks.d/k3s-legacy/playbook.bash
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+
+playbook_add() {
+ 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]}
+ node-ip: $(config "k3s.network.ip" "$(config "vpn.ipv4" "127.0.0.1")")
+ bind-address: $(config "k3s.network.bind" "$(config "vpn.ipv4" "0.0.0.0")")
+ cluster-cidr: $(config "k3s.network.cidr.pods")
+ service-cidr: $(config "k3s.network.cidr.svcs")
+ cluster-dns: $(config "k3s.network.service.dns")
+ cluster-domain: $(config "k3s.domain")
+ disable:
+ - traefik
+ EOF
+
+ info "$BASHTARD_PLAYBOOK" "Installing k3s"
+ curl -sfL https://get.k3s.io | sh - # I hate this
+ curl -L https://github.com/fluxcd/flux2/releases/download/v0.31.5/flux_0.31.5_linux_amd64.tar.gz | tar xzf - -C /usr/local/bin
+
+ notice "$BASHTARD_PLAYBOOK" "Waiting for node to become available"
+ { grep -q -m 1 "${BASHTARD_PLATFORM[fqdn]}[[:space:]]\+Ready"; kill $!; } < <(k3s kubectl get node -w)
+
+ info "$BASHTARD_PLAYBOOK" "Installing flux-system on k3s"
+ flux bootstrap git \
+ --branch="$(config "k3s.flux.repo.branch")" \
+ --cluster-domain="$(config "k3s.domain")" \
+ --kubeconfig=/etc/rancher/k3s/k3s.yaml \
+ --path="$(config "k3s.flux.repo.path" "playbooks.d/$BASHTARD_PLAYBOOK/manifests/clusters/${BASHTARD_PLATFORM[fqdn]}")" \
+ --private-key-file="$(config "k3s.flux.repo.privkey" "$HOME/.ssh/id.d/$USER@$(hostname -s)-ed25519")" \
+ --silent \
+ --url="$(config "k3s.flux.repo.url")"
+}
+
+playbook_sync() {
+ :;
+}
+
+playbook_del() {
+ /usr/local/bin/k3s-uninstall.sh
+}