mirror of
https://github.com/jbowdre/vsphere-k8s.git
synced 2024-12-22 03:42:18 +00:00
merge fixes
This commit is contained in:
commit
b5bbc4e7a8
10 changed files with 85 additions and 91 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
DESCRIPTION:
|
||||
DESCRIPTION :
|
||||
Ubuntu Server 20.04 LTS Kubernetes node variables used by the Packer Plugin for VMware vSphere (vsphere-iso).
|
||||
*/
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/bin/bash -eu
|
||||
source ./env.txt
|
||||
|
||||
if [ ! -f /etc/kubernetes/manifests/kube-vip.yaml ]; then
|
||||
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 \
|
||||
|
@ -10,9 +11,7 @@ if [ ! -f /etc/kubernetes/manifests/kube-vip.yaml ]; then
|
|||
--controlplane \
|
||||
--arp \
|
||||
--leaderElection | sudo tee /etc/kubernetes/manifests/kube-vip.yaml
|
||||
fi
|
||||
|
||||
if [ "${HOSTNAME}" == "${K8S_INITIAL_NODE}" ]; then
|
||||
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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue