Skip to content

Commit

Permalink
feat: allow to specific vip interface
Browse files Browse the repository at this point in the history
  • Loading branch information
zifeo committed Sep 6, 2024
1 parent 8f02111 commit 4a494df
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
24 changes: 13 additions & 11 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ module "servers" {
keypair_name = openstack_compute_keypair_v2.key.name
ssh_authorized_keys = local.ssh_authorized_keys

network_id = openstack_networking_network_v2.net.id
subnet_id = openstack_networking_subnet_v2.servers.id
secgroup_id = openstack_networking_secgroup_v2.server.id
internal_vip = local.internal_vip
bastion_host = local.external_ip
san = distinct(concat([local.external_ip, local.internal_vip], var.additional_san))
network_id = openstack_networking_network_v2.net.id
subnet_id = openstack_networking_subnet_v2.servers.id
secgroup_id = openstack_networking_secgroup_v2.server.id
internal_vip = local.internal_vip
vip_interface = var.vip_interface
bastion_host = local.external_ip
san = distinct(concat([local.external_ip, local.internal_vip], var.additional_san))

manifests_folder = var.manifests_folder
manifests = merge(
Expand Down Expand Up @@ -200,11 +201,12 @@ module "agents" {
keypair_name = openstack_compute_keypair_v2.key.name
ssh_authorized_keys = local.ssh_authorized_keys

network_id = openstack_networking_network_v2.net.id
subnet_id = openstack_networking_subnet_v2.agents.id
secgroup_id = openstack_networking_secgroup_v2.agent.id
internal_vip = local.internal_vip
bastion_host = local.external_ip
network_id = openstack_networking_network_v2.net.id
subnet_id = openstack_networking_subnet_v2.agents.id
secgroup_id = openstack_networking_secgroup_v2.agent.id
internal_vip = local.internal_vip
vip_interface = var.vip_interface
bastion_host = local.external_ip

ff_autoremove_agent = var.ff_autoremove_agent
ff_wait_ready = var.ff_wait_ready
Expand Down
2 changes: 1 addition & 1 deletion node/cloud-init.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ write_files:
- name: port
value: "6443"
- name: vip_interface
value: ens3
value: "${vip_interface}"
- name: vip_cidr
value: "32"
- name: cp_enable
Expand Down
21 changes: 11 additions & 10 deletions node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,17 @@ resource "openstack_compute_instance_v2" "instance" {

# yamlencode(yamldecode to debug yaml
user_data = base64encode(templatefile("${path.module}/cloud-init.yaml.tpl", {
rke2_token = var.rke2_token
rke2_version = var.rke2_version
rke2_conf = var.rke2_config != null ? var.rke2_config : ""
rke2_device = var.rke2_volume_device
is_server = var.is_server
is_first = var.is_first && count.index == 0
bootstrap = var.bootstrap && var.is_first && count.index == 0
internal_vip = var.internal_vip
node_ip = openstack_networking_port_v2.port[count.index].all_fixed_ips[0]
san = var.is_server ? var.san : []
rke2_token = var.rke2_token
rke2_version = var.rke2_version
rke2_conf = var.rke2_config != null ? var.rke2_config : ""
rke2_device = var.rke2_volume_device
is_server = var.is_server
is_first = var.is_first && count.index == 0
bootstrap = var.bootstrap && var.is_first && count.index == 0
internal_vip = var.internal_vip
vip_interface = var.vip_interface
node_ip = openstack_networking_port_v2.port[count.index].all_fixed_ips[0]
san = var.is_server ? var.san : []
manifests_files = var.is_server ? merge(
var.manifests_folder != "" ? {
for f in fileset(var.manifests_folder, "*.{yml,yaml}") : f => base64gzip(file("${var.manifests_folder}/${f}"))
Expand Down
4 changes: 4 additions & 0 deletions node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ variable "internal_vip" {
default = ""
}

variable "vip_interface" {
type = string
}

variable "bastion_host" {
type = string
}
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ variable "subnet_lb_cidr" {
default = "192.168.44.0/24"
}

variable "vip_interface" {
type = string
default = "ens3"
}

variable "dns_nameservers4" {
type = list(string)
# Cloudflare
Expand Down

0 comments on commit 4a494df

Please sign in to comment.