Move declaration of primary IPs into kubernetes-module
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
resource "hcloud_primary_ip" "ipv4" {
|
||||
count = length(var.servers)
|
||||
|
||||
name = "k8s_primary_ipv4_${count.index}"
|
||||
datacenter = var.servers[count.index].ip_datacenter
|
||||
type = "ipv4"
|
||||
assignee_type = "server"
|
||||
auto_delete = var.auto_delete_primary_ips
|
||||
}
|
||||
|
||||
resource "hcloud_primary_ip" "ipv6" {
|
||||
count = length(var.servers)
|
||||
|
||||
name = "k8s_primary_ipv6_${count.index}"
|
||||
datacenter = var.servers[count.index].ip_datacenter
|
||||
type = "ipv6"
|
||||
assignee_type = "server"
|
||||
auto_delete = var.auto_delete_primary_ips
|
||||
}
|
||||
|
||||
locals {
|
||||
network = "10.0.0.0/16"
|
||||
subnet_eu_central = "10.0.0.0/24"
|
||||
@@ -5,6 +25,8 @@ locals {
|
||||
for idx, config in var.servers : "${var.name}-server-${idx + 1}" => merge(
|
||||
config,
|
||||
{
|
||||
ipv4_id = hcloud_primary_ip.ipv4[idx].id
|
||||
ipv6_id = hcloud_primary_ip.ipv6[idx].id
|
||||
ip = cidrhost(local.subnet_eu_central, idx + 2)
|
||||
first_ip = idx == 0 ? "" : cidrhost(local.subnet_eu_central, 2)
|
||||
}
|
||||
|
||||
@@ -8,10 +8,9 @@ variable "ssh_keys" {
|
||||
|
||||
variable "servers" {
|
||||
type = list(object({
|
||||
ipv4_id = number
|
||||
ipv6_id = number
|
||||
type = string
|
||||
location = string
|
||||
type = string
|
||||
location = string
|
||||
ip_datacenter = string
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -24,26 +23,37 @@ variable "agents" {
|
||||
}
|
||||
|
||||
variable "ping_enabled" {
|
||||
type = bool
|
||||
type = bool
|
||||
default = true
|
||||
}
|
||||
|
||||
variable "public_tcp_services" {
|
||||
type = map(list(string))
|
||||
type = map(list(string))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "kubernetes_exposed_ips" {
|
||||
type = list(string)
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "ssh_exposed_ips" {
|
||||
type = list(string)
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "ssh_port" {
|
||||
type = number
|
||||
type = number
|
||||
default = 1022
|
||||
}
|
||||
|
||||
variable "auto_delete_primary_ips" {
|
||||
default = true
|
||||
description = <<EOF
|
||||
Set this to "false" to keep the primary IPs bound to your Hetzner-Account, even after a destroy.
|
||||
This setting would allow for reuse of the same IPs between multiple create/destroy cycles.
|
||||
Though, it doesn't guarantee reuse of the same IPs.
|
||||
|
||||
Note, that reserved IPs will create costs, even if they're not used.
|
||||
EOF
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user