upcloud: add server groups and target port for lb (#9831)
parent
f7dade867a
commit
5bb54ef6a2
|
@ -136,4 +136,8 @@ terraform destroy --var-file cluster-settings.tfvars \
|
|||
* `loadbalancer_plan`: Plan to use for load balancer *(development|production-small)*
|
||||
* `loadbalancers`: Ports to load balance and which machines to forward to. Key of this object will be used as the name of the load balancer frontends/backends
|
||||
* `port`: Port to load balance.
|
||||
* `target_port`: Port to the backend servers.
|
||||
* `backend_servers`: List of servers that traffic to the port should be forwarded to.
|
||||
* `server_groups`: Group servers together
|
||||
* `servers`: The servers that should be included in the group.
|
||||
* `anti_affinity`: If anti-affinity should be enabled, try to spread the VMs out on separate nodes.
|
||||
|
|
|
@ -121,6 +121,7 @@ loadbalancer_plan = "development"
|
|||
loadbalancers = {
|
||||
# "http" : {
|
||||
# "port" : 80,
|
||||
# "target_port" : 80,
|
||||
# "backend_servers" : [
|
||||
# "worker-0",
|
||||
# "worker-1",
|
||||
|
@ -128,3 +129,20 @@ loadbalancers = {
|
|||
# ]
|
||||
# }
|
||||
}
|
||||
|
||||
server_groups = {
|
||||
# "control-plane" = {
|
||||
# servers = [
|
||||
# "master-0"
|
||||
# ]
|
||||
# anti_affinity = true
|
||||
# },
|
||||
# "workers" = {
|
||||
# servers = [
|
||||
# "worker-0",
|
||||
# "worker-1",
|
||||
# "worker-2"
|
||||
# ]
|
||||
# anti_affinity = true
|
||||
# }
|
||||
}
|
|
@ -34,6 +34,8 @@ module "kubernetes" {
|
|||
loadbalancer_enabled = var.loadbalancer_enabled
|
||||
loadbalancer_plan = var.loadbalancer_plan
|
||||
loadbalancers = var.loadbalancers
|
||||
|
||||
server_groups = var.server_groups
|
||||
}
|
||||
|
||||
#
|
||||
|
|
|
@ -13,7 +13,7 @@ locals {
|
|||
lb_backend_servers = flatten([
|
||||
for lb_name, loadbalancer in var.loadbalancers : [
|
||||
for backend_server in loadbalancer.backend_servers : {
|
||||
port = loadbalancer.port
|
||||
port = loadbalancer.target_port
|
||||
lb_name = lb_name
|
||||
server_name = backend_server
|
||||
}
|
||||
|
@ -548,3 +548,11 @@ resource "upcloud_loadbalancer_static_backend_member" "lb_backend_member" {
|
|||
max_sessions = var.loadbalancer_plan == "production-small" ? 50000 : 1000
|
||||
enabled = true
|
||||
}
|
||||
|
||||
resource "upcloud_server_group" "server_groups" {
|
||||
for_each = var.server_groups
|
||||
title = each.key
|
||||
anti_affinity = each.value.anti_affinity
|
||||
labels = {}
|
||||
members = [for server in each.value.servers : merge(upcloud_server.master, upcloud_server.worker)[server].id]
|
||||
}
|
|
@ -90,6 +90,16 @@ variable "loadbalancers" {
|
|||
|
||||
type = map(object({
|
||||
port = number
|
||||
target_port = number
|
||||
backend_servers = list(string)
|
||||
}))
|
||||
}
|
||||
|
||||
variable "server_groups" {
|
||||
description = "Server groups"
|
||||
|
||||
type = map(object({
|
||||
anti_affinity = bool
|
||||
servers = list(string)
|
||||
}))
|
||||
}
|
|
@ -3,7 +3,7 @@ terraform {
|
|||
required_providers {
|
||||
upcloud = {
|
||||
source = "UpCloudLtd/upcloud"
|
||||
version = "~>2.5.0"
|
||||
version = "~>2.7.1"
|
||||
}
|
||||
}
|
||||
required_version = ">= 0.13"
|
||||
|
|
|
@ -122,6 +122,7 @@ loadbalancer_plan = "development"
|
|||
loadbalancers = {
|
||||
# "http" : {
|
||||
# "port" : 80,
|
||||
# "target_port" : 80,
|
||||
# "backend_servers" : [
|
||||
# "worker-0",
|
||||
# "worker-1",
|
||||
|
@ -129,3 +130,20 @@ loadbalancers = {
|
|||
# ]
|
||||
# }
|
||||
}
|
||||
|
||||
server_groups = {
|
||||
# "control-plane" = {
|
||||
# servers = [
|
||||
# "master-0"
|
||||
# ]
|
||||
# anti_affinity = true
|
||||
# },
|
||||
# "workers" = {
|
||||
# servers = [
|
||||
# "worker-0",
|
||||
# "worker-1",
|
||||
# "worker-2"
|
||||
# ]
|
||||
# anti_affinity = true
|
||||
# }
|
||||
}
|
|
@ -126,7 +126,19 @@ variable "loadbalancers" {
|
|||
|
||||
type = map(object({
|
||||
port = number
|
||||
target_port = number
|
||||
backend_servers = list(string)
|
||||
}))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "server_groups" {
|
||||
description = "Server groups"
|
||||
|
||||
type = map(object({
|
||||
anti_affinity = bool
|
||||
servers = list(string)
|
||||
}))
|
||||
|
||||
default = {}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ terraform {
|
|||
required_providers {
|
||||
upcloud = {
|
||||
source = "UpCloudLtd/upcloud"
|
||||
version = "~>2.5.0"
|
||||
version = "~>2.7.1"
|
||||
}
|
||||
}
|
||||
required_version = ">= 0.13"
|
||||
|
|
Loading…
Reference in New Issue