merge fixes

This commit is contained in:
John Bowdre 2023-04-19 14:14:40 -05:00
commit b5bbc4e7a8
10 changed files with 85 additions and 91 deletions

View File

@ -178,7 +178,6 @@ autoinstall:
hostname: ${ vm_guest_os_hostname }
users:
- name: ${ build_username }
passwd: "${ build_password }"
groups: [adm, cdrom, dip, plugdev, lxd, sudo]
lock-passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL

View File

@ -1,4 +1,8 @@
#!/bin/bash -eu
echo '>> Enabling legacy VMware Guest Customization...'
echo 'disable_vmware_customization: true' | sudo tee -a /etc/cloud/cloud.cfg
if grep -q 'disable_vmware_customization' /etc/cloud/cloud.cfg; then
sudo sed -i 's/^disable_vmware_customization:.*$/disable_vmware_customization: True/' /etc/cloud/cloud.cfg
else
echo 'disable_vmware_customization: true' | sudo tee -a /etc/cloud/cloud.cfg
fi
sudo vmware-toolbox-cmd config set deployPkg enable-custom-scripts true

View File

@ -2,10 +2,10 @@
# Prepare a VM to become a template.
echo '>> Clearing audit logs...'
sudo sh -c 'if [ -f /var/log/audit/audit.log ]; then
cat /dev/null > /var/log/audit/audit.log
sudo sh -c 'if [ -f /var/log/audit/audit.log ]; then
cat /dev/null > /var/log/audit/audit.log
fi'
sudo sh -c 'if [ -f /var/log/wtmp ]; then
sudo sh -c 'if [ -f /var/log/wtmp ]; then
cat /dev/null > /var/log/wtmp
fi'
sudo sh -c 'if [ -f /var/log/lastlog ]; then
@ -31,7 +31,7 @@ echo '>> Clearing host keys...'
sudo rm -f /etc/ssh/ssh_host_*
echo '>> Removing Packer SSH key...'
sed -i '/packer_temp_key/d' ~/.ssh/authorized_keys
sed -i '/packer_key/d' ~/.ssh/authorized_keys
echo '>> Clearing machine-id...'
sudo truncate -s 0 /etc/machine-id

View File

@ -1,3 +1,7 @@
#!/bin/sh -eu
echo '>> Preserving network settings...'
echo 'manual_cache_clean: True' | sudo tee -a /etc/cloud/cloud.cfg
if grep -q 'manual_cache_clean' /etc/cloud/cloud.cfg; then
sudo sed -i 's/^manual_cache_clean.*$/manual_cache_clean: True/' /etc/cloud/cloud.cfg
else
echo 'manual_cache_clean: True' | sudo tee -a /etc/cloud/cloud.cfg
fi

View File

