-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathISTIO_helm.tf
162 lines (126 loc) · 4.42 KB
/
ISTIO_helm.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
153
154
155
156
157
158
159
160
161
162
// Install Istio via Helm and Tiller on both clusters
resource "null_resource" "istio-svc-act-gke" {
# Changes to any instance of the cluster requires re-provisioning
triggers = {
cluster_instance_cert = "${google_container_cluster.primary.master_auth.0.cluster_ca_certificate}"
}
provisioner "local-exec" {
environment = {
KUBECONFIG = "${ local.control_cluster_kubeconfig }"
}
command = "kubectl apply -f ${var.ISTIO_helm_yaml_url}"
}
provisioner "local-exec" {
when = "destroy"
environment = {
KUBECONFIG = "${ local.control_cluster_kubeconfig }"
}
command = "kubectl delete -f ${var.ISTIO_helm_yaml_url}"
}
depends_on = ["google_container_cluster.primary"]
}
resource "null_resource" "istio-svc-act-eks" {
# Changes to any instance of the cluster requires re-provisioning
triggers = {
cluster_instance_cert = "${module.eks.cluster_certificate_authority_data}"
}
provisioner "local-exec" {
environment = {
KUBECONFIG = "${ local.remote_cluster_kubeconfig }"
}
command = "kubectl apply -f ${var.ISTIO_helm_yaml_url}"
}
provisioner "local-exec" {
when = "destroy"
environment = {
KUBECONFIG = "${ local.remote_cluster_kubeconfig }"
}
command = "kubectl delete -f ${var.ISTIO_helm_yaml_url}"
}
depends_on = ["module.eks"]
}
resource "helm_repository" "istio" {
name = "${var.ISTIO_chart_repo_name}"
url = "${var.ISTIO_chart_repo}"
}
resource "helm_release" "istio-control-gke" {
#provider = "helm.gke"
repository = "${var.ISTIO_chart_repo_name}"
name = "istio"
chart = "istio"
version = "${var.ISTIO_version}"
namespace = "istio-system"
values = [<<EOF
grafana.enabled : true
kiali.enabled : true
tracing.enabled : true
servicegraph.enabled : true
EOF
]
depends_on = ["null_resource.istio-svc-act-gke", "helm_repository.istio"]
}
// Gather IP Info from Istio Cluster
data "external" "ISTO_CONTROL" {
program = ["bash", "-c", "./get_istio_ips.py ${ local.control_cluster_kubeconfig }"]
depends_on = ["helm_release.istio-control-gke"]
}
resource "helm_release" "istio-remote-eks" {
provider = "helm.eks"
repository = "${var.ISTIO_chart_repo_name}"
name = "istio-remote"
chart = "istio-remote"
version = "${var.ISTIO_version}"
namespace = "istio-system"
values = [<<EOF
global.remotePilotAddress : "${lookup(data.external.ISTO_CONTROL.result, "PILOT_POD_IP")}"
global.remotePolicyAddress : "${lookup(data.external.ISTO_CONTROL.result, "POLICY_POD_IP")}"
global.remoteTelemetryAddress : "${lookup(data.external.ISTO_CONTROL.result, "TELEMETRY_POD_IP")}"
global.proxy.envoyStatsd.enabled : true
global.proxy.envoyStatsd.host : "${lookup(data.external.ISTO_CONTROL.result, "STATSD_POD_IP")}"
global.remoteZipkinAddress : "${lookup(data.external.ISTO_CONTROL.result, "ZIPKIN_POD_IP")}"
EOF
]
depends_on = ["module.eks", "null_resource.istio-svc-act-eks", "helm_release.istio-control-gke", "data.external.ISTO_CONTROL", "helm_repository.istio"]
}
// Label namespace with istio automatic injection
resource "null_resource" "istio-namespace-label-gke" {
# Changes to any instance of the cluster requires re-provisioning
triggers = {
cluster_instance_cert = "${google_container_cluster.primary.master_auth.0.cluster_ca_certificate}"
}
provisioner "local-exec" {
environment = {
KUBECONFIG = "${ local.control_cluster_kubeconfig }"
}
command = "kubectl label namespace default istio-injection=enabled"
}
provisioner "local-exec" {
when = "destroy"
environment = {
KUBECONFIG = "${ local.control_cluster_kubeconfig }"
}
command = "kubectl label namespace default istio-injection-"
}
depends_on = ["helm_release.istio-control-gke"]
}
// Label namespace with istio automatic injection
resource "null_resource" "istio-namespace-label-eks" {
# Changes to any instance of the cluster requires re-provisioning
triggers = {
cluster_instance_cert = "${module.eks.cluster_certificate_authority_data}"
}
provisioner "local-exec" {
environment = {
KUBECONFIG = "${ local.remote_cluster_kubeconfig }"
}
command = "kubectl label namespace default istio-injection=enabled"
}
provisioner "local-exec" {
when = "destroy"
environment = {
KUBECONFIG = "${ local.remote_cluster_kubeconfig }"
}
command = "kubectl label namespace default istio-injection-"
}
depends_on = ["helm_release.istio-remote-eks"]
}