-
Notifications
You must be signed in to change notification settings - Fork 1
/
kubernetes.tf
152 lines (131 loc) · 4.29 KB
/
kubernetes.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
145
146
147
148
149
150
151
152
# Kubernetes provider
# https://learn.hashicorp.com/terraform/kubernetes/provision-eks-cluster#optional-configure-terraform-kubernetes-provider
# To learn how to schedule deployments and services using the provider, go here: https://learn.hashicorp.com/terraform/kubernetes/deploy-nginx-kubernetes
# The Kubernetes provider is included in this file so the EKS module can complete successfully. Otherwise, it throws an error when creating `kubernetes_config_map.aws_auth`.
# You should **not** schedule deployments and services in this workspace. This keeps workspaces modular (one for provision EKS, another for scheduling Kubernetes resources) as per best practices.
provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
exec {
api_version = "client.authentication.k8s.io/v1alpha1"
command = "aws"
args = [
"eks",
"get-token",
"--cluster-name",
data.aws_eks_cluster.cluster.name
]
}
}
provider "helm" {
kubernetes {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
exec {
api_version = "client.authentication.k8s.io/v1alpha1"
args = ["eks", "get-token", "--cluster-name", var.eks.cluster_name]
command = "aws"
}
}
}
resource "helm_release" "metric-server" {
name = "metric-server"
repository = "https://charts.bitnami.com/bitnami"
chart = "metrics-server"
namespace = "kube-system"
depends_on = [aws_eks_node_group.workers]
}
resource "null_resource" "metric_server" {
provisioner "local-exec" {
command = "kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml"
}
depends_on = [aws_eks_node_group.workers]
}
resource "helm_release" "cluster-autoscaler" {
name = "cluster-autoscaler"
repository = "https://kubernetes.github.io/autoscaler"
chart = "cluster-autoscaler"
namespace = "kube-system"
values = [templatefile("./valueOverrideFiles/clusterAutoScaler.yaml.tpl", {
clusterName = var.eks.cluster_name ,
serviceAccount = module.iam_assumable_role_admin.iam_role_arn ,
awsRegion = var.region
cloudProvider = "aws"
fullnameOverride = "cluster-autoscaler"
})]
depends_on = [aws_eks_node_group.workers]
}
resource "helm_release" "prometheus" {
name = "prometheus"
repository = "https://prometheus-community.github.io/helm-charts"
chart = "prometheus"
namespace = "monitoring"
create_namespace = true
values = [
"${file("valueOverrideFiles/prometheus.yaml")}"
]
depends_on = [aws_eks_node_group.workers]
set {
name = "fullnameOverride"
value = "prometheus"
}
}
resource "helm_release" "loki" {
name = "loki"
repository = "https://grafana.github.io/helm-charts"
chart = "loki-stack"
namespace = "monitoring"
create_namespace = true
depends_on = [aws_eks_node_group.workers]
set {
name = "fullnameOverride"
value = "loki"
}
}
resource "helm_release" "grafana" {
name = "grafana"
repository = "https://grafana.github.io/helm-charts"
chart = "grafana"
namespace = "monitoring"
create_namespace = true
depends_on = [aws_eks_node_group.workers]
values = [
"${file("valueOverrideFiles/grafanaValues.yaml")}"
]
set {
name = "fullnameOverride"
value = "grafana"
}
}
resource "helm_release" "ingress-nginx" {
name = "ingress"
repository = "https://kubernetes.github.io/ingress-nginx"
chart = "ingress-nginx"
namespace = "ingress-nginx"
create_namespace = true
depends_on = [aws_eks_node_group.workers]
set {
name = "fullnameOverride"
value = "ingress-nginx"
}
}
resource "helm_release" "cert-manager" {
name = "tls"
repository = "https://charts.jetstack.io"
chart = "cert-manager"
namespace = "cert-manager"
create_namespace = true
depends_on = [aws_eks_node_group.workers]
set {
name = "version"
value = "v1.3.1"
}
set {
name = "installCRDs"
value = true
}
set {
name = "fullnameOverride"
value = "cert-manager"
}
}