Skip to content

Commit

Permalink
DNS and hosts are setup. Next step is the SSH keys and unattended ins…
Browse files Browse the repository at this point in the history
…tallation.
  • Loading branch information
dwmkerr committed Jan 29, 2017
1 parent bd5a5de commit 76ede4d
Show file tree
Hide file tree
Showing 7 changed files with 424 additions and 58 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ You'll be paying for:

- https://www.udemy.com/openshift-enterprise-installation-and-configuration - The basic structure of the network is based on this course.
- https://blog.openshift.com/openshift-container-platform-reference-architecture-implementation-guides/ - Detailed guide on high available solutions, including production grade AWS setup.

## TODO

- [ ] Consider whether it is needed to script elastic IPs for the instances and DNS.
- [ ] Test whether the previously registered domain name is actually forwarding to the public DNS.
14 changes: 13 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "aws" {
}

// Create the OpenShift cluster using our module.
module "consul-cluster" {
module "openshift" {
source = "./modules/openshift"
region = "${var.region}"
amisize = "t2.large" // Smallest that meets the min specs for OS
Expand All @@ -13,4 +13,16 @@ module "consul-cluster" {
subnet_cidr = "10.0.1.0/24"
key_name = "openshift"
public_key_path = "${var.public_key_path}"
public_domain = "${var.public_domain}"
}

// Output some useful variables for quick SSH access etc.
output "master-dns" {
value = "${module.openshift.master-dns}"
}
output "node1-dns" {
value = "${module.openshift.node1-dns}"
}
output "node2-dns" {
value = "${module.openshift.node2-dns}"
}
4 changes: 4 additions & 0 deletions modules/openshift/00-variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ variable "key_name" {
variable "public_key_path" {
description = "The local public key path, e.g. ~/.ssh/id_rsa.pub"
}

variable "public_domain" {
description = "The public domain for the cluster, e.g: openshifting.com"
}
75 changes: 75 additions & 0 deletions modules/openshift/04-dns.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Notes: We could make the internal domain a variable, but not sure it is
// really necessary.

// Create the internal DNS.
resource "aws_route53_zone" "internal" {
name = "openshift.local"
comment = "OpenShift Cluster Internal DNS"
vpc_id = "${aws_vpc.openshift.id}"
tags {
Name = "OpenShift Internal DNS"
Project = "openshift"
}
}

// Routes for 'master', 'node1' and 'node2'.
resource "aws_route53_record" "master-a-record" {
zone_id = "${aws_route53_zone.internal.zone_id}"
name = "master.openshift.local"
type = "A"
ttl = 300
records = [
"${aws_instance.master.private_ip}"
]
}
resource "aws_route53_record" "node1-a-record" {
zone_id = "${aws_route53_zone.internal.zone_id}"
name = "node1.openshift.local"
type = "A"
ttl = 300
records = [
"${aws_instance.node1.private_ip}"
]
}
resource "aws_route53_record" "node2-a-record" {
zone_id = "${aws_route53_zone.internal.zone_id}"
name = "node2.openshift.local"
type = "A"
ttl = 300
records = [
"${aws_instance.node2.private_ip}"
]
}

// Create the external DNS.
resource "aws_route53_zone" "external" {
name = "${var.public_domain}"
comment = "OpenShift Cluster External DNS"

tags {
Name = "OpenShift External DNS"
Project = "openshift"
}
}

// Create a record to hit the master node via 'console.<domain>'.
resource "aws_route53_record" "master-console-a-record" {
zone_id = "${aws_route53_zone.external.zone_id}"
name = "console.${var.public_domain}"
type = "A"
ttl = 300
records = [
"${aws_instance.master.public_ip}"
]
}

// Also add a wildcard - this'll be for services etc.
resource "aws_route53_record" "master-wildcard-a-record" {
zone_id = "${aws_route53_zone.external.zone_id}"
name = "*.${var.public_domain}"
type = "A"
ttl = 300
records = [
"${aws_instance.master.public_ip}"
]
}
10 changes: 10 additions & 0 deletions modules/openshift/99-outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Output some useful variables for quick SSH access etc.
output "master-dns" {
value = "${aws_instance.master.public_dns}"
}
output "node1-dns" {
value = "${aws_instance.node1.public_dns}"
}
output "node2-dns" {
value = "${aws_instance.node2.public_dns}"
}
Loading

0 comments on commit 76ede4d

Please sign in to comment.