blob: cfd0330e00921634842821fefef78343f55fea36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/usr/bin/env bash
playbook_add() {
pkg install curl
info "$BASHTARD_PLAYBOOK/add" "Writing config.yaml for k3s"
mkdir -pv -- /etc/rancher/k3s
{
cat <<-EOF
node-name: "${BASHTARD_PLATFORM[fqdn]}"
node-ip: "$(config "$BASHTARD_PLAYBOOK.internal-ip" "127.0.0.1")"
bind-address: "$(config "$BASHTARD_PLAYBOOK.bind-address" "0.0.0.0")"
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")"
disable:
- traefik
EOF
if [[ -n "$(config "$BASHTARD_PLAYBOOK.external-ip" "")" ]]
then
printf "%s: \"%s\"\n" "node-external-ip" "$(config "$BASHTARD_PLAYBOOK.external-ip" "")"
fi
} > "$(config "fs.etcdir")/rancher/k3s/config.yaml"
info "$BASHTARD_PLAYBOOK/add" "Installing k3s"
curl -sfL https://get.k3s.io | sh -s - server --cluster-init # I hate this
#notice "$BASHTARD_PLAYBOOK/add" "Creating data directories"
#mkdir -pv -- "$(playbook_path "data")/manifests.d"
notice "$BASHTARD_PLAYBOOK/add" "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 kubeconfig
local manifest_prefix
local values
data="$(playbook_path "data")"
kubeconfig="$(config "fs.etcdir")/rancher/k3s/k3s.yaml"
notice "$BASHTARD_PLAYBOOK/sync" "Applying manifests.d"
kubectl --kubeconfig "$kubeconfig" apply --recursive --filename "$data/manifests.d" || true
}
playbook_del() {
/usr/local/bin/k3s-uninstall.sh
}
|