khuedoan-homelab/infra/bootstrap.sh

57 lines
1.5 KiB
Bash
Raw Normal View History

2021-07-18 16:12:13 +07:00
#!/bin/sh
2021-07-21 00:15:26 +07:00
set -euo pipefail
2021-07-18 16:12:13 +07:00
# Create ephemeral cluster
kind create cluster \
--wait 60s \
2021-07-21 00:15:26 +07:00
--kubeconfig ephemeral-cluster/kind-kubeconfig.yaml \
--config ephemeral-cluster/kind.yaml
2021-07-18 16:12:13 +07:00
# Install Sidero
clusterctl init \
--bootstrap talos \
--control-plane talos \
--infrastructure sidero \
2021-07-21 00:15:26 +07:00
--kubeconfig ephemeral-cluster/kind-kubeconfig.yaml \
--config clusterctl.yaml
kubectl wait pods \
2021-07-21 00:15:26 +07:00
--kubeconfig ephemeral-cluster/kind-kubeconfig.yaml \
--all \
--all-namespaces \
2021-07-21 00:15:26 +07:00
--timeout 300s \
--for=condition=Ready
# Apply server classes
kubectl apply \
2021-07-21 00:15:26 +07:00
--kubeconfig ephemeral-cluster/kind-kubeconfig.yaml \
--filename serverclasses/
# Waker servers up
wol '00:23:24:d1:f3:f0'
# wol '00:23:24:d1:f4:d6'
# wol '00:23:24:d1:f5:69'
# wol '00:23:24:e7:04:60'
2021-07-18 16:12:13 +07:00
# Create cluster
2021-07-21 00:15:26 +07:00
export CONTROL_PLANE_ENDPOINT=$(kubectl get server \
--kubeconfig ephemeral-cluster/kind-kubeconfig.yaml \
--output jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
clusterctl config cluster \
--infrastructure sidero \
2021-07-21 00:15:26 +07:00
--kubeconfig ephemeral-cluster/kind-kubeconfig.yaml \
--config clusterctl.yaml \
homelab > cluster/homelab.yaml
kubectl apply \
2021-07-21 00:15:26 +07:00
--kubeconfig ephemeral-cluster/kind-kubeconfig.yaml \
--filename cluster/homelab.yaml
2021-07-18 18:37:40 +07:00
# Get kube config
2021-07-21 00:15:26 +07:00
clusterctl get kubeconfig \
--kubeconfig ephemeral-cluster/kind-kubeconfig.yaml \
homelab > kubeconfig.yaml
# Cleanup ephemeral cluster
# kind delete cluster --name bootstrap-cluster
# rm ephemeral-cluster/kind-kubeconfig.yaml