Skip to content

Commit

Permalink
feat: Adding flags to switch between LB (#159)
Browse files Browse the repository at this point in the history
* This PR will allow us to pass custom domain filters, allow external dns to control r53 records, deploy the operator phase2

---------

Co-authored-by: Justin Brooks <jsbroks@gmail.com>
  • Loading branch information
zacharyblasczyk and jsbroks authored Jan 10, 2024
1 parent 4ccf34e commit ffa3778
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
22 changes: 12 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ module "acm" {
locals {
acm_certificate_arn = local.create_certificate ? module.acm.acm_certificate_arn : var.acm_certificate_arn
url = local.acm_certificate_arn == null ? "http://${local.fqdn}" : "https://${local.fqdn}"
domain_filter = var.custom_domain_filter == null || var.custom_domain_filter == "" ? local.fqdn : var.custom_domain_filter

internal_app_port = 32543
}

module "app_eks" {
source = "./modules/app_eks"

fqdn = local.fqdn
fqdn = local.domain_filter

namespace = var.namespace
kms_key_arn = local.kms_key_arn
Expand Down Expand Up @@ -153,7 +154,7 @@ module "app_lb" {
acm_certificate_arn = local.acm_certificate_arn
zone_id = var.zone_id

fqdn = local.fqdn
fqdn = var.enable_dummy_dns ? "old.${local.fqdn}" : local.fqdn
extra_fqdn = var.extra_fqdn
allowed_inbound_cidr = var.allowed_inbound_cidr
allowed_inbound_ipv6_cidr = var.allowed_inbound_ipv6_cidr
Expand Down Expand Up @@ -228,18 +229,20 @@ module "wandb" {
class = "alb"

annotations = {
"alb.ingress.kubernetes.io/load-balancer-name" = "${var.namespace}-alb-k8s"
"alb.ingress.kubernetes.io/inbound-cidrs" = <<-EOF
"alb.ingress.kubernetes.io/load-balancer-name" = "${var.namespace}-alb-k8s"
"alb.ingress.kubernetes.io/inbound-cidrs" = <<-EOF
${join("\\,", var.allowed_inbound_cidr)}
EOF
"alb.ingress.kubernetes.io/scheme" = "internet-facing"
"alb.ingress.kubernetes.io/target-type" = "ip"
"alb.ingress.kubernetes.io/listen-ports" = "[{\\\"HTTPS\\\": 443}]"
"alb.ingress.kubernetes.io/certificate-arn" = local.acm_certificate_arn
"external-dns.alpha.kubernetes.io/hostname" = var.enable_operator_alb ? local.fqdn : ""
"external-dns.alpha.kubernetes.io/ingress-hostname-source" = "annotation-only"
"alb.ingress.kubernetes.io/scheme" = "internet-facing"
"alb.ingress.kubernetes.io/target-type" = "ip"
"alb.ingress.kubernetes.io/listen-ports" = "[{\\\"HTTPS\\\": 443}]"
"alb.ingress.kubernetes.io/certificate-arn" = local.acm_certificate_arn
}
}

app = {
app = var.enable_operator_alb ? {} : {
extraEnv = {
"GORILLA_GLUE_LIST" = "true"
}
Expand All @@ -254,7 +257,6 @@ module "wandb" {
efs = {
fileSystemId = module.app_eks.efs_id
}

}
}
}
Expand Down
7 changes: 7 additions & 0 deletions modules/app_eks/external_dns/external_dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ resource "helm_release" "external_dns" {
value = var.fqdn
}

set {
name = "policy"
value = "sync"
}

set {
name = "serviceAccount.annotations.eks\\.amazonaws\\.com/role-arn"
value = aws_iam_role.default.arn
}


}
21 changes: 20 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ variable "external_dns" {
description = "Using external DNS. A `subdomain` must also be specified if this value is true."
}

variable "custom_domain_filter" {
description = "A custom domain filter to be used by external-dns instead of the default FQDN. If not set, the local FQDN is used."
type = string
default = null
}

# Sometimes domain name and zone name dont match, so lets explicitly ask for
# both. Also is just life easier to have both even though in most cause it may
# be redundant info.
Expand All @@ -111,6 +117,19 @@ variable "subdomain" {
description = "Subdomain for accessing the Weights & Biases UI. Default creates record at Route53 Route."
}

variable "enable_dummy_dns" {
type = bool
default = false
description = "Boolean indicating whether or not to enable dummy DNS for the old alb"
}


variable "enable_operator_alb" {
type = bool
default = false
description = "Boolean indicating whether to use operatore ALB (true) or not (false)."
}

variable "extra_fqdn" {
type = list(string)
default = []
Expand Down Expand Up @@ -336,4 +355,4 @@ variable "other_wandb_env" {
type = map(any)
description = "Extra environment variables for W&B"
default = {}
}
}

0 comments on commit ffa3778

Please sign in to comment.