-
Notifications
You must be signed in to change notification settings - Fork 13
/
eks.tf
144 lines (126 loc) · 3.21 KB
/
eks.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
data "aws_availability_zones" "available" {}
locals {
name = basename(path.cwd)
azs = slice(data.aws_availability_zones.available.names, 0, 3)
tags = {
"tf" : "true"
"Name" : local.name
}
cloud_cidr = "10.0.0.0/16"
}
provider "aws" {
region = var.aws_region
profile = var.aws_profile
default_tags {
tags = {
"tf" : "true"
"Name" : local.name
}
}
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "5.1.2"
name = "kubeflow-vpc"
cidr = local.cloud_cidr
map_public_ip_on_launch = true
azs = local.azs
public_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
private_subnets = ["10.0.3.0/24", "10.0.4.0/24"]
enable_nat_gateway = true
single_nat_gateway = true
enable_dns_hostnames = true
enable_dns_support = true
}
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 19.20"
cluster_name = "cluster"
cluster_version = "1.28"
cluster_endpoint_public_access = true
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.public_subnets
create_cloudwatch_log_group = false
cluster_encryption_config = {}
node_security_group_additional_rules = {
ssh = {
type = "ingress"
description = "Allow SSH inbound traffic from anywhere"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
},
istio_injection_webhook = {
description = "Allow istio injection"
protocol = "tcp"
from_port = "15017"
to_port = "15017"
type = "ingress"
source_cluster_security_group = true
}
}
eks_managed_node_groups = {
amzn_linux = {
instance_types = ["t3.xlarge"]
min_size = 0
max_size = 1
desired_size = 1
}
}
tags = local.tags
}
provider "kubernetes" {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
exec {
command = "aws"
api_version = "client.authentication.k8s.io/v1beta1"
args = [
"--region",
var.aws_region,
"eks",
"get-token",
"--cluster-name",
module.eks.cluster_name
]
env = {
name = "AWS_PROFILE"
value = var.aws_profile
}
}
}
provider "helm" {
kubernetes {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
exec {
command = "aws"
api_version = "client.authentication.k8s.io/v1beta1"
args = [
"--region",
var.aws_region,
"eks",
"get-token",
"--cluster-name",
module.eks.cluster_name
]
env = {
name = "AWS_PROFILE"
value = var.aws_profile
}
}
}
}
resource "null_resource" "cluster_ready" {
# triggers = {
# always_run = "${timestamp()}"
# }
provisioner "local-exec" {
command = "echo 'Cluster is ready!'"
}
depends_on = [
module.vpc,
module.eks
]
}