contrib/terraform/aws: Tag instances and remove loadbalancer ip (#2023)

* Properly tag instances and subnets with `kubernetes.io/cluster/$cluster_name`

This is required by kubernetes to support multiple clusters in a single vpc/az

* Get rid of loadbalancer_apiserver_address as it is no longer needed
This commit is contained in:
Jan Jungnickel 2017-12-04 15:31:46 +01:00 committed by Matthew Mosesohn
parent ca8a9c600a
commit b3745f2614
5 changed files with 6 additions and 11 deletions

View file

@ -98,7 +98,7 @@ resource "aws_instance" "k8s-master" {
tags = "${merge(var.default_tags, map( tags = "${merge(var.default_tags, map(
"Name", "kubernetes-${var.aws_cluster_name}-master${count.index}", "Name", "kubernetes-${var.aws_cluster_name}-master${count.index}",
"Cluster", "${var.aws_cluster_name}", "kubernetes.io/cluster/${var.aws_cluster_name}", "member",
"Role", "master" "Role", "master"
))}" ))}"
} }
@ -127,7 +127,7 @@ resource "aws_instance" "k8s-etcd" {
tags = "${merge(var.default_tags, map( tags = "${merge(var.default_tags, map(
"Name", "kubernetes-${var.aws_cluster_name}-etcd${count.index}", "Name", "kubernetes-${var.aws_cluster_name}-etcd${count.index}",
"Cluster", "${var.aws_cluster_name}", "kubernetes.io/cluster/${var.aws_cluster_name}", "member",
"Role", "etcd" "Role", "etcd"
))}" ))}"
@ -151,7 +151,7 @@ resource "aws_instance" "k8s-worker" {
tags = "${merge(var.default_tags, map( tags = "${merge(var.default_tags, map(
"Name", "kubernetes-${var.aws_cluster_name}-worker${count.index}", "Name", "kubernetes-${var.aws_cluster_name}-worker${count.index}",
"Cluster", "${var.aws_cluster_name}", "kubernetes.io/cluster/${var.aws_cluster_name}", "member",
"Role", "worker" "Role", "worker"
))}" ))}"
@ -175,7 +175,6 @@ data "template_file" "inventory" {
list_node = "${join("\n",aws_instance.k8s-worker.*.tags.Name)}" list_node = "${join("\n",aws_instance.k8s-worker.*.tags.Name)}"
list_etcd = "${join("\n",aws_instance.k8s-etcd.*.tags.Name)}" list_etcd = "${join("\n",aws_instance.k8s-etcd.*.tags.Name)}"
elb_api_fqdn = "apiserver_loadbalancer_domain_name=\"${module.aws-elb.aws_elb_api_fqdn}\"" elb_api_fqdn = "apiserver_loadbalancer_domain_name=\"${module.aws-elb.aws_elb_api_fqdn}\""
elb_api_server = "loadbalancer_apiserver={\"port\": ${var.aws_elb_api_port}, \"address\": \"${var.loadbalancer_apiserver_address}\"}"
} }
} }

View file

@ -43,7 +43,7 @@ resource "aws_elb" "aws-elb-api" {
healthy_threshold = 2 healthy_threshold = 2
unhealthy_threshold = 2 unhealthy_threshold = 2
timeout = 3 timeout = 3
target = "HTTP:8080/" target = "TCP:${var.k8s_secure_api_port}"
interval = 30 interval = 30
} }

View file

@ -34,7 +34,8 @@ resource "aws_subnet" "cluster-vpc-subnets-public" {
cidr_block = "${element(var.aws_cidr_subnets_public, count.index)}" cidr_block = "${element(var.aws_cidr_subnets_public, count.index)}"
tags = "${merge(var.default_tags, map( tags = "${merge(var.default_tags, map(
"Name", "kubernetes-${var.aws_cluster_name}-${element(var.aws_avail_zones, count.index)}-public" "Name", "kubernetes-${var.aws_cluster_name}-${element(var.aws_avail_zones, count.index)}-public",
"kubernetes.io/cluster/${var.aws_cluster_name}", "member"
))}" ))}"
} }

View file

@ -25,4 +25,3 @@ kube-master
[k8s-cluster:vars] [k8s-cluster:vars]
${elb_api_fqdn} ${elb_api_fqdn}
${elb_api_server}

View file

@ -99,10 +99,6 @@ variable "k8s_secure_api_port" {
description = "Secure Port of K8S API Server" description = "Secure Port of K8S API Server"
} }
variable "loadbalancer_apiserver_address" {
description= "Bind Address for ELB of K8s API Server"
}
variable "default_tags" { variable "default_tags" {
description = "Default tags for all resources" description = "Default tags for all resources"
type = "map" type = "map"