forked from isovalent/terraform-aws-talos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-infra.tf
82 lines (71 loc) · 1.89 KB
/
02-infra.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
module "cluster_sg" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 5.1"
name = var.cluster_name
description = "Allow all intra-cluster and egress traffic"
vpc_id = var.vpc_id
tags = var.tags
ingress_with_self = [
{
rule = "all-all"
},
]
ingress_with_cidr_blocks = [
{
from_port = 50000
to_port = 50000
protocol = "tcp"
cidr_blocks = var.talos_api_allowed_cidr
description = "Talos API Access"
},
]
egress_with_cidr_blocks = [
{
rule = "all-all"
cidr_blocks = "0.0.0.0/0"
},
]
}
module "kubernetes_api_sg" {
source = "terraform-aws-modules/security-group/aws//modules/https-443"
version = "~> 5.1"
name = "${var.cluster_name}-k8s-api"
description = "Allow access to the Kubernetes API"
vpc_id = var.vpc_id
ingress_cidr_blocks = [var.kubernetes_api_allowed_cidr]
tags = var.tags
}
module "elb_k8s_elb" {
source = "terraform-aws-modules/elb/aws"
version = "~> 4.0"
name = "${var.cluster_name}-k8s-api"
subnets = data.aws_subnets.public.ids
tags = merge(var.tags, local.cluster_required_tags)
security_groups = [
module.cluster_sg.security_group_id,
module.kubernetes_api_sg.security_group_id,
]
listener = [
{
lb_port = 443
lb_protocol = "tcp"
instance_port = 6443
instance_protocol = "tcp"
},
{
lb_port = 50000
lb_protocol = "tcp"
instance_port = 50000
instance_protocol = "tcp"
}
]
health_check = {
target = "tcp:6443"
interval = 30
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 5
}
number_of_instances = var.controlplane_count
instances = module.talos_control_plane_nodes.*.id
}