Skip to content

Commit

Permalink
Enhancement: Add Support for extra settings and set sensible defaults (
Browse files Browse the repository at this point in the history
…#12)

* Add Support for vlan Tagging

* Added agent tag for faster ready

* fix: Add lifecycle ingnores to stop VM being destroyed due to minor changes

* fix: Add Support fox nameserver and proxy

* fix: export proxy vars

Co-authored-by: Frank <[email protected]>
  • Loading branch information
jamestutton and fvumbaca authored May 16, 2022
1 parent ca0248e commit 2fe9cc0
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 2 deletions.
14 changes: 14 additions & 0 deletions master_nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ resource "proxmox_vm_qemu" "k3s-master" {
sockets = local.master_node_settings.sockets
memory = local.master_node_settings.memory

agent = 1

disk {
type = local.master_node_settings.storage_type
storage = local.master_node_settings.storage_id
Expand All @@ -59,6 +61,14 @@ resource "proxmox_vm_qemu" "k3s-master" {
tag = local.master_node_settings.network_tag
}

lifecycle {
ignore_changes = [
ciuser,
sshkeys,
disk,
network
]
}

os_type = "cloud-init"

Expand All @@ -68,6 +78,8 @@ resource "proxmox_vm_qemu" "k3s-master" {

sshkeys = file(var.authorized_keys_file)

nameserver = var.nameserver

connection {
type = "ssh"
user = local.master_node_settings.user
Expand All @@ -89,6 +101,8 @@ resource "proxmox_vm_qemu" "k3s-master" {
user = "k3s"
password = random_password.k3s-master-db-password.result
}]

http_proxy = var.http_proxy
})
]
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/install-k3s-server.sh.tftpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export HTTP_PROXY="${http_proxy}"
export HTTPS_PROXY="${http_proxy}"
export http_proxy="${http_proxy}"
export https_proxy="${http_proxy}"

curl -sfL https://get.k3s.io | sh -s - ${mode} \
%{ for component in disable ~}
--disable ${component} \
Expand Down
9 changes: 7 additions & 2 deletions scripts/install-support-apps.sh.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ MARIADB_K3S_DATABASE="${k3s_database}"
MARIADB_K3S_USER="${k3s_user}"
MARIADB_K3S_PASSWORD="${k3s_password}"

export HTTP_PROXY="${http_proxy}"
export HTTPS_PROXY="${http_proxy}"
export http_proxy="${http_proxy}"
export https_proxy="${http_proxy}"

mariadb() {
sudo apt install mariadb-server -y
sudo -E apt install mariadb-server -y

# Make mariadb listen to all remote requests
sudo sed -i -e 's/\(bind-address\s*=\s*\)[0-9.]*/\10.0.0.0/g' /etc/mysql/mariadb.conf.d/50-server.cnf
Expand All @@ -28,7 +33,7 @@ mariadb() {
}

nginx() {
sudo apt install nginx -y
sudo -E apt install nginx -y
}

mariadb
Expand Down
18 changes: 18 additions & 0 deletions support_node.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ locals {
user = "support"
network_tag = -1



db_name = "k3s"
db_user = "k3s"



network_bridge = "vmbr0"
})

Expand All @@ -40,6 +44,8 @@ resource "proxmox_vm_qemu" "k3s-support" {
sockets = local.support_node_settings.sockets
memory = local.support_node_settings.memory


agent = 1
disk {
type = local.support_node_settings.storage_type
storage = local.support_node_settings.storage_id
Expand All @@ -57,6 +63,14 @@ resource "proxmox_vm_qemu" "k3s-support" {
tag = local.support_node_settings.network_tag
}

lifecycle {
ignore_changes = [
ciuser,
sshkeys,
disk,
network
]
}

os_type = "cloud-init"

Expand All @@ -66,6 +80,8 @@ resource "proxmox_vm_qemu" "k3s-support" {

sshkeys = file(var.authorized_keys_file)

nameserver = var.nameserver

connection {
type = "ssh"
user = local.support_node_settings.user
Expand All @@ -80,6 +96,8 @@ resource "proxmox_vm_qemu" "k3s-support" {
k3s_database = local.support_node_settings.db_name
k3s_user = local.support_node_settings.db_user
k3s_password = random_password.k3s-master-db-password.result

http_proxy = var.http_proxy
})
}

Expand Down
13 changes: 13 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,16 @@ variable "k3s_disable_components" {
type = list(string)
default = []
}


variable "http_proxy" {
default = ""
type = string
description = "http_proxy"
}

variable "nameserver" {
default = ""
type = string
description = "nameserver"
}
15 changes: 15 additions & 0 deletions worker_nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ resource "proxmox_vm_qemu" "k3s-worker" {
sockets = each.value.sockets
memory = each.value.memory

agent = 1

disk {
type = each.value.storage_type
storage = each.value.storage_id
Expand All @@ -69,6 +71,15 @@ resource "proxmox_vm_qemu" "k3s-worker" {
tag = each.value.network_tag
}

lifecycle {
ignore_changes = [
ciuser,
sshkeys,
disk,
network
]
}

os_type = "cloud-init"

ciuser = each.value.user
Expand All @@ -77,6 +88,8 @@ resource "proxmox_vm_qemu" "k3s-worker" {

sshkeys = file(var.authorized_keys_file)

nameserver = var.nameserver

connection {
type = "ssh"
user = each.value.user
Expand All @@ -93,6 +106,8 @@ resource "proxmox_vm_qemu" "k3s-worker" {
server_hosts = ["https://${local.support_node_ip}:6443"]
node_taints = each.value.taints
datastores = []

http_proxy = var.http_proxy
})
]
}
Expand Down

0 comments on commit 2fe9cc0

Please sign in to comment.