2017-03-02 01:25:58 +08:00
|
|
|
resource "aws_security_group" "aws-elb" {
|
|
|
|
name = "kubernetes-${var.aws_cluster_name}-securitygroup-elb"
|
|
|
|
vpc_id = "${var.aws_vpc_id}"
|
|
|
|
|
2017-10-18 18:44:32 +08:00
|
|
|
tags = "${merge(var.default_tags, map(
|
|
|
|
"Name", "kubernetes-${var.aws_cluster_name}-securitygroup-elb"
|
|
|
|
))}"
|
2017-03-02 01:25:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
resource "aws_security_group_rule" "aws-allow-api-access" {
|
|
|
|
type = "ingress"
|
|
|
|
from_port = "${var.aws_elb_api_port}"
|
|
|
|
to_port = "${var.k8s_secure_api_port}"
|
|
|
|
protocol = "TCP"
|
|
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
|
|
security_group_id = "${aws_security_group.aws-elb.id}"
|
|
|
|
}
|
|
|
|
|
2017-03-20 19:06:07 +08:00
|
|
|
resource "aws_security_group_rule" "aws-allow-api-egress" {
|
|
|
|
type = "egress"
|
|
|
|
from_port = 0
|
|
|
|
to_port = 65535
|
|
|
|
protocol = "TCP"
|
|
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
|
|
security_group_id = "${aws_security_group.aws-elb.id}"
|
|
|
|
}
|
2017-03-02 01:25:58 +08:00
|
|
|
|
|
|
|
# Create a new AWS ELB for K8S API
|
|
|
|
resource "aws_elb" "aws-elb-api" {
|
|
|
|
name = "kubernetes-elb-${var.aws_cluster_name}"
|
|
|
|
subnets = ["${var.aws_subnet_ids_public}"]
|
|
|
|
security_groups = ["${aws_security_group.aws-elb.id}"]
|
|
|
|
|
|
|
|
listener {
|
|
|
|
instance_port = "${var.k8s_secure_api_port}"
|
|
|
|
instance_protocol = "tcp"
|
|
|
|
lb_port = "${var.aws_elb_api_port}"
|
|
|
|
lb_protocol = "tcp"
|
|
|
|
}
|
|
|
|
|
|
|
|
health_check {
|
|
|
|
healthy_threshold = 2
|
|
|
|
unhealthy_threshold = 2
|
|
|
|
timeout = 3
|
2017-12-04 22:31:46 +08:00
|
|
|
target = "TCP:${var.k8s_secure_api_port}"
|
2017-03-02 01:25:58 +08:00
|
|
|
interval = 30
|
|
|
|
}
|
|
|
|
|
|
|
|
cross_zone_load_balancing = true
|
|
|
|
idle_timeout = 400
|
|
|
|
connection_draining = true
|
|
|
|
connection_draining_timeout = 400
|
|
|
|
|
2017-10-18 18:44:32 +08:00
|
|
|
tags = "${merge(var.default_tags, map(
|
|
|
|
"Name", "kubernetes-${var.aws_cluster_name}-elb-api"
|
|
|
|
))}"
|
2017-03-02 01:25:58 +08:00
|
|
|
}
|