mirror of
https://github.com/jbowdre/vsphere-k8s.git
synced 2024-11-24 17:02:17 +00:00
Compare commits
No commits in common. "2d14363967050033fbf067f718c4e2d076719411" and "87b627ebcb939c3ecc6def3f79b3688471428ec1" have entirely different histories.
2d14363967
...
87b627ebcb
4 changed files with 21 additions and 35 deletions
|
@ -79,7 +79,6 @@ resource "vsphere_virtual_machine" "control" {
|
|||
firmware = data.vsphere_virtual_machine.template.firmware
|
||||
hardware_version = data.vsphere_virtual_machine.template.hardware_version
|
||||
scsi_type = data.vsphere_virtual_machine.template.scsi_type
|
||||
wait_for_guest_net_timeout = 10
|
||||
|
||||
extra_config = {
|
||||
"disk.EnableUUID" = "TRUE"
|
||||
|
@ -164,7 +163,6 @@ resource "vsphere_virtual_machine" "worker" {
|
|||
firmware = data.vsphere_virtual_machine.template.firmware
|
||||
hardware_version = data.vsphere_virtual_machine.template.hardware_version
|
||||
scsi_type = data.vsphere_virtual_machine.template.scsi_type
|
||||
wait_for_guest_net_timeout = 10
|
||||
|
||||
network_interface {
|
||||
network_id = data.vsphere_network.network.id
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#!/bin/bash -eu
|
||||
source ./env.txt
|
||||
|
||||
if [ "${HOSTNAME}" == "${K8S_INITIAL_NODE}" ]; then
|
||||
if [ ! -f /etc/kubernetes/manifests/kube-vip.yaml ]; then
|
||||
if [ ! -f /etc/kubernetes/manifests/kube-vip.yaml ]; then
|
||||
echo ">> Configuring kube-vip..."
|
||||
sudo ctr image pull ghcr.io/kube-vip/kube-vip:"${KUBEVIP_VER}"
|
||||
sudo ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:"${KUBEVIP_VER}" vip /kube-vip manifest pod \
|
||||
|
@ -11,7 +10,9 @@ if [ "${HOSTNAME}" == "${K8S_INITIAL_NODE}" ]; then
|
|||
--controlplane \
|
||||
--arp \
|
||||
--leaderElection | sudo tee /etc/kubernetes/manifests/kube-vip.yaml
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${HOSTNAME}" == "${K8S_INITIAL_NODE}" ]; then
|
||||
if ! kubectl get nodes 2>/dev/null; then
|
||||
echo ">> Bootstrapping first controlplane node..."
|
||||
cat << EOF > kubeadminit.yaml
|
||||
|
@ -56,14 +57,14 @@ EOF
|
|||
|
||||
echo ">> Creating discovery config..."
|
||||
kubectl -n kube-public get configmap cluster-info -o jsonpath='{.data.kubeconfig}' > discovery.yaml
|
||||
sudo install -m 600 discovery.yaml /etc/kubernetes/discovery.yaml
|
||||
sudo install -o root -g root -m 600 discovery.yaml /etc/kubernetes/discovery.yaml
|
||||
else
|
||||
echo ">> [ERROR] Cluster initialization unsuccessful on ${HOSTNAME}! <<"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo ">> Waiting up to 10 minutes for all control-plane nodes to be Ready..."
|
||||
python3 -m http.server 2>/dev/null &
|
||||
python3 -m http.server &
|
||||
PROC_ID=$!
|
||||
attempts_max=60
|
||||
attempt=0
|
||||
|
@ -387,11 +388,8 @@ else
|
|||
attempt=0
|
||||
until [ -f /etc/kubernetes/discovery.yaml ]; do
|
||||
wget "http://${K8S_CONTROLPLANE_VIP}:8000/discovery.yaml" 2>/dev/null
|
||||
if ! sudo install -m 600 discovery.yaml /etc/kubernetes/discovery.yaml 2>/dev/null; then
|
||||
if [ ${attempt} -eq ${attempts_max} ]; then
|
||||
echo ">> [ERROR] Timeout waiting for discovery.yaml! <<"
|
||||
exit 1
|
||||
fi
|
||||
sudo install -o root -g root -m 600 discovery.yaml /etc/kubernetes/discovery.yaml 2>/dev/null
|
||||
if [ ! -f /etc/kubernetes/discovery.yaml ]; then
|
||||
attempt=$((attempt+1))
|
||||
sleep 10
|
||||
fi
|
||||
|
@ -411,17 +409,7 @@ nodeRegistration:
|
|||
controlPlane:
|
||||
certificateKey: ${KUBEADM_CERTKEY}
|
||||
EOF
|
||||
if sudo kubeadm join "${K8S_CONTROLPLANE_VIP}:6443" --config kubeadmjoin.yaml; then
|
||||
if [ ! -f /etc/kubernetes/manifests/kube-vip.yaml ]; then
|
||||
echo ">> Configuring kube-vip..."
|
||||
sudo ctr image pull ghcr.io/kube-vip/kube-vip:"${KUBEVIP_VER}"
|
||||
sudo ctr run --rm --net-host ghcr.io/kube-vip/kube-vip:"${KUBEVIP_VER}" vip /kube-vip manifest pod \
|
||||
--interface ens192 \
|
||||
--vip "${K8S_CONTROLPLANE_VIP}" \
|
||||
--controlplane \
|
||||
--arp \
|
||||
--leaderElection | sudo tee /etc/kubernetes/manifests/kube-vip.yaml
|
||||
fi
|
||||
if sudo kubeadm join "${K8S_CONTROLPLANE_VIP}":6443 --config kubeadmjoin.yaml; then
|
||||
echo ">> Node ${HOSTNAME} successfully initialized!"
|
||||
touch .k8s-node-success
|
||||
mkdir -p "${HOME}"/.kube
|
||||
|
|
|
@ -17,7 +17,7 @@ echo ">> Continuing after $((attempt*10)) seconds."
|
|||
echo ">> Waiting up to 10 minutes for all control-plane nodes..."
|
||||
attempts_max=60
|
||||
attempt=0
|
||||
until wget "http://${K8S_CONTROLPLANE_VIP}:8000/.k8s-controlplane-success" 2>/dev/null; do
|
||||
until "$(wget http://${K8S_CONTROLPLANE_VIP}:8000/.k8s-controlplane-success)" 2>/dev/null; do
|
||||
if [ ${attempt} -eq ${attempts_max} ]; then
|
||||
echo ">> [ERROR] Timeout waiting for control-plane nodes! <<"
|
||||
exit 1
|
||||
|
@ -31,7 +31,7 @@ attempts_max=6
|
|||
attempt=0
|
||||
until [ -f /etc/kubernetes/discovery.yaml ]; do
|
||||
wget "http://${K8S_CONTROLPLANE_VIP}:8000/discovery.yaml" 2>/dev/null
|
||||
sudo install -m 600 discovery.yaml /etc/kubernetes/discovery.yaml 2>/dev/null
|
||||
sudo install -o root -g root -m 600 discovery.yaml /etc/kubernetes/discovery.yaml 2>/dev/null
|
||||
if [ ! -f /etc/kubernetes/discovery.yaml ]; then
|
||||
attempt=$((attempt+1))
|
||||
sleep 10
|
||||
|
|
|
@ -20,15 +20,15 @@ vm-domain = "lab.local"
|
|||
# Control plane specs
|
||||
vm-control-count = "3"
|
||||
vm-control-cpu = "2"
|
||||
vm-control-ram = "4096"
|
||||
vm-control-ram = "2048"
|
||||
vm-control-disk-size = "30"
|
||||
vm-control-ip-address-start = "60"
|
||||
vm-control-name = "k8s-control"
|
||||
|
||||
# Worker specs
|
||||
vm-worker-count = "3"
|
||||
vm-worker-cpu = "4"
|
||||
vm-worker-ram = "8192"
|
||||
vm-worker-cpu = "1"
|
||||
vm-worker-ram = "1024"
|
||||
vm-worker-disk-size = "30"
|
||||
vm-worker-ip-address-start = "64"
|
||||
vm-worker-name = "k8s-worker"
|
||||
|
|
Loading…
Reference in a new issue