Skip to content

Commit

Permalink
vSphere AI depl: create api and ingress records (#9021)
Browse files Browse the repository at this point in the history
- update terroform scripts for deployment on vSphere via Assisted
  Installer to create API and Ingress DNS records

Signed-off-by: Daniel Horak <[email protected]>
  • Loading branch information
dahorak authored Dec 8, 2023
1 parent d19b0db commit d022b2a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
27 changes: 27 additions & 0 deletions terraform/ai/vsphere/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ locals {
control_planes = [for idx in range(var.control_plane_count) : "${var.cluster_id}-control-plane-${idx}"]
compute_nodes = [for idx in range(var.compute_count) : "${var.cluster_id}-compute-${idx}"]
guest_id = "rhel8_64Guest"
dns_zone_id = one(data.aws_route53_zone.dns_zone[*].zone_id)
}

// configure connection to vSphere
Expand Down Expand Up @@ -37,6 +38,32 @@ data "vsphere_network" "network" {
distributed_virtual_switch_uuid = ""
}

// get DNS zone for creating API and Ingress A records
data "aws_route53_zone" "dns_zone" {
count = var.base_domain != null ? 1 : 0
name = var.base_domain
}

// create DNS A record for API (only if api_ip is defined)
resource "aws_route53_record" "api_a_record" {
count = var.api_ip != null ? 1 : 0
type = "A"
ttl = "60"
zone_id = local.dns_zone_id
name = "api.${var.cluster_id}.${var.base_domain}"
records = [var.api_ip]
}

// create DNS A record for Ingress (only if ingress_ip is defined)
resource "aws_route53_record" "ingress_a_record" {
count = var.ingress_ip != null ? 1 : 0
type = "A"
ttl = "60"
zone_id = local.dns_zone_id
name = "*.apps.${var.cluster_id}.${var.base_domain}"
records = [var.ingress_ip]
}

// create Resource Pool for VMs
resource "vsphere_resource_pool" "resource_pool" {
name = var.cluster_id
Expand Down
9 changes: 9 additions & 0 deletions terraform/ai/vsphere/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ compute_data_disks_count = "2"
// The size of data disks for Compute VMs, in GB.
// Default 256 GB.
compute_data_disks_size = "256"

// Base DNS domain, where should be the cluster records created
// base_domain = "example.com"

// API IP address, if not defined no DNS record is created
// api_ip = "192.0.2.2"

// Ingress IP address, if not defined no DNS record is created
// ingress_ip = "192.0.2.3"
18 changes: 18 additions & 0 deletions terraform/ai/vsphere/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ variable "system_disk_size" {
default = "120"
}

variable "base_domain" {
type = string
default = null
description = "Base DNS domain, where should be the cluster records created"
}

variable "api_ip" {
type = string
default = null
description = "API IP address, if not defined DNS record is not created"
}

variable "ingress_ip" {
type = string
default = null
description = "Ingress IP address, if not defined DNS record is not created"
}

///////////
// control-plane machine variables
///////////
Expand Down

0 comments on commit d022b2a

Please sign in to comment.