Skip to content

Commit

Permalink
support for host specific configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
3pings committed Nov 20, 2024
1 parent 293815d commit 7486856
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 19 deletions.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Additionally, with the "VIP" tag, we enable Kubevip for HA. The Edge Host is no
| --------|--------- |
![QRCode](images/qrcode.png) | ![UID Copy](images/uid_copy.png)

```
```tf
module "edge-demo-module" {
source = "spectrocloud/edge/spectrocloud"
version = "1.4.0"
version = "1.5.0"
# Store Number/Location
name = "demo"
# add tags to the cluster (optional) list(strings)
Expand Down Expand Up @@ -62,7 +62,22 @@ module "edge-demo-module" {
edge_host = [
{
host_uid = "edge12345"
host_name = "edge1"
static_ip = "10.100.100.31"
subnet_mask = "255.255.255.0"
default_gateway = "10.100.100.1"
dns_servers = ["10.100.100.1","10.100.100.2"]
},
{
host_uid = "edge123456"
host_name = "edge2"
static_ip = "10.100.100.32"
subnet_mask = "255.255.255.0"
default_gateway = "10.100.100.1"
dns_servers = ["10.100.100.1","10.100.100.2"]
nic_name = "auto"
}
]
},
Expand All @@ -89,7 +104,7 @@ module "edge-demo-module" {
cluster_profiles = [
{
name = "edge-profile"
tag = "1.27.7"
tag = "1.30.5-ubuntu"
context = "project"
},
{
Expand Down Expand Up @@ -126,20 +141,21 @@ module "edge-demo-module" {
}
```
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_spectrocloud"></a> [spectrocloud](#requirement\_spectrocloud) | >= 0.17.4 |
| <a name="requirement_spectrocloud"></a> [spectrocloud](#requirement\_spectrocloud) | >= 0.22.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_spectrocloud"></a> [spectrocloud](#provider\_spectrocloud) | >= 0.17.4 |
| <a name="provider_spectrocloud"></a> [spectrocloud](#provider\_spectrocloud) | 0.22.0 |

## Modules

Expand All @@ -160,7 +176,7 @@ No modules.
| <a name="input_cluster_tags"></a> [cluster\_tags](#input\_cluster\_tags) | Tags to be added to the profile. key:value | `list(string)` | `[]` | no |
| <a name="input_cluster_vip"></a> [cluster\_vip](#input\_cluster\_vip) | IP Address for Cluster VIP for HA. Must be unused on on the same layer 2 segment as the node IPs. | `string` | `""` | no |
| <a name="input_location"></a> [location](#input\_location) | Optional - If used Latitude and Longitude represent the coordinates of the location you wish to assign to the cluster. https://www.latlong.net/ is one tool that can be used to find this. | <pre>object({<br> latitude = optional(number)<br> longitude = optional(number)<br> })</pre> | <pre>{<br> "latitude": 0,<br> "longitude": 0<br>}</pre> | no |
| <a name="input_machine_pools"></a> [machine\_pools](#input\_machine\_pools) | Values for the attributes of the Node Pools. 'edge\_host\_tags' is used to lookup the Edge Host already registered with Palette. | <pre>list(object({<br> name = string<br> additional_labels = optional(map(string))<br> control_plane = optional(bool)<br> control_plane_as_worker = optional(bool)<br> taints = optional(list(object({<br> effect = string<br> key = string<br> value = string<br> })))<br> edge_host = list(object({<br> host_uid = string<br> static_ip = optional(string)<br><br> }))<br> }))</pre> | n/a | yes |
| <a name="input_machine_pools"></a> [machine\_pools](#input\_machine\_pools) | Values for the attributes of the Node Pools. 'edge\_host\_tags' is used to lookup the Edge Host already registered with Palette. | <pre>list(object({<br> name = string<br> additional_labels = optional(map(string))<br> control_plane = optional(bool)<br> control_plane_as_worker = optional(bool)<br> taints = optional(list(object({<br> effect = string<br> key = string<br> value = string<br> })))<br> edge_host = list(object({<br> host_uid = string<br> host_name = optional(string)<br> nic_name = optional(string)<br> static_ip = optional(string)<br> subnet_mask = optional(string)<br> default_gateway = optional(string)<br> dns_servers = optional(list(string))<br> two_node_role = optional(string)<br> }))<br> }))</pre> | n/a | yes |
| <a name="input_name"></a> [name](#input\_name) | Name of the cluster to be created. | `string` | n/a | yes |
| <a name="input_ntp_servers"></a> [ntp\_servers](#input\_ntp\_servers) | n/a | `list(string)` | `[]` | no |
| <a name="input_overlay_cidr_range"></a> [overlay\_cidr\_range](#input\_overlay\_cidr\_range) | CIDR range for the overlay network. | `string` | `""` | no |
Expand Down
23 changes: 19 additions & 4 deletions examples/cluster.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module "edge-demo-module" {
source = "spectrocloud/edge/spectrocloud"
version = "1.4.0"
version = "1.5.0"
# Store Number/Location
name = "demo"
# add tags to the cluster (optional) list(strings)
Expand Down Expand Up @@ -31,8 +31,23 @@ module "edge-demo-module" {
}
edge_host = [
{
host_uid = "edge12345"
static_ip = "10.100.100.31"
host_uid = "edge12345"
host_name = "edge1"
static_ip = "10.100.100.31"
subnet_mask = "255.255.255.0"
default_gateway = "10.100.100.1"
dns_servers = ["10.100.100.1", "10.100.100.2"]

},
{
host_uid = "edge123456"
host_name = "edge2"
static_ip = "10.100.100.32"
subnet_mask = "255.255.255.0"
default_gateway = "10.100.100.1"
dns_servers = ["10.100.100.1", "10.100.100.2"]
nic_name = "auto"

}
]
},
Expand All @@ -59,7 +74,7 @@ module "edge-demo-module" {
cluster_profiles = [
{
name = "edge-profile"
tag = "1.27.7"
tag = "1.30.5-ubuntu"
context = "project"
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {

required_providers {
spectrocloud = {
version = "= 0.17.4"
version = "= 0.22.0"
source = "spectrocloud/spectrocloud"
}
}
Expand Down
12 changes: 9 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ resource "spectrocloud_cluster_edge_native" "this" {
dynamic "edge_host" {
for_each = machine_pool.value.edge_host
content {
host_uid = edge_host.value.host_uid
static_ip = edge_host.value.static_ip
host_uid = edge_host.value.host_uid
host_name = edge_host.value.host_name
nic_name = edge_host.value.nic_name
static_ip = edge_host.value.static_ip
subnet_mask = edge_host.value.subnet_mask
default_gateway = edge_host.value.default_gateway
dns_servers = edge_host.value.dns_servers
two_node_role = edge_host.value.two_node_role

}
}
# edge_host = machine_pool.value.edge_host != null ? machine_pool.value.edge_host : data.spectrocloud_appliances.this[machine_pool.value.name].ids
}
}
dynamic "cluster_profile" {
Expand Down
2 changes: 1 addition & 1 deletion providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
spectrocloud = {
version = ">= 0.17.4"
version = ">= 0.22.0"
source = "spectrocloud/spectrocloud"
}
}
Expand Down
25 changes: 21 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "machine_pools" {
description = "Values for the attributes of the Node Pools. 'edge_host_tags' is used to lookup the Edge Host already registered with Palette."
description = "Values for the attributes of the Node Pools. 'edge_host_tags' is used to lookup the Edge Host already registered with Palette."
type = list(object({
name = string
additional_labels = optional(map(string))
Expand All @@ -11,11 +11,28 @@ variable "machine_pools" {
value = string
})))
edge_host = list(object({
host_uid = string
static_ip = optional(string)

host_uid = string
host_name = optional(string)
nic_name = optional(string)
static_ip = optional(string)
subnet_mask = optional(string)
default_gateway = optional(string)
dns_servers = optional(list(string))
two_node_role = optional(string)
}))
}))

validation {
condition = alltrue([for mp in var.machine_pools : alltrue([
for eh in mp.edge_host : (
eh.two_node_role == null ||
eh.two_node_role == "primary" ||
eh.two_node_role == "secondary"
)
])])

error_message = "The 'two_node_role' field in 'edge_host' objects must be either 'primary', 'secondary', or not set (null)."
}
}
variable "cluster_tags" {
type = list(string)
Expand Down

0 comments on commit 7486856

Please sign in to comment.