mirror of
https://github.com/wahyd4/home-docker.git
synced 2026-08-09 04:15:52 +10:00
49 lines
1.3 KiB
Bash
49 lines
1.3 KiB
Bash
#! /bin/bash -eu
|
|
|
|
# Update HOST0, HOST1 and HOST2 with the IPs of your hosts
|
|
export HOST0=192.168.1.2
|
|
export HOST1=192.168.1.11
|
|
export HOST2=192.168.1.111
|
|
|
|
# Update NAME0, NAME1 and NAME2 with the hostnames of your hosts
|
|
export NAME0="server-1"
|
|
export NAME1="plex"
|
|
export NAME2="ssd-server-1"
|
|
|
|
# Create temp directories to store files that will end up on other hosts.
|
|
mkdir -p /tmp/${HOST0}/ /tmp/${HOST1}/ /tmp/${HOST2}/
|
|
|
|
HOSTS=(${HOST0} ${HOST1} ${HOST2})
|
|
NAMES=(${NAME0} ${NAME1} ${NAME2})
|
|
|
|
for i in "${!HOSTS[@]}"; do
|
|
HOST=${HOSTS[$i]}
|
|
NAME=${NAMES[$i]}
|
|
cat << EOF > /tmp/${HOST}/kubeadmcfg.yaml
|
|
---
|
|
apiVersion: "kubeadm.k8s.io/v1beta3"
|
|
kind: InitConfiguration
|
|
nodeRegistration:
|
|
name: ${NAME}
|
|
localAPIEndpoint:
|
|
advertiseAddress: ${HOST}
|
|
---
|
|
apiVersion: "kubeadm.k8s.io/v1beta3"
|
|
kind: ClusterConfiguration
|
|
etcd:
|
|
local:
|
|
serverCertSANs:
|
|
- "${HOST}"
|
|
peerCertSANs:
|
|
- "${HOST}"
|
|
extraArgs:
|
|
initial-cluster: ${NAMES[0]}=https://${HOSTS[0]}:2380,${NAMES[1]}=https://${HOSTS[1]}:2380,${NAMES[2]}=https://${HOSTS[2]}:2380
|
|
initial-cluster-state: new
|
|
name: ${NAME}
|
|
listen-peer-urls: https://${HOST}:2380
|
|
listen-client-urls: https://${HOST}:2379
|
|
advertise-client-urls: https://${HOST}:2379
|
|
initial-advertise-peer-urls: https://${HOST}:2380
|
|
EOF
|
|
done
|