summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2024-04-03 13:21:50 +0200
committerPatrick Spek <p.spek@tyil.nl>2024-04-03 13:21:50 +0200
commitb782fea00c1a2aa93e451ec61bc9aebee4340258 (patch)
treed1fa6e9e755ec4c6d336e87c4d2dd7a496b36bdb
parent51212b01cc27202ba23fbcf3dd5e2684b9f8f90e (diff)
Update k3s-node playbook
-rw-r--r--playbooks.d/k3s-node/playbook.bash34
1 files changed, 29 insertions, 5 deletions
diff --git a/playbooks.d/k3s-node/playbook.bash b/playbooks.d/k3s-node/playbook.bash
index f2ae8d6..bcf4930 100644
--- a/playbooks.d/k3s-node/playbook.bash
+++ b/playbooks.d/k3s-node/playbook.bash
@@ -4,29 +4,42 @@ BASHTARD_PLAYBOOK_VARS[$BASHTARD_PLAYBOOK.entry.host]="required"
BASHTARD_PLAYBOOK_VARS[$BASHTARD_PLAYBOOK.entry.token]="required"
playbook_add() {
- pkg install curl nfs-common open-iscsi
+ local role
+
+ role="$(config "$BASHTARD_PLAYBOOK.role" "agent")"
+
+ pkg install curl
info "$BASHTARD_PLAYBOOK" "Writing config.yaml for k3s"
mkdir -pv -- /etc/rancher/k3s
cat <<-EOF > /etc/rancher/k3s/config.yaml
- node-ip: "$(config "$BASHTARD_PLAYBOOK.node-ip" "$(config "bashtard.ssh.host")")"
node-name: "${BASHTARD_PLATFORM[fqdn]}"
+ node-ip: "$(config "$BASHTARD_PLAYBOOK.internal-ip" "127.0.0.1")"
server: "https://$(config "$BASHTARD_PLAYBOOK.entry.host"):$(config "$BASHTARD_PLAYBOOK.entry.port" "6443")"
token: "$(config "$BASHTARD_PLAYBOOK.entry.token")"
EOF
- if [[ "$(config "$BASHTARD_PLAYBOOK.role")" == "server" ]]
+ if [[ -n "$(config "$BASHTARD_PLAYBOOK.external-ip" "")" ]]
+ then
+ printf "%s: %s\n" "node-external-ip" "$(config "$BASHTARD_PLAYBOOK.external-ip" "")"\
+ >> /etc/rancher/k3s/config.yaml
+ fi
+
+ if [[ "$role" == "server" ]]
then
cat <<-EOF >> /etc/rancher/k3s/config.yaml
cluster-cidr: "$(config "$BASHTARD_PLAYBOOK.cluster-cidr" "172.19.0.0/16")"
cluster-domain: "$(config "$BASHTARD_PLAYBOOK.cluster-domain" "cluster.local")"
service-cidr: "$(config "$BASHTARD_PLAYBOOK.service-cidr" "172.20.0.0/16")"
service-node-port-range: "$(config "$BASHTARD_PLAYBOOK.service-node-port-min" "30000")-$(config "$BASHTARD_PLAYBOOK.service-node-port-max" "32767")"
+ flannel-ipv6-masq: true
+ disable:
+ - traefik
EOF
fi
info "$BASHTARD_PLAYBOOK" "Installing k3s"
- curl -sfL https://get.k3s.io | sh -s - "$(config "$BASHTARD_PLAYBOOK.role" "agent")"
+ curl -sfL https://get.k3s.io | sh -s - "$role"
notice "$BASHTARD_PLAYBOOK" "Waiting for node to become available"
{ grep -q -m 1 "${BASHTARD_PLATFORM[fqdn]}[[:space:]]\+Ready"; kill $!; } < <(k3s kubectl get node -w)
@@ -37,5 +50,16 @@ playbook_sync() {
}
playbook_del() {
- /usr/local/bin/k3s-uninstall.sh
+ local role
+
+ role="$(config "$BASHTARD_PLAYBOOK.role" "agent")"
+
+ case "$role" in
+ server)
+ /usr/local/bin/k3s-uninstall.sh
+ ;;
+ agent)
+ /usr/local/bin/k3s-agent-uninstall.sh
+ ;;
+ esac
}