Skip to content

Commit 289682f

Browse files
committed
feat(rancher): AWS - Split-horizon DNS setup to make rancher reachable on private ip inside vpc
Rancher URL is set to a public reachable FQDN based on sslip.io. The workload cluster tries to reach and join Rancher through that public IP. In cases were the ingress CIDR is not 0.0.0.0/0 (recommended), downstream cluster need a way to reach Rancher through the private IP. This is achieved with a split-horizon DNS setup that maps the Rancher FQDN to a private ip inside the VPC.
1 parent 9febd3a commit 289682f

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

rancher/aws/infra.tf

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,28 @@ resource "aws_instance" "rancher_server" {
139139
}
140140
}
141141

142+
# Split-horizon DNS setup to make rancher reachable through private ip inside vpc
143+
resource "aws_route53_zone" "rancher_route53_private" {
144+
name = "sslip.io"
145+
comment = "${var.prefix}-rancher-route53"
146+
147+
vpc {
148+
vpc_id = aws_vpc.rancher_vpc.id
149+
}
150+
151+
tags = {
152+
Name = "${var.prefix}-rancher-route53"
153+
Creator = "rancher-quickstart"
154+
}
155+
}
156+
resource "aws_route53_record" "rancher_sslip_private" {
157+
zone_id = aws_route53_zone.rancher_route53_private.zone_id
158+
name = join(".", ["rancher", aws_instance.rancher_server.public_ip, "sslip.io"])
159+
type = "A"
160+
ttl = 300
161+
records = [aws_instance.rancher_server.private_ip]
162+
}
163+
142164
# Rancher resources
143165
module "rancher_common" {
144166
source = "../rancher-common"
@@ -164,7 +186,8 @@ module "rancher_common" {
164186
# AWS EC2 instance for creating a single node workload cluster
165187
resource "aws_instance" "quickstart_node" {
166188
depends_on = [
167-
aws_route_table_association.rancher_route_table_association
189+
aws_route_table_association.rancher_route_table_association,
190+
aws_route53_record.rancher_sslip_private
168191
]
169192
ami = data.aws_ami.sles.id
170193
instance_type = var.instance_type

0 commit comments

Comments
 (0)