All checks were successful
continuous-integration/drone/push Build is passing
- Upgrading to Terraform from 1.1.8 to 1.3.5 - Upgrading to Kubernetes from 1.23.5 to 1.25.4 - Using Q35 machine for workers - Using UEFI for boot - Refactored XSLT
87 lines
2.3 KiB
HCL
87 lines
2.3 KiB
HCL
locals {
|
|
pool_name = "kubernetes-workers"
|
|
worker_id_start = 80
|
|
worker_count = 2
|
|
}
|
|
|
|
resource "libvirt_pool" "kubernetes_workers" {
|
|
name = "kubernetes-workers"
|
|
type = "dir"
|
|
path = "/vmstore/kubernetes-workers"
|
|
}
|
|
|
|
data "template_cloudinit_config" "worker" {
|
|
count = local.worker_count
|
|
|
|
gzip = false
|
|
base64_encode = false
|
|
|
|
part {
|
|
filename = "init.cfg"
|
|
content_type = "text/cloud-config"
|
|
content = yamlencode({
|
|
ssh_authorized_keys = [
|
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCp7+2y7Y8jOUM2TXFbuKWMmwguNsCoFxE6JUg4VPbGTsX0FA3UTi1AB5TzL7tEPt6/j7MolSIvtupXFrH2pNdOuHXZL0LsR8EQ5uLA2oDRJX3xiyHrgBAXtEjAWkVus1DjUz19vRw/81GGnPucr4WIR4vSc+H0DFLgjJKn/MsMf/Z8DnCwEbguO2qlDPH8ToQQZC2k6BLwEHVpWigKE6MisV9i9GhFFJG9nbcHPq/Vf5fJhIHG+LGD3AgMeEZF9QE2pNbMOJ4lRP2lo16KpxYJCx5shdFqE3kiV/hLXVkDhSDK+p4pw1uuGEz7dFz5Fa1CMIa8iARKMzcYejs0AqqD"
|
|
]
|
|
write_files = [
|
|
{
|
|
path = "/var/lib/kubernetes/ca.pem"
|
|
content = local.kubernetes_ca
|
|
},
|
|
{
|
|
path = "/var/lib/kubelet/bootstrap-kubeconfig"
|
|
encoding = "gzip+base64"
|
|
content = base64gzip(local.bootstrap_kubeconfig)
|
|
},
|
|
{
|
|
path = "/var/lib/kubelet/kubelet-config.yaml"
|
|
content = local.kubelet_config
|
|
}
|
|
]
|
|
mounts = [
|
|
["datastore", "/mnt/datastore", "9p", "trans=virtio,version=9p2000.L,rw,dirsync,cache=mmap"]
|
|
]
|
|
})
|
|
}
|
|
}
|
|
|
|
module "worker" {
|
|
source = "git@git.thomasklein.me:thomasklein/terraform-modules//lawndale-vm"
|
|
|
|
count = local.worker_count
|
|
uefi = true
|
|
machine = "q35"
|
|
|
|
name = "k8s-worker-${count.index}"
|
|
id = local.worker_id_start + count.index
|
|
|
|
description = "Kubernetes worker (${count.index})"
|
|
|
|
vcpu = 6
|
|
memory_mb = 12 * 1024
|
|
interface = "nat"
|
|
|
|
create_root_storage_pool = false
|
|
root_storage_pool = local.pool_name
|
|
root_storage_volume_size_gb = 16
|
|
|
|
base_image_pool = "base-images"
|
|
base_image_volume = "ubuntu-jammy-20221127-k8s-v1.25.4-20221127"
|
|
|
|
filesystems = [
|
|
{
|
|
source = "/mnt/datastore/k8s"
|
|
target = "datastore"
|
|
readonly = false
|
|
accessmode = "mapped"
|
|
}
|
|
]
|
|
|
|
depends_on = [libvirt_pool.kubernetes_workers]
|
|
|
|
user_data = data.template_cloudinit_config.worker[count.index].rendered
|
|
|
|
|
|
xslt = file("${path.module}/fixing-worker-domaindefs.xsl")
|
|
}
|