#!/bin/bash set -e set -u set -x SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") source ${SCRIPT_DIR}/helper.sh set_remote $1 # Setup k3s ARGS="--tls-san=$VIP --disable servicelb --disable traefik --etcd-s3 --etcd-s3-endpoint=s3.us-west-002.backblazeb2.com --etcd-s3-bucket=titan-k3s-backup --etcd-s3-folder=testing --cluster-init" ssh -t $REMOTE "curl -sfL https://get.k3s.io | INSTALL_K3S_SKIP_START=true INSTALL_K3S_EXEC=\"server $ARGS\" sh -" add_b2_key_to_k3s_env start_k3s # Copy over kubeconfig ssh -t $REMOTE "sudo -S cp /etc/rancher/k3s/k3s.yaml ~/k3s.yaml && sudo chown titan:titan ~/k3s.yaml" scp $REMOTE:~/k3s.yaml ~/.kube/config ssh -t $REMOTE "rm ~/k3s.yaml" # Update up to correct ip sed -i -e "s/127.0.0.1/$REMOTE_IP/" ~/.kube/config add_interface_label kubectl apply -k ${SCRIPT_DIR}/../clusters/titan.lan.huizinga.dev/kube-vip/ echo "Join the other nodes to the cluster, once done hit enter" read # Add sops secret to the cluster kubectl apply -f ${SCRIPT_DIR}/namespace.yaml sops decrypt ${SCRIPT_DIR}/sops-gpg.yaml | kubectl apply -f - # Bootstrap flux on the node flux bootstrap git --url ssh://git@huizinga.dev/Dreaded_X/flux-infra --branch=master --path=clusters/titan.lan.huizinga.dev --components source-controller,kustomize-controller,helm-controller # Update the ip to the control plane virtual ip sed -i -e "s/$REMOTE_IP/$VIP/" ~/.kube/config kubectl get nodes