-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathmain.tf
132 lines (109 loc) · 2.78 KB
/
main.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
terraform {
required_providers {
kind = {
source = "tehcyx/kind"
version = "0.5.1"
}
kubectl = {
source = "gavinbunney/kubectl"
version = "1.14.0"
}
}
}
provider "kind" {}
resource "kind_cluster" "default" {
name = var.cluster_name
wait_for_ready = true
kind_config {
kind = "Cluster"
api_version = "kind.x-k8s.io/v1alpha4"
node {
role = "control-plane"
extra_port_mappings {
container_port = 80
host_port = 80
}
extra_port_mappings {
container_port = 443
host_port = 443
}
}
node {
role = "worker"
image = "kindest/node:v1.27.1"
}
node {
role = "worker"
image = "kindest/node:v1.27.1"
}
node {
role = "worker"
image = "kindest/node:v1.27.1"
}
}
}
provider "kubectl" {
host = kind_cluster.default.endpoint
cluster_ca_certificate = kind_cluster.default.cluster_ca_certificate
client_certificate = kind_cluster.default.client_certificate
client_key = kind_cluster.default.client_key
}
data "kubectl_file_documents" "crds" {
content = file("olm/crds.yaml")
}
resource "kubectl_manifest" "crds_apply" {
for_each = data.kubectl_file_documents.crds.manifests
yaml_body = each.value
wait = true
server_side_apply = true
}
data "kubectl_file_documents" "olm" {
content = file("olm/olm.yaml")
}
resource "kubectl_manifest" "olm_apply" {
depends_on = [kubectl_manifest.crds_apply]
for_each = data.kubectl_file_documents.olm.manifests
wait = true
yaml_body = each.value
}
data "kubectl_file_documents" "final" {
content = file("olm/final.yaml")
}
resource "kubectl_manifest" "final_apply" {
depends_on = [kubectl_manifest.olm_apply]
for_each = data.kubectl_file_documents.final.manifests
wait = true
yaml_body = each.value
}
provider "helm" {
kubernetes {
host = kind_cluster.default.endpoint
cluster_ca_certificate = kind_cluster.default.cluster_ca_certificate
client_certificate = kind_cluster.default.client_certificate
client_key = kind_cluster.default.client_key
}
}
resource "time_sleep" "wait_150_seconds" {
depends_on = [kubectl_manifest.final_apply]
create_duration = "150s"
}
resource "helm_release" "argocd" {
name = "argocd"
depends_on = [time_sleep.wait_150_seconds]
repository = "https://argoproj.github.io/argo-helm"
chart = "argo-cd"
namespace = "argocd"
version = "7.6.7"
create_namespace = true
}
resource "helm_release" "argocd-apps" {
name = "argocd-apps"
repository = "https://argoproj.github.io/argo-helm"
chart = "argocd-apps"
namespace = "argocd"
version = "1.6.2"
values = [
file("argocd/application.yaml")
]
depends_on = [helm_release.argocd]
}