summaryrefslogtreecommitdiff
path: root/playbook.bash
diff options
context:
space:
mode:
Diffstat (limited to 'playbook.bash')
-rw-r--r--playbook.bash57
1 files changed, 10 insertions, 47 deletions
diff --git a/playbook.bash b/playbook.bash
index 0cbf315..49b6ee8 100644
--- a/playbook.bash
+++ b/playbook.bash
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
playbook_add() {
- pkg install curl
+ pkg install curl nfs-common open-iscsi
case "${BASHTARD_PLATFORM[key]}" in
linux-debian_gnu_linux|linux-ubuntu)
@@ -23,17 +23,18 @@ playbook_add() {
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
+ node-ip: "$(config "$BASHTARD_PLAYBOOK.node-ip" "$(config "bashtard.ssh.host")")"
+ cluster-cidr: "$(config "$BASHTARD_PLAYBOOK.cluster-cidr" "172.19.0.0/16")"
+ service-cidr: "$(config "$BASHTARD_PLAYBOOK.service-cidr" "172.20.0.0/16")"
+ cluster-domain: "$(config "$BASHTARD_PLAYBOOK.cluster-domain" "cluster.local")"
+ service-node-port-range: "$(config "$BASHTARD_PLAYBOOK.service-node-port-min" "30000")-$(config "$BASHTARD_PLAYBOOK.service-node-port-max" "32767")"
EOF
info "$BASHTARD_PLAYBOOK" "Installing k3s"
- curl -sfL https://get.k3s.io | sh - # I hate this
+ curl -sfL https://get.k3s.io | sh -s - server --cluster-init # 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)
@@ -43,54 +44,16 @@ playbook_add() {
playbook_sync() {
local data
- local helm_cmd
local kubeconfig
+ local manifest_prefix
local values
data="$(playbook_path "data")"
kubeconfig="$(config "fs.etcdir")/rancher/k3s/k3s.yaml"
+ manifest_prefix="$(config "$BASHTARD_PLAYBOOK.manifest-prefix" "")"
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
- values="$(config "$BASHTARD_PLAYBOOK.helm.apps.$app.values" "")"
-
- if [[ -n "$values" ]]
- then
- helm_cmd+=("--values" "$data/helm.d/$values")
- fi
-
- # Set which chart to upgrade
- helm_cmd+=("$app")
- helm_cmd+=("$(config "$BASHTARD_PLAYBOOK.helm.apps.$app.chart")")
-
- notice "$BASHTARD_PLAYBOOK/helm/$app" "> ${helm_cmd[*]}"
- ${helm_cmd[@]} > /dev/null
-
- unset helm_cmd
- unset values
- done < <(config_subkeys "$BASHTARD_PLAYBOOK.helm.apps")
+ kubectl --kubeconfig "$kubeconfig" apply --recursive --filename "$data/manifests.d/$manifest_prefix"
}
playbook_del() {