Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add server groups to OpenStack example #3354

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/terraform/openstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ See the [Terraform loadbalancers in examples document][docs-tf-loadbalancer].

| Name | Version |
|------|---------|
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | ~> 1.52.0 |
| <a name="provider_openstack"></a> [openstack](#provider\_openstack) | 1.52.1 |

## Modules

Expand All @@ -36,6 +36,7 @@ No modules.
| [openstack_compute_instance_v2.bastion](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_instance_v2) | resource |
| [openstack_compute_instance_v2.control_plane](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_instance_v2) | resource |
| [openstack_compute_keypair_v2.deployer](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_keypair_v2) | resource |
| [openstack_compute_servergroup_v2.control_plane](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_servergroup_v2) | resource |
| [openstack_lb_listener_v2.kube_apiserver](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/lb_listener_v2) | resource |
| [openstack_lb_loadbalancer_v2.kube_apiserver](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/lb_loadbalancer_v2) | resource |
| [openstack_lb_member_v2.kube_apiserver](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/lb_member_v2) | resource |
Expand Down Expand Up @@ -73,6 +74,7 @@ No modules.
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of the cluster | `string` | n/a | yes |
| <a name="input_config_drive"></a> [config\_drive](#input\_config\_drive) | If enabled, metadata for machines is stored on a configuration drive instead of the metadata service. | `bool` | `false` | no |
| <a name="input_control_plane_flavor"></a> [control\_plane\_flavor](#input\_control\_plane\_flavor) | OpenStack instance flavor for the control plane nodes | `string` | `"m1.small"` | no |
| <a name="input_control_plane_group_policy"></a> [control\_plane\_group\_policy](#input\_control\_plane\_group\_policy) | OpenStack instance group policy for the control plane nodes. Cannot be changed without recreating VMs! | `string` | `"soft-anti-affinity"` | no |
| <a name="input_control_plane_vm_count"></a> [control\_plane\_vm\_count](#input\_control\_plane\_vm\_count) | number of control plane instances | `number` | `3` | no |
| <a name="input_external_network_name"></a> [external\_network\_name](#input\_external\_network\_name) | OpenStack external network name | `string` | n/a | yes |
| <a name="input_image"></a> [image](#input\_image) | image name to use | `string` | `""` | no |
Expand Down
9 changes: 9 additions & 0 deletions examples/terraform/openstack/control_plane.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

resource "openstack_compute_servergroup_v2" "control_plane" {
name = "${var.cluster_name}-control_plane"
policies = [var.control_plane_group_policy]
}
Comment on lines +17 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are policies supported by default on all OpenStack installations or does it require policies to be explicitly enabled and created?


resource "openstack_networking_port_v2" "control_plane" {
count = var.control_plane_vm_count
name = "${var.cluster_name}-control_plane-${count.index}"
Expand All @@ -37,6 +42,10 @@ resource "openstack_compute_instance_v2" "control_plane" {
security_groups = [openstack_networking_secgroup_v2.securitygroup.name]
config_drive = var.config_drive

scheduler_hints {
group = openstack_compute_servergroup_v2.control_plane.id
}
Comment on lines +45 to +47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we provide an easy way to disable this? For example, if we can control this with a variable.


network {
port = element(openstack_networking_port_v2.control_plane[*].id, count.index)
}
Expand Down
6 changes: 6 additions & 0 deletions examples/terraform/openstack/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ variable "control_plane_flavor" {
type = string
}

variable "control_plane_group_policy" {
description = "OpenStack instance group policy for the control plane nodes. Cannot be changed without recreating VMs!"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description = "OpenStack instance group policy for the control plane nodes. Cannot be changed without recreating VMs!"
description = "OpenStack instance group policy for the control plane nodes"

We'll document the other part in the changelog.

default = "soft-anti-affinity"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somewhere document supported values and why we recommend soft-anti-affinity?

type = string
}

# Worker Node Variables
variable "worker_os" {
description = "OS to run on worker machines"
Expand Down