FlexibleEngineCloud / terraform-provider-flexibleengine

Terraform flexibleengine provider
https://www.terraform.io/docs/providers/flexibleengine/
Mozilla Public License 2.0
30 stars 53 forks source link

Creating a public Enhanced Load Balancer #417

Closed fculpo closed 3 years ago

fculpo commented 3 years ago

Hi,

I cannot find how to create a Public Enhanced Load Balancer with flexibleengine_lb_loadbalancer_v2 as there is no option for providing Network Type and/or EIP (it works with classic LB flexibleengine_elb_loadbalancer).

With the only parameters available right now, all I can create is an internal/private ELB.

Am I missing something ?

(use case is creation of an ELB and static EIP to use with k8s LoadBalancer)

Terraform version = 0.13.5

Soprad commented 3 years ago

Hi,

Faced the same. Solved it by binding/creating an EIP to our internal v2 ELB through floatingip_v2 ressource to the vip_port of the ELB.

Create ELB v2 :

resource "flexibleengine_lb_loadbalancer_v2" "elb_public" {
  name                = "pub_elb"
  description         = "Public loadbalancer for ${terraform.workspace}"
  vip_subnet_id       = flexibleengine_vpc_subnet_v1.internal_subnet.subnet_id
}

Bind EIP from default pool (will auto-create a new EIP if none is defined) to previously created ELB :

resource "flexibleengine_networking_floatingip_v2" "public_fip" {
  pool      = "admin_external_net"
  port_id   = flexibleengine_lb_loadbalancer_v2.elb_public.vip_port_id
}
osaluden commented 3 years ago

Hello and thank you @Soprad this is indeed the solution. A public ELB is a private ELB with an EIP associated to its VIP. Another way to create the EIP and benefit from the bandwidth parameter :

Same code fot he ELB then use the flexibleengine_vpc_eip_v1 resource (create the EIP and bind to ELB VIP port):

resource "flexibleengine_vpc_eip_v1" "eip" {
  publicip {
    type = "5_bgp" 
    port_id = flexibleengine_lb_loadbalancer_v2.elb_public.vip_port_id
  }
  bandwidth {
    name = "elb-bandwidth"
    size = 10 
    share_type = "PER"
    charge_mode = "traffic"
  }
}

Resource documentation at https://registry.terraform.io/providers/FlexibleEngineCloud/flexibleengine/latest/docs/resources/vpc_eip_v1 for more details about the parameters.

fculpo commented 3 years ago

Thanks I will try that.

Another related question: as we are required to choose a subnet, hence an AZ to deploy ELB, does that mean that if that AZ fails we lose ELB ? That would be a pain point since we deploy our k8s in multi AZ.

If so, is there any way to implement redundancy on the LB ?

antonin-a commented 3 years ago

Hello @fculpo, ELB and subnets (on which you can also specify an AZ) are resilient/redundant by default in order to avoid any spof. The purpose of choosing the AZ is just to choose the "primary" one.

fculpo commented 3 years ago

thanks @antonin-a, I tried the suggested solution, it works as expected, closing this