-
Notifications
You must be signed in to change notification settings - Fork 0
/
eks.tf
72 lines (59 loc) · 2.05 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
resource "aws_eks_cluster" "eks_cluster" {
name = "eks-cluster"
role_arn = aws_iam_role.eks_cluster_role.arn
vpc_config {
subnet_ids = var.eks_cluster_subnets
security_group_ids = var.eks_cluster_security_groups
endpoint_private_access = true
endpoint_public_access = true
public_access_cidrs = ["0.0.0.0/0"]
}
kubernetes_network_config {
ip_family = "ipv4"
}
# Ensure that IAM Role permissions are created before and deleted after EKS Cluster handling.
# Otherwise, EKS will not be able to properly delete EKS managed EC2 infrastructure such as Security Groups.
depends_on = [
aws_iam_role_policy_attachment.eks_cluster_role_attach
]
}
resource "aws_eks_addon" "vpc_cni_addon" {
cluster_name = aws_eks_cluster.eks_cluster.name
addon_name = "vpc-cni"
addon_version = "v1.12.6-eksbuild.2"
}
/// must deploy after having node groups
# resource "aws_eks_addon" "coredns_addon" {
# cluster_name = aws_eks_cluster.eks_cluster.name
# addon_name = "coredns"
# addon_version = "v1.10.1-eksbuild.1"
# }
resource "aws_eks_addon" "kube_proxy_addon" {
cluster_name = aws_eks_cluster.eks_cluster.name
addon_name = "kube-proxy"
addon_version = "v1.27.1-eksbuild.1"
depends_on = [
aws_eks_node_group.eks_node_group
]
}
resource "aws_eks_node_group" "eks_node_group" {
cluster_name = aws_eks_cluster.eks_cluster.name
node_group_name = "group1"
node_role_arn = aws_iam_role.eks_node_role.arn
subnet_ids = var.eks_cluster_subnets
scaling_config {
desired_size = 1
max_size = 1
min_size = 1
}
remote_access {
ec2_ssh_key = var.eks_node_group_key_pair
}
# capacity_type = "SPOT" // this line dont let the node to join the node-group
instance_types = ["t3.small"]
# Ensure that IAM Role permissions are created before and deleted after EKS Node Group handling.
# Otherwise, EKS will not be able to properly delete EC2 Instances and Elastic Network Interfaces.
depends_on = [
aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy_attach
]
}