@ -1,67 +1,67 @@
/*
DESCRIPTION:
DESCRIPTION :
Ubuntu Server 20.04 LTS Kubernetes node variables used by the Packer Plugin for VMware vSphere (vsphere-iso).
*/
// vSphere Credentials
vsphere_endpoint = "vcenter.lab.local"
vsphere_username = "packer"
vsphere_password = "VMware1!"
vsphere_insecure_connection = true
vsphere_endpoint = "vcenter.lab.local"
vsphere_username = "packer"
vsphere_password = "VMware1!"
vsphere_insecure_connection = true
// vSphere Settings
vsphere_datacenter = "Datacenter 01"
vsphere_cluster = "cluster-01"
vsphere_datastore = "datastore-01"
vsphere_network = "network-01"
vsphere_folder = "_Templates"
vsphere_datacenter = "Datacenter 01"
vsphere_cluster = "cluster-01"
vsphere_datastore = "datastore-01"
vsphere_network = "network-01"
vsphere_folder = "_Templates"
// Guest Operating System Settings
vm_guest_os_language = "en_US"
vm_guest_os_keyboard = "us"
vm_guest_os_timezone = "America/Chicago"
vm_guest_os_type = "ubuntu64Guest"
vm_guest_os_language = "en_US"
vm_guest_os_keyboard = "us"
vm_guest_os_timezone = "America/Chicago"
vm_guest_os_type = "ubuntu64Guest"
// Virtual Machine Hardware Settings
vm_name = "k8s-u2004"
vm_firmware = "efi-secure"
vm_cdrom_type = "sata"
vm_cpu_count = 2
vm_cpu_cores = 1
vm_cpu_hot_add = true
vm_mem_size = 2048
vm_mem_hot_add = true
vm_disk_size = 30720
vm_disk_controller_type = ["pvscsi"]
vm_disk_thin_provisioned = true
vm_network_card = "vmxnet3"
common_vm_version = 19
common_tools_upgrade_policy = true
common_remove_cdrom = true
vm_name = "k8s-u2004"
vm_firmware = "efi-secure"
vm_cdrom_type = "sata"
vm_cpu_count = 2
vm_cpu_cores = 1
vm_cpu_hot_add = true
vm_mem_size = 2048
vm_mem_hot_add = true
vm_disk_size = 30720
vm_disk_controller_type = ["pvscsi"]
vm_disk_thin_provisioned = true
vm_network_card = "vmxnet3"
common_vm_version = 19
common_tools_upgrade_policy = true
common_remove_cdrom = true
// Template and Content Library Settings
common_template_conversion = true
common_content_library_name = null
common_content_library_ovf = false
common_content_library_destroy = true
common_content_library_skip_export = true
common_template_conversion = true
common_content_library_name = null
common_content_library_ovf = false
common_content_library_destroy = true
common_content_library_skip_export = true
// OVF Export Settings
common_ovf_export_enabled = false
common_ovf_export_overwrite = true
common_ovf_export_path = ""
common_ovf_export_enabled = false
common_ovf_export_overwrite = true
common_ovf_export_path = ""
// Removable Media Settings
common_iso_datastore = "datastore-01"
iso_url = null
iso_path = "_ISO"
iso_file = "ubuntu-20.04.5-live-server-amd64.iso"
iso_checksum_type = "sha256"
iso_checksum_value = "5035be37a7e9abbdc09f0d257f3e33416c1a0fb322ba860d42d74aa75c3468d4"
common_iso_datastore = "datastore-01"
iso_url = null
iso_path = "_ISO"
iso_file = "ubuntu-20.04.5-live-server-amd64.iso"
iso_checksum_type = "sha256"
iso_checksum_value = "5035be37a7e9abbdc09f0d257f3e33416c1a0fb322ba860d42d74aa75c3468d4"
// Boot Settings
vm_boot_order = "disk,cdrom"
vm_boot_wait = "4s"
vm_boot_order = "disk,cdrom"
vm_boot_wait = "4s"
vm_boot_command = [
"<esc><wait>",
"linux /casper/vmlinuz --- autoinstall ds=\"nocloud\"",
@ -73,14 +73,14 @@ vm_boot_command = [
]
// Communicator Settings
communicator_port = 22
communicator_timeout = "20m"
common_ip_wait_timeout = "20m"
common_shutdown_timeout = "15m"
build_remove_keys = true
build_username = "admin"
build_password = "VMware1!"
ssh_keys = [
communicator_port = 22
communicator_timeout = "20m"
common_ip_wait_timeout = "20m"
common_shutdown_timeout = "15m"
build_remove_keys = true
build_username = "admin"
build_password = "VMware1!"
ssh_keys = [
"ssh-ed25519 blahblahblah builder"
]
@ -105,4 +105,4 @@ pre_final_scripts = [
]
// Kubernetes Settings
k8s_version = "1.25.3"
k8s_version = "1.25.3"

View File

@ -41,7 +41,6 @@ locals {
"/meta-data" = file("data/meta-data")
"/user-data" = templatefile("data/user-data.pkrtpl.hcl", {
build_username = var.build_username
build_password = bcrypt(var.build_password)
ssh_keys = concat([local.ssh_public_key], var.ssh_keys)
vm_guest_os_language = var.vm_guest_os_language
vm_guest_os_keyboard = var.vm_guest_os_keyboard
@ -108,7 +107,7 @@ source "vsphere-iso" "ubuntu-k8s" {
boot_wait = var.vm_boot_wait
boot_command = var.vm_boot_command
ip_wait_timeout = var.common_ip_wait_timeout
shutdown_command = local.shutdown_command
shutdown_command = var.vm_shutdown_command
shutdown_timeout = var.common_shutdown_timeout
// Communicator Settings and Credentials

View File

@ -7,7 +7,6 @@
// Defines the input variables.
// vSphere Credentials
variable "vsphere_endpoint" {
type = string
description = "The fully qualified domain name or IP address of the vCenter Server instance. ('vcenter.lab.local')"
@ -16,7 +15,6 @@ variable "vsphere_endpoint" {
variable "vsphere_username" {
type = string
description = "The username to login to the vCenter Server instance. ('packer')"
sensitive = true
}
variable "vsphere_password" {
@ -32,7 +30,6 @@ variable "vsphere_insecure_connection" {
}
// vSphere Settings
variable "vsphere_datacenter" {
type = string
description = "The name of the target vSphere datacenter. ('Lab Datacenter')"
@ -59,7 +56,6 @@ variable "vsphere_folder" {
}
// Virtual Machine Settings
variable "vm_name" {
type = string
description = "Name of the new VM to create."
@ -175,7 +171,6 @@ variable "common_remove_cdrom" {
}
// Template and Content Library Settings
variable "common_template_conversion" {
type = bool
description = "Convert the virtual machine to template. Must be 'false' for content library."
@ -207,7 +202,6 @@ variable "common_content_library_skip_export" {
}
// Snapshot Settings
variable "common_snapshot_creation" {
type = bool
description = "Create a snapshot for Linked Clones."
@ -221,7 +215,6 @@ variable "common_snapshot_name" {
}
// OVF Export Settings
variable "common_ovf_export_enabled" {
type = bool
description = "Enable OVF artifact export."
@ -240,7 +233,6 @@ variable "common_ovf_export_path" {
}
// Removable Media Settings
variable "common_iso_datastore" {
type = string
description = "The name of the source vSphere datastore for ISO images. ('datastore-iso-01')"
@ -278,7 +270,6 @@ variable "cd_label" {
}
// Boot Settings
variable "vm_boot_order" {
type = string
description = "The boot order for virtual machines devices. ('disk,cdrom')"
@ -313,7 +304,6 @@ variable "common_shutdown_timeout" {
}
// Communicator Settings and Credentials
variable "build_username" {
type = string
description = "The username to login to the guest operating system. ('admin')"
@ -346,7 +336,6 @@ variable "build_remove_keys" {
}
// Communicator Settings
variable "communicator_port" {
type = string
description = "The port for the communicator protocol."
@ -370,7 +359,6 @@ variable "communicator_ssl" {
}
// Provisioner Settings
variable "cloud_init_apt_packages" {
type = list(string)
description = "A list of apt packages to install during the subiquity cloud-init installer."
@ -396,7 +384,6 @@ variable "pre_final_scripts" {
}
// Kubernetes Settings
variable "k8s_version" {
type = string
description = "Kubernetes version to be installed. Latest stable is listed at https://dl.k8s.io/release/stable.txt"

View File

@ -79,6 +79,7 @@ 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"
@ -163,6 +164,7 @@ 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

View File

@ -1,18 +1,17 @@
#!/bin/bash -eu
source ./env.txt
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 [ "${HOSTNAME}" == "${K8S_INITIAL_NODE}" ]; 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 ! kubectl get nodes 2>/dev/null; then
echo ">> Bootstrapping first controlplane node..."
cat << EOF > kubeadminit.yaml
@ -57,7 +56,7 @@ EOF
echo ">> Creating discovery config..."
kubectl -n kube-public get configmap cluster-info -o jsonpath='{.data.kubeconfig}' > discovery.yaml
sudo install -o root -g root -m 600 discovery.yaml /etc/kubernetes/discovery.yaml
sudo install -m 600 discovery.yaml /etc/kubernetes/discovery.yaml
else
echo ">> [ERROR] Cluster initialization unsuccessful on ${HOSTNAME}! <<"
exit 1

View File

@ -20,15 +20,15 @@ vm-domain = "lab.local"
# Control plane specs
vm-control-count = "3"
vm-control-cpu = "2"
vm-control-ram = "2048"
vm-control-ram = "4096"
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 = "1"
vm-worker-ram = "1024"
vm-worker-cpu = "4"
vm-worker-ram = "8192"
vm-worker-disk-size = "30"
vm-worker-ip-address-start = "64"
vm-worker-name = "k8s-worker"