mirror of
https://github.com/jbowdre/vsphere-k8s.git
synced 2024-11-21 23:52:18 +00:00
Compare commits
3 commits
beb7a2feca
...
0a699fb499
Author | SHA1 | Date | |
---|---|---|---|
0a699fb499 | |||
1e1d3e4b1a | |||
b93e07740d |
4 changed files with 48 additions and 38 deletions
|
@ -20,7 +20,6 @@ vsphere_folder = "_Templates"
|
||||||
vm_guest_os_language = "en_US"
|
vm_guest_os_language = "en_US"
|
||||||
vm_guest_os_keyboard = "us"
|
vm_guest_os_keyboard = "us"
|
||||||
vm_guest_os_timezone = "America/Chicago"
|
vm_guest_os_timezone = "America/Chicago"
|
||||||
vm_guest_os_family = "linux"
|
|
||||||
vm_guest_os_type = "ubuntu64Guest"
|
vm_guest_os_type = "ubuntu64Guest"
|
||||||
|
|
||||||
// Virtual Machine Hardware Settings
|
// Virtual Machine Hardware Settings
|
||||||
|
@ -104,4 +103,4 @@ pre_final_scripts = [
|
||||||
]
|
]
|
||||||
|
|
||||||
// Kubernetes Settings
|
// Kubernetes Settings
|
||||||
k8s_version = "1.25.3"
|
k8s_version = "1.25.3"
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
variable "vsphere_endpoint" {
|
variable "vsphere_endpoint" {
|
||||||
type = string
|
type = string
|
||||||
description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')"
|
description = "The fully qualified domain name or IP address of the vCenter Server instance. ('vcenter.lab.local')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vsphere_username" {
|
variable "vsphere_username" {
|
||||||
type = string
|
type = string
|
||||||
description = "The username to login to the vCenter Server instance. (e.g. 'svc-packer-vsphere@rainpole.io')"
|
description = "The username to login to the vCenter Server instance. ('packer')"
|
||||||
sensitive = true
|
sensitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,27 +35,27 @@ variable "vsphere_insecure_connection" {
|
||||||
|
|
||||||
variable "vsphere_datacenter" {
|
variable "vsphere_datacenter" {
|
||||||
type = string
|
type = string
|
||||||
description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')"
|
description = "The name of the target vSphere datacenter. ('Lab Datacenter')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vsphere_cluster" {
|
variable "vsphere_cluster" {
|
||||||
type = string
|
type = string
|
||||||
description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')"
|
description = "The name of the target vSphere cluster. ('cluster-01')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vsphere_datastore" {
|
variable "vsphere_datastore" {
|
||||||
type = string
|
type = string
|
||||||
description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')"
|
description = "The name of the target vSphere datastore. ('datastore-01')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vsphere_network" {
|
variable "vsphere_network" {
|
||||||
type = string
|
type = string
|
||||||
description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')"
|
description = "The name of the target vSphere network. ('network-192.168.1.0')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vsphere_folder" {
|
variable "vsphere_folder" {
|
||||||
type = string
|
type = string
|
||||||
description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')"
|
description = "The name of the target vSphere folder. ('_Templates')"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Virtual Machine Settings
|
// Virtual Machine Settings
|
||||||
|
@ -83,36 +83,31 @@ variable "vm_guest_os_timezone" {
|
||||||
default = "UTC"
|
default = "UTC"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vm_guest_os_family" {
|
|
||||||
type = string
|
|
||||||
description = "The guest operating system family. Used for naming. (e.g. 'linux')"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "vm_guest_os_type" {
|
variable "vm_guest_os_type" {
|
||||||
type = string
|
type = string
|
||||||
description = "The guest operating system type, also know as guestid. (e.g. 'ubuntu64Guest')"
|
description = "The guest operating system type. ('ubuntu64Guest')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vm_firmware" {
|
variable "vm_firmware" {
|
||||||
type = string
|
type = string
|
||||||
description = "The virtual machine firmware. (e.g. 'efi-secure'. 'efi', or 'bios')"
|
description = "The virtual machine firmware. ('efi-secure'. 'efi', or 'bios')"
|
||||||
default = "efi-secure"
|
default = "efi-secure"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vm_cdrom_type" {
|
variable "vm_cdrom_type" {
|
||||||
type = string
|
type = string
|
||||||
description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')"
|
description = "The virtual machine CD-ROM type. ('sata', or 'ide')"
|
||||||
default = "sata"
|
default = "sata"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vm_cpu_count" {
|
variable "vm_cpu_count" {
|
||||||
type = number
|
type = number
|
||||||
description = "The number of virtual CPUs. (e.g. '2')"
|
description = "The number of virtual CPUs. ('2')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vm_cpu_cores" {
|
variable "vm_cpu_cores" {
|
||||||
type = number
|
type = number
|
||||||
description = "The number of virtual CPUs cores per socket. (e.g. '1')"
|
description = "The number of virtual CPUs cores per socket. ('1')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vm_cpu_hot_add" {
|
variable "vm_cpu_hot_add" {
|
||||||
|
@ -123,7 +118,7 @@ variable "vm_cpu_hot_add" {
|
||||||
|
|
||||||
variable "vm_mem_size" {
|
variable "vm_mem_size" {
|
||||||
type = number
|
type = number
|
||||||
description = "The size for the virtual memory in MB. (e.g. '2048')"
|
description = "The size for the virtual memory in MB. ('2048')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vm_mem_hot_add" {
|
variable "vm_mem_hot_add" {
|
||||||
|
@ -134,13 +129,13 @@ variable "vm_mem_hot_add" {
|
||||||
|
|
||||||
variable "vm_disk_size" {
|
variable "vm_disk_size" {
|
||||||
type = number
|
type = number
|
||||||
description = "The size for the virtual disk in MB. (e.g. '61440' = 60GB)"
|
description = "The size for the virtual disk in MB. ('61440' = 60GB)"
|
||||||
default = 61440
|
default = 61440
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "vm_disk_controller_type" {
|
variable "vm_disk_controller_type" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')"
|
description = "The virtual disk controller types in sequence. ('pvscsi')"
|
||||||
default = ["pvscsi"]
|
default = ["pvscsi"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +153,7 @@ variable "vm_disk_eagerly_scrub" {
|
||||||
|
|
||||||
variable "vm_network_card" {
|
variable "vm_network_card" {
|
||||||
type = string
|
type = string
|
||||||
description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')"
|
description = "The virtual network card type. ('vmxnet3' or 'e1000e')"
|
||||||
default = "vmxnet3"
|
default = "vmxnet3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +184,7 @@ variable "common_template_conversion" {
|
||||||
|
|
||||||
variable "common_content_library_name" {
|
variable "common_content_library_name" {
|
||||||
type = string
|
type = string
|
||||||
description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')"
|
description = "The name of the target vSphere content library, if used. ('Lab-CL')"
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,27 +243,27 @@ variable "common_ovf_export_path" {
|
||||||
|
|
||||||
variable "common_iso_datastore" {
|
variable "common_iso_datastore" {
|
||||||
type = string
|
type = string
|
||||||
description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')"
|
description = "The name of the source vSphere datastore for ISO images. ('datastore-iso-01')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "iso_url" {
|
variable "iso_url" {
|
||||||
type = string
|
type = string
|
||||||
description = "The URL source of the ISO image. (e.g. 'https://artifactory.rainpole.io/.../os.iso')"
|
description = "The URL source of the ISO image. ('https://releases.ubuntu.com/20.04.5/ubuntu-20.04.5-live-server-amd64.iso')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "iso_path" {
|
variable "iso_path" {
|
||||||
type = string
|
type = string
|
||||||
description = "The path on the source vSphere datastore for ISO image. (e.g. 'iso/linux/ubuntu')"
|
description = "The path on the source vSphere datastore for ISO image. ('ISOs/Linux')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "iso_file" {
|
variable "iso_file" {
|
||||||
type = string
|
type = string
|
||||||
description = "The file name of the ISO image used by the vendor. (e.g. 'ubuntu-<version>-live-server-amd64.iso')"
|
description = "The file name of the ISO image used by the vendor. ('ubuntu-20.04.5-live-server-amd64.iso')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "iso_checksum_type" {
|
variable "iso_checksum_type" {
|
||||||
type = string
|
type = string
|
||||||
description = "The checksum algorithm used by the vendor. (e.g. 'sha256')"
|
description = "The checksum algorithm used by the vendor. ('sha256')"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "iso_checksum_value" {
|
variable "iso_checksum_value" {
|
||||||
|
@ -286,7 +281,7 @@ variable "cd_label" {
|
||||||
|
|
||||||
variable "vm_boot_order" {
|
variable "vm_boot_order" {
|
||||||
type = string
|
type = string
|
||||||
description = "The boot order for virtual machines devices. (e.g. 'disk,cdrom')"
|
description = "The boot order for virtual machines devices. ('disk,cdrom')"
|
||||||
default = "disk,cdrom"
|
default = "disk,cdrom"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +316,7 @@ variable "common_shutdown_timeout" {
|
||||||
|
|
||||||
variable "build_username" {
|
variable "build_username" {
|
||||||
type = string
|
type = string
|
||||||
description = "The username to login to the guest operating system. (e.g. 'rainpole')"
|
description = "The username to login to the guest operating system. ('admin')"
|
||||||
sensitive = true
|
sensitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,18 +63,34 @@ EOF
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo ">> Waiting up to 15 minutes for all nodes to be Ready..."
|
echo ">> Waiting up to 10 minutes for all control-plane nodes to be Ready..."
|
||||||
attempts_max=90
|
python3 -m http.server &
|
||||||
|
PROC_ID=$!
|
||||||
|
attempts_max=60
|
||||||
attempt=0
|
attempt=0
|
||||||
until [ "$(kubectl get nodes | grep -c ' Ready ')" == "${K8S_NODE_COUNT}" ]; do
|
until [ "$(kubectl get nodes | grep -c ' control-plane ')" -eq "${K8S_CONTROLPLANE_COUNT}" ]; do
|
||||||
if [ ${attempt} -eq ${attempts_max} ]; then
|
if [ ${attempt} -eq ${attempts_max} ]; then
|
||||||
echo ">> [ERROR] Timeout waiting for cluster online! <<"
|
echo ">> [ERROR] Timeout waiting for control-plane nodes to join! <<"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
attempt=$((attempt+1))
|
attempt=$((attempt+1))
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
echo ">> Continuing after $((attempt*10)) seconds."
|
echo ">> Continuing after $((attempt*10)) seconds."
|
||||||
|
touch .k8s-controlplane-success
|
||||||
|
echo ">> Waiting up to 10 minutes for all worker nodes to be Ready..."
|
||||||
|
attempts_max=60
|
||||||
|
attempt=0
|
||||||
|
until [ "$(kubectl get nodes | grep -c ' Ready ')" == "${K8S_NODE_COUNT}" ]; do
|
||||||
|
if [ ${attempt} -eq ${attempts_max} ]; then
|
||||||
|
echo ">> [ERROR] Timeout waiting for worker nodes to join! <<"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
attempt=$((attempt+1))
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
kill $PROC_ID
|
||||||
|
echo ">> Continuing after $((attempt*10)) seconds."
|
||||||
echo ">> Configuring vSphere Cloud Provider Interface..."
|
echo ">> Configuring vSphere Cloud Provider Interface..."
|
||||||
cat << EOF | kubectl apply -f -
|
cat << EOF | kubectl apply -f -
|
||||||
# https://raw.githubusercontent.com/kubernetes/cloud-provider-vsphere/release-1.25/releases/v1.25/vsphere-cloud-controller-manager.yaml
|
# https://raw.githubusercontent.com/kubernetes/cloud-provider-vsphere/release-1.25/releases/v1.25/vsphere-cloud-controller-manager.yaml
|
||||||
|
@ -371,7 +387,7 @@ else
|
||||||
attempts_max=6
|
attempts_max=6
|
||||||
attempt=0
|
attempt=0
|
||||||
until [ -f /etc/kubernetes/discovery.yaml ]; do
|
until [ -f /etc/kubernetes/discovery.yaml ]; do
|
||||||
scp -o StrictHostKeyChecking=no "${K8S_CONTROLPLANE_VIP}":discovery.yaml . 2>/dev/null
|
wget "http://${K8S_CONTROLPLANE_VIP}:8000/discovery.yaml" 2>/dev/null
|
||||||
sudo install -o root -g root -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
|
if [ ! -f /etc/kubernetes/discovery.yaml ]; then
|
||||||
attempt=$((attempt+1))
|
attempt=$((attempt+1))
|
||||||
|
|
|
@ -17,7 +17,7 @@ echo ">> Continuing after $((attempt*10)) seconds."
|
||||||
echo ">> Waiting up to 10 minutes for all control-plane nodes..."
|
echo ">> Waiting up to 10 minutes for all control-plane nodes..."
|
||||||
attempts_max=60
|
attempts_max=60
|
||||||
attempt=0
|
attempt=0
|
||||||
until [ "$(ssh -o StrictHostKeyChecking=no "${K8S_CONTROLPLANE_VIP}" kubectl get nodes | grep -c " control-plane ")" -eq "${K8S_CONTROLPLANE_COUNT}" ]; do
|
until "$(wget http://${K8S_CONTROLPLANE_VIP}:8000/.k8s-controlplane-success)" 2>/dev/null; do
|
||||||
if [ ${attempt} -eq ${attempts_max} ]; then
|
if [ ${attempt} -eq ${attempts_max} ]; then
|
||||||
echo ">> [ERROR] Timeout waiting for control-plane nodes! <<"
|
echo ">> [ERROR] Timeout waiting for control-plane nodes! <<"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -30,7 +30,7 @@ echo ">> Joining cluster..."
|
||||||
attempts_max=6
|
attempts_max=6
|
||||||
attempt=0
|
attempt=0
|
||||||
until [ -f /etc/kubernetes/discovery.yaml ]; do
|
until [ -f /etc/kubernetes/discovery.yaml ]; do
|
||||||
scp -o StrictHostKeyChecking=no "${K8S_CONTROLPLANE_VIP}":discovery.yaml . 2>/dev/null
|
wget "http://${K8S_CONTROLPLANE_VIP}:8000/discovery.yaml" 2>/dev/null
|
||||||
sudo install -o root -g root -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
|
if [ ! -f /etc/kubernetes/discovery.yaml ]; then
|
||||||
attempt=$((attempt+1))
|
attempt=$((attempt+1))
|
||||||
|
|
Loading…
Reference in a new issue