Make bootstrap script a bit more dynamic

This commit is contained in:
Khue Doan 2021-07-20 23:31:15 +07:00
parent a94103bc5d
commit bf70d4c04b
No known key found for this signature in database
GPG Key ID: 4C1A90A461B3C27B
2 changed files with 27 additions and 34 deletions

View File

@ -2,45 +2,39 @@
set -e
# DHCP server
# Create ephemeral cluster
kind create cluster \
--wait 60s \
--config kind.yaml
talosctl cluster create \
-p 69:69/udp,8081:8081/tcp \
--workers 0 \
--endpoint '192.168.1.19'
# Install Sidero
clusterctl init \
--bootstrap talos \
--control-plane talos \
--infrastructure sidero \
--config clusterctl.yaml
kubectl wait pods \
--all \
--all-namespaces \
--for=condition=Ready
kubectl taint node talos-default-master-1 node-role.kubernetes.io/master:NoSchedule-
clusterctl init -b talos -c talos -i sidero --config clusterctl.yaml
# Apply server classes
kubectl apply \
--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'
kubectl apply -f serverclasses
# Create cluster
export CONTROL_PLANE_ENDPOINT=$(kubectl get server -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
clusterctl config cluster homelab \
--infrastructure sidero \
--config clusterctl.yaml > cluster/homelab.yaml
kubectl apply \
--filename cluster/homelab.yaml
# Wait for servers to register
sleep 30
clusterctl config cluster management-plane -i sidero --config clusterctl.yaml > cluster/management-plane.yaml
kubectl apply -f cluster/
kubectl get talosconfig \
-l cluster.x-k8s.io/cluster-name=management-plane \
-o yaml -o jsonpath='{.items[0].status.talosConfig}' > management-plane-talosconfig.yaml
clusterctl init \
--kubeconfig-context=admin@management-plane
-i sidero -b talos -c talos
clusterctl move \
--kubeconfig-context=admin@talos-default \
--to-kubeconfig=$HOME/.kube/config \
--to-kubeconfig-context=admin@management-plane
kubectl taint node talos-192-168-1-24 node-role.kubernetes.io/master:NoSchedule-
kubectl patch deploy -n sidero-system sidero-controller-manager --type='json' -p='[{"op": "add", "path": "/spec/template/spec/hostNetwork", "value": true}]'
# Get kube config
clusterctl get kubeconfig homelab > kubeconfig.yaml

View File

@ -5,7 +5,6 @@ SIDERO_CONTROLLER_MANAGER_HOST_NETWORK: true
CONTROL_PLANE_SERVERCLASS: m5.xlarge
WORKER_SERVERCLASS: m5.xlarge
CONTROL_PLANE_ENDPOINT: 192.168.1.12
CONTROL_PLANE_PORT: 6443
KUBERNETES_VERSION: v1.21.1