Onboard Load Balancer (part 4: acc tests, examples and documentation) (#117)
* Implement acceptance test * Add resource and data source to the provider * Add examples and markdown description * Generate docs * Adjustments after review * Move load balancer supporting infrastructure from resource config to example
This commit is contained in:
parent
b804dc789e
commit
7188e13e92
9 changed files with 831 additions and 0 deletions
97
docs/data-sources/loadbalancer.md
Normal file
97
docs/data-sources/loadbalancer.md
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_loadbalancer Data Source - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
Load Balancer resource schema.
|
||||
---
|
||||
|
||||
# stackit_loadbalancer (Data Source)
|
||||
|
||||
Load Balancer resource schema.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
data "stackit_loadbalancer" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-load-balancer"
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `name` (String) Load balancer name.
|
||||
- `project_id` (String) STACKIT project ID to which the Load Balancer is associated.
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `external_address` (String) External Load Balancer IP address where this Load Balancer is exposed.
|
||||
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","`name`".
|
||||
- `listeners` (Attributes List) List of all listeners which will accept traffic. Limited to 20. (see [below for nested schema](#nestedatt--listeners))
|
||||
- `networks` (Attributes List) List of networks that listeners and targets reside in. (see [below for nested schema](#nestedatt--networks))
|
||||
- `options` (Attributes) Defines any optional functionality you want to have enabled on your load balancer. (see [below for nested schema](#nestedatt--options))
|
||||
- `private_address` (String) Transient private Load Balancer IP address. It can change any time.
|
||||
- `target_pools` (Attributes List) List of all target pools which will be used in the Load Balancer. Limited to 20. (see [below for nested schema](#nestedatt--target_pools))
|
||||
|
||||
<a id="nestedatt--listeners"></a>
|
||||
### Nested Schema for `listeners`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `display_name` (String)
|
||||
- `port` (Number) Port number where we listen for traffic.
|
||||
- `protocol` (String) Protocol is the highest network protocol we understand to load balance.
|
||||
- `target_pool` (String) Reference target pool by target pool name.
|
||||
|
||||
|
||||
<a id="nestedatt--networks"></a>
|
||||
### Nested Schema for `networks`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `network_id` (String) Openstack network ID.
|
||||
- `role` (String) The role defines how the load balancer is using the network.
|
||||
|
||||
|
||||
<a id="nestedatt--options"></a>
|
||||
### Nested Schema for `options`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `acl` (Set of String) Load Balancer is accessible only from an IP address in this range.
|
||||
- `private_network_only` (Boolean) If true, Load Balancer is accessible only via a private network IP address.
|
||||
|
||||
|
||||
<a id="nestedatt--target_pools"></a>
|
||||
### Nested Schema for `target_pools`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `active_health_check` (Attributes) (see [below for nested schema](#nestedatt--target_pools--active_health_check))
|
||||
- `name` (String) Target pool name.
|
||||
- `target_port` (Number) Identical port number where each target listens for traffic.
|
||||
- `targets` (Attributes List) List of all targets which will be used in the pool. Limited to 250. (see [below for nested schema](#nestedatt--target_pools--targets))
|
||||
|
||||
<a id="nestedatt--target_pools--active_health_check"></a>
|
||||
### Nested Schema for `target_pools.active_health_check`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `healthy_threshold` (Number) Healthy threshold of the health checking.
|
||||
- `interval` (String) Interval duration of health checking in seconds.
|
||||
- `interval_jitter` (String) Interval duration threshold of the health checking in seconds.
|
||||
- `timeout` (String) Active health checking timeout duration in seconds.
|
||||
- `unhealthy_threshold` (Number) Unhealthy threshold of the health checking.
|
||||
|
||||
|
||||
<a id="nestedatt--target_pools--targets"></a>
|
||||
### Nested Schema for `target_pools.targets`
|
||||
|
||||
Read-Only:
|
||||
|
||||
- `display_name` (String) Target display name
|
||||
- `ip` (String) Target IP
|
||||
|
|
@ -116,6 +116,7 @@ Using this flow is less secure since the token is long-lived. You can provide th
|
|||
- `credentials_path` (String) Path of JSON from where the credentials are read. Takes precedence over the env var `STACKIT_CREDENTIALS_PATH`. Default value is `~/.stackit/credentials.json`.
|
||||
- `dns_custom_endpoint` (String) Custom endpoint for the DNS service
|
||||
- `jwks_custom_endpoint` (String) Custom endpoint for the jwks API, which is used to get the json web key sets (jwks) to validate tokens when using the key flow
|
||||
- `loadbalancer_custom_endpoint` (String) Custom endpoint for the Load Balancer service
|
||||
- `logme_custom_endpoint` (String) Custom endpoint for the LogMe service
|
||||
- `mariadb_custom_endpoint` (String) Custom endpoint for the MariaDB service
|
||||
- `mongodbflex_custom_endpoint` (String) Custom endpoint for the MongoDB Flex service
|
||||
|
|
|
|||
261
docs/resources/loadbalancer.md
Normal file
261
docs/resources/loadbalancer.md
Normal file
|
|
@ -0,0 +1,261 @@
|
|||
---
|
||||
# generated by https://github.com/hashicorp/terraform-plugin-docs
|
||||
page_title: "stackit_loadbalancer Resource - stackit"
|
||||
subcategory: ""
|
||||
description: |-
|
||||
Setting up supporting infrastructure
|
||||
Configuring an OpenStack provider
|
||||
To automate the creation of load balancers, OpenStack can be used to setup the supporting infrastructure.
|
||||
To set up the OpenStack provider, you can create a token through the STACKIT Portal, in your project's Infrastructure API page.
|
||||
There, the OpenStack user domain name, username, and password are generated and can be obtained. The provider can then be configured as follows:
|
||||
```terraform
|
||||
terraform {
|
||||
required_providers {
|
||||
(...)
|
||||
openstack = {
|
||||
source = "terraform-provider-openstack/openstack"
|
||||
}
|
||||
}
|
||||
}
|
||||
provider "openstack" {
|
||||
userdomainname = "{OpenStack user domain name}"
|
||||
username = "{OpenStack username}"
|
||||
password = "{OpenStack password}"
|
||||
region = "RegionOne"
|
||||
authurl = "https://keystone.api.iaas.eu01.stackit.cloud/v3"
|
||||
}
|
||||
```
|
||||
Configuring the supporting infrastructure
|
||||
The example below uses OpenStack to create the network, router, a public IP address and a compute instance.
|
||||
---
|
||||
|
||||
# stackit_loadbalancer (Resource)
|
||||
|
||||
## Setting up supporting infrastructure
|
||||
|
||||
|
||||
### Configuring an OpenStack provider
|
||||
|
||||
|
||||
To automate the creation of load balancers, OpenStack can be used to setup the supporting infrastructure.
|
||||
To set up the OpenStack provider, you can create a token through the STACKIT Portal, in your project's Infrastructure API page.
|
||||
There, the OpenStack user domain name, username, and password are generated and can be obtained. The provider can then be configured as follows:
|
||||
```terraform
|
||||
terraform {
|
||||
required_providers {
|
||||
(...)
|
||||
openstack = {
|
||||
source = "terraform-provider-openstack/openstack"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "openstack" {
|
||||
user_domain_name = "{OpenStack user domain name}"
|
||||
user_name = "{OpenStack username}"
|
||||
password = "{OpenStack password}"
|
||||
region = "RegionOne"
|
||||
auth_url = "https://keystone.api.iaas.eu01.stackit.cloud/v3"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Configuring the supporting infrastructure
|
||||
|
||||
The example below uses OpenStack to create the network, router, a public IP address and a compute instance.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```terraform
|
||||
# Create a network
|
||||
resource "openstack_networking_network_v2" "example" {
|
||||
name = "example-network"
|
||||
}
|
||||
|
||||
# Create a subnet
|
||||
resource "openstack_networking_subnet_v2" "example" {
|
||||
name = "example-subnet"
|
||||
cidr = "192.168.0.0/25"
|
||||
dns_nameservers = ["8.8.8.8"]
|
||||
network_id = openstack_networking_network_v2.example.id
|
||||
}
|
||||
|
||||
# Get public network
|
||||
data "openstack_networking_network_v2" "public" {
|
||||
name = "floating-net"
|
||||
}
|
||||
|
||||
# Create a floating IP
|
||||
resource "openstack_networking_floatingip_v2" "example" {
|
||||
pool = data.openstack_networking_network_v2.public.name
|
||||
}
|
||||
|
||||
# Get flavor for instance
|
||||
data "openstack_compute_flavor_v2" "example" {
|
||||
name = "g1.1"
|
||||
}
|
||||
|
||||
# Create an instance
|
||||
resource "openstack_compute_instance_v2" "example" {
|
||||
depends_on = [openstack_networking_subnet_v2.example]
|
||||
name = "example-instance"
|
||||
flavor_id = data.openstack_compute_flavor_v2.example.id
|
||||
admin_pass = "example"
|
||||
security_groups = ["default"]
|
||||
|
||||
block_device {
|
||||
uuid = "4364cdb2-dacd-429b-803e-f0f7cfde1c24" // Ubuntu 22.04
|
||||
volume_size = 32
|
||||
source_type = "image"
|
||||
destination_type = "volume"
|
||||
delete_on_termination = true
|
||||
}
|
||||
|
||||
network {
|
||||
name = openstack_networking_network_v2.example.name
|
||||
}
|
||||
}
|
||||
|
||||
# Create a router and attach it to the public network
|
||||
resource "openstack_networking_router_v2" "example" {
|
||||
name = "example-router"
|
||||
admin_state_up = "true"
|
||||
external_network_id = data.openstack_networking_network_v2.public.id
|
||||
}
|
||||
|
||||
# Attach the subnet to the router
|
||||
resource "openstack_networking_router_interface_v2" "example_interface" {
|
||||
router_id = openstack_networking_router_v2.example.id
|
||||
subnet_id = openstack_networking_subnet_v2.example.id
|
||||
}
|
||||
|
||||
# Create a load balancer
|
||||
resource "stackit_loadbalancer" "example" {
|
||||
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
||||
name = "example-load-balancer"
|
||||
target_pools = [
|
||||
{
|
||||
name = "example-target-pool"
|
||||
target_port = 80
|
||||
targets = [
|
||||
{
|
||||
display_name = "example-target"
|
||||
ip = openstack_compute_instance_v2.example.network.0.fixed_ip_v4
|
||||
}
|
||||
]
|
||||
active_health_check = {
|
||||
healthy_threshold = 10
|
||||
interval = "3s"
|
||||
interval_jitter = "3s"
|
||||
timeout = "3s"
|
||||
unhealthy_threshold = 10
|
||||
}
|
||||
}
|
||||
]
|
||||
listeners = [
|
||||
{
|
||||
display_name = "example-listener"
|
||||
port = 80
|
||||
protocol = "PROTOCOL_TCP"
|
||||
target_pool = "example-target-pool"
|
||||
}
|
||||
]
|
||||
networks = [
|
||||
{
|
||||
network_id = openstack_networking_network_v2.example.id
|
||||
role = "ROLE_LISTENERS_AND_TARGETS"
|
||||
}
|
||||
]
|
||||
external_address = openstack_networking_floatingip_v2.example.address
|
||||
options = {
|
||||
private_network_only = false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<!-- schema generated by tfplugindocs -->
|
||||
## Schema
|
||||
|
||||
### Required
|
||||
|
||||
- `listeners` (Attributes List) List of all listeners which will accept traffic. Limited to 20. (see [below for nested schema](#nestedatt--listeners))
|
||||
- `name` (String) Load balancer name.
|
||||
- `networks` (Attributes List) List of networks that listeners and targets reside in. (see [below for nested schema](#nestedatt--networks))
|
||||
- `project_id` (String) STACKIT project ID to which the Load Balancer is associated.
|
||||
- `target_pools` (Attributes List) List of all target pools which will be used in the Load Balancer. Limited to 20. (see [below for nested schema](#nestedatt--target_pools))
|
||||
|
||||
### Optional
|
||||
|
||||
- `external_address` (String) External Load Balancer IP address where this Load Balancer is exposed.
|
||||
- `options` (Attributes) Defines any optional functionality you want to have enabled on your load balancer. (see [below for nested schema](#nestedatt--options))
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `id` (String) Terraform's internal resource ID. It is structured as "`project_id`","`name`".
|
||||
- `private_address` (String) Transient private Load Balancer IP address. It can change any time.
|
||||
|
||||
<a id="nestedatt--listeners"></a>
|
||||
### Nested Schema for `listeners`
|
||||
|
||||
Optional:
|
||||
|
||||
- `display_name` (String)
|
||||
- `port` (Number) Port number where we listen for traffic.
|
||||
- `protocol` (String) Protocol is the highest network protocol we understand to load balance.
|
||||
- `target_pool` (String) Reference target pool by target pool name.
|
||||
|
||||
|
||||
<a id="nestedatt--networks"></a>
|
||||
### Nested Schema for `networks`
|
||||
|
||||
Required:
|
||||
|
||||
- `network_id` (String) Openstack network ID.
|
||||
|
||||
Optional:
|
||||
|
||||
- `role` (String) The role defines how the load balancer is using the network.
|
||||
|
||||
|
||||
<a id="nestedatt--target_pools"></a>
|
||||
### Nested Schema for `target_pools`
|
||||
|
||||
Required:
|
||||
|
||||
- `name` (String) Target pool name.
|
||||
- `target_port` (Number) Identical port number where each target listens for traffic.
|
||||
- `targets` (Attributes List) List of all targets which will be used in the pool. Limited to 250. (see [below for nested schema](#nestedatt--target_pools--targets))
|
||||
|
||||
Optional:
|
||||
|
||||
- `active_health_check` (Attributes) (see [below for nested schema](#nestedatt--target_pools--active_health_check))
|
||||
|
||||
<a id="nestedatt--target_pools--targets"></a>
|
||||
### Nested Schema for `target_pools.targets`
|
||||
|
||||
Required:
|
||||
|
||||
- `display_name` (String) Target display name
|
||||
- `ip` (String) Target IP
|
||||
|
||||
|
||||
<a id="nestedatt--target_pools--active_health_check"></a>
|
||||
### Nested Schema for `target_pools.active_health_check`
|
||||
|
||||
Optional:
|
||||
|
||||
- `healthy_threshold` (Number) Healthy threshold of the health checking.
|
||||
- `interval` (String) Interval duration of health checking in seconds.
|
||||
- `interval_jitter` (String) Interval duration threshold of the health checking in seconds.
|
||||
- `timeout` (String) Active health checking timeout duration in seconds.
|
||||
- `unhealthy_threshold` (Number) Unhealthy threshold of the health checking.
|
||||
|
||||
|
||||
|
||||
<a id="nestedatt--options"></a>
|
||||
### Nested Schema for `options`
|
||||
|
||||
Optional:
|
||||
|
||||
- `acl` (Set of String) Load Balancer is accessible only from an IP address in this range.
|
||||
- `private_network_only` (Boolean) If true, Load Balancer is accessible only via a private network IP address.
|
||||
Loading…
Add table
Add a link
Reference in a new issue