forked from kbst/terraform-kubestack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt ingress and dns setup to new cluster service modules
Removes in-module kubernetes service type loadbalancer
- Loading branch information
Showing
16 changed files
with
121 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,5 @@ | ||
resource "kubernetes_service" "current" { | ||
count = var.disable_default_ingress ? 0 : 1 | ||
|
||
provider = kubernetes.eks | ||
|
||
metadata { | ||
name = "ingress-kbst-default" | ||
namespace = "ingress-kbst-default" | ||
} | ||
|
||
spec { | ||
type = "LoadBalancer" | ||
|
||
selector = { | ||
"kubestack.com/ingress-default" = "true" | ||
} | ||
|
||
port { | ||
name = "http" | ||
port = 80 | ||
target_port = "http" | ||
} | ||
|
||
port { | ||
name = "https" | ||
port = 443 | ||
target_port = "https" | ||
} | ||
} | ||
|
||
depends_on = [module.cluster_services] | ||
} | ||
|
||
resource "aws_route53_zone" "current" { | ||
count = var.disable_default_ingress ? 0 : 1 | ||
|
||
name = "${var.metadata_fqdn}." | ||
} | ||
|
||
data "aws_elb_hosted_zone_id" "current" { | ||
count = var.disable_default_ingress ? 0 : 1 | ||
} | ||
|
||
resource "aws_route53_record" "host" { | ||
count = var.disable_default_ingress ? 0 : 1 | ||
|
||
zone_id = aws_route53_zone.current[0].zone_id | ||
name = var.metadata_fqdn | ||
type = "A" | ||
|
||
alias { | ||
name = kubernetes_service.current[0].status[0].load_balancer[0].ingress[0].hostname | ||
zone_id = data.aws_elb_hosted_zone_id.current[0].id | ||
evaluate_target_health = true | ||
} | ||
} | ||
|
||
resource "aws_route53_record" "wildcard" { | ||
count = var.disable_default_ingress ? 0 : 1 | ||
|
||
zone_id = aws_route53_zone.current[0].zone_id | ||
name = "*.${var.metadata_fqdn}" | ||
type = "A" | ||
|
||
alias { | ||
name = kubernetes_service.current[0].status[0].load_balancer[0].ingress[0].hostname | ||
zone_id = data.aws_elb_hosted_zone_id.current[0].id | ||
evaluate_target_health = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
variable "ingress_service_name" { | ||
type = string | ||
description = "Metadata name of the ingress service." | ||
} | ||
|
||
variable "ingress_service_namespace" { | ||
type = string | ||
description = "Metadata namespace of the ingress service." | ||
} | ||
|
||
variable "metadata_fqdn" { | ||
type = string | ||
description = "Cluster module FQDN." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
} | ||
|
||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
} | ||
} | ||
|
||
required_version = ">= 0.13" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
data "kubernetes_service" "current" { | ||
metadata { | ||
name = var.ingress_service_name | ||
namespace = var.ingress_service_namespace | ||
} | ||
} | ||
|
||
data "aws_route53_zone" "current" { | ||
name = "${var.metadata_fqdn}." | ||
} | ||
|
||
data "aws_elb_hosted_zone_id" "current" { | ||
} | ||
|
||
resource "aws_route53_record" "host" { | ||
zone_id = data.aws_route53_zone.current.zone_id | ||
name = var.metadata_fqdn | ||
type = "A" | ||
|
||
alias { | ||
name = data.kubernetes_service.current.status[0].load_balancer[0].ingress[0].hostname | ||
zone_id = data.aws_elb_hosted_zone_id.current.id | ||
evaluate_target_health = true | ||
} | ||
} | ||
|
||
resource "aws_route53_record" "wildcard" { | ||
zone_id = data.aws_route53_zone.current.zone_id | ||
name = "*.${var.metadata_fqdn}" | ||
type = "A" | ||
|
||
alias { | ||
name = data.kubernetes_service.current.status[0].load_balancer[0].ingress[0].hostname | ||
zone_id = data.aws_elb_hosted_zone_id.current.id | ||
evaluate_target_health = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
variable "ingress_service_name" { | ||
type = string | ||
description = "Metadata name of the ingress service." | ||
} | ||
|
||
variable "ingress_service_namespace" { | ||
type = string | ||
description = "Metadata namespace of the ingress service." | ||
} | ||
|
||
variable "metadata_fqdn" { | ||
type = string | ||
description = "Cluster module FQDN." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
} | ||
|
||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
} | ||
} | ||
|
||
required_version = ">= 0.13" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
output "kubeconfig" { | ||
value = data.template_file.kubeconfig.rendered | ||
} | ||
|
||
output "default_ingress_ip" { | ||
value = length(google_compute_address.current) > 0 ? google_compute_address.current[0].address : null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters