Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Smart Columbus OS deployment #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Retrieve AWS credentials from env variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
provider "aws" {
region = "${var.aws_region}"
profile = "${var.aws_profile}"
}

#####
Expand Down Expand Up @@ -178,7 +179,7 @@ data "template_file" "init_master" {

vars {
kubeadm_token = "${module.kubeadm-token.token}"
dns_name = "${var.cluster_name}.${var.hosted_zone}"
dns_name = "internal.${var.cluster_name}.${var.hosted_zone}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should pass here both the internal as well as the external DNS names. We should use them both to generate the certificate SANs (in init-aws-kubernetes-master.sh, lines 89-91) and create for both of them kubeconfig (same file, lines 107-114) so that you can pick the one with external access or internal access. But I can do this while merging this if you want.

ip_address = "${aws_eip.master.public_ip}"
cluster_name = "${var.cluster_name}"
addons = "${join(" ", var.addons)}"
Expand All @@ -187,7 +188,6 @@ data "template_file" "init_master" {
asg_min_nodes = "${var.min_worker_count}"
asg_max_nodes = "${var.max_worker_count}"
aws_subnets = "${join(" ", concat(var.worker_subnet_ids, list(var.master_subnet_id)))}"

}
}

Expand All @@ -196,7 +196,7 @@ data "template_file" "init_node" {

vars {
kubeadm_token = "${module.kubeadm-token.token}"
dns_name = "${var.cluster_name}.${var.hosted_zone}"
dns_name = "internal.${var.cluster_name}.${var.hosted_zone}"
}
}

Expand Down Expand Up @@ -313,6 +313,12 @@ resource "aws_instance" "master" {
}
}

resource "aws_network_interface" "master_private_interfaces" {
count = "${length(var.worker_subnet_ids)}"
security_groups = ["${aws_security_group.kubernetes.id}"]
subnet_id = "${var.worker_subnet_ids[count.index]}"
}

resource "aws_eip_association" "master_assoc" {
instance_id = "${aws_instance.master.id}"
allocation_id = "${aws_eip.master.id}"
Expand Down Expand Up @@ -395,3 +401,11 @@ resource "aws_route53_record" "master" {
records = ["${aws_eip.master.public_ip}"]
ttl = 300
}

resource "aws_route53_record" "master-internal" {
zone_id = "${data.aws_route53_zone.dns_zone.zone_id}"
name = "internal.${var.cluster_name}.${var.hosted_zone}"
type = "A"
records = ["${aws_network_interface.master_private_interfaces.*.private_ips}"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the network interface here? Why is not sufficient to just use ${aws_instance.master.private_ip} for the internal host name? AFAIK They should not need additional Network Interface to see each other.

ttl = 300
}
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ output "public_ip" {
value = "${aws_eip.master.public_ip}"
}

output "private_ip" {
description = "Cluster private IP address"
value = "${aws_instance.master.private_ip}"
}

output "dns" {
description = "Cluster DNS address"
value = "${aws_route53_record.master.fqdn}"
Expand Down
7 changes: 6 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ variable "aws_region" {
default = "eu-central-1"
}

variable "aws_profile" {
description = "AWS credentials profile to use"
default = "default"
}

variable "cluster_name" {
description = "Name of the AWS Kubernetes cluster - will be used to name all created resources"
}
Expand Down Expand Up @@ -77,4 +82,4 @@ variable api_access_cidr {
default = [
"0.0.0.0/0"
]
}
}