-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.tf
212 lines (186 loc) · 6.36 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
module "sharing-io" {
source = "./terraform/equinix-metal-talos-cluster"
cluster_name = "sharing-io"
kube_apiserver_domain = "k8s.sharing.io"
equinix_metal_project_id = var.equinix_metal_project_id
equinix_metal_metro = local.metro
equinix_metal_auth_token = var.equinix_metal_auth_token
talos_version = local.talos_version
kubernetes_version = local.kubernetes_version
ipxe_script_url = local.ipxe_script_url
controlplane_nodes = 3
talos_install_image = local.talos_install_image
providers = {
talos = talos
helm = helm
equinix = equinix
}
}
module "sharing-io-record-apiserver-ip" {
source = "./terraform/rfc2136-record-assign"
zone = "sharing.io."
name = "k8s"
addresses = [module.sharing-io.cluster_apiserver_ip]
providers = {
dns = dns
}
depends_on = [module.sharing-io]
}
module "sharing-io-record-ingress-ip" {
source = "./terraform/rfc2136-record-assign"
zone = "sharing.io."
name = "*"
addresses = [module.sharing-io.cluster_ingress_ip]
providers = {
dns = dns
}
depends_on = [module.sharing-io]
}
module "sharing-io-record-dns-ip" {
source = "./terraform/rfc2136-record-assign"
zone = "sharing.io."
name = "dns"
addresses = [module.sharing-io.cluster_dns_ip]
providers = {
dns = dns
}
depends_on = [module.sharing-io]
}
resource "powerdns_zone" "try" {
name = "try.sharing.io."
kind = "Native"
nameservers = ["ns1.sharing.io.", "ns2.sharing.io."]
}
resource "powerdns_record" "try-A" {
zone = "try.sharing.io."
name = "try.sharing.io."
type = "A"
ttl = 300
records = [module.sharing-io.cluster_ingress_ip]
depends_on = [powerdns_zone.try]
}
resource "powerdns_record" "try-WILDCARD" {
zone = "try.sharing.io."
name = "*.try.sharing.io."
type = "A"
ttl = 300
records = [module.sharing-io.cluster_ingress_ip]
depends_on = [powerdns_zone.try]
}
resource "powerdns_record" "wg-A" {
# TUNNELD_WIREGUARD_ENDPOINT
zone = "sharing.io."
name = "wg.sharing.io."
type = "A"
ttl = 300
records = [module.sharing-io.cluster_wireguard_ip]
depends_on = [powerdns_zone.try]
}
resource "powerdns_zone" "coder" {
name = "coder.sharing.io."
kind = "Native"
nameservers = ["ns1.sharing.io.", "ns2.sharing.io."]
}
resource "powerdns_record" "coder-A" {
zone = "coder.sharing.io."
name = "coder.sharing.io."
type = "A"
ttl = 300
records = [module.sharing-io.cluster_ingress_ip]
depends_on = [powerdns_zone.coder]
}
resource "powerdns_record" "coder-WILDCARD" {
zone = "coder.sharing.io."
name = "*.coder.sharing.io."
type = "A"
ttl = 300
records = [module.sharing-io.cluster_ingress_ip]
depends_on = [powerdns_zone.coder]
}
module "sharing-io-record-wireguard-ip" {
source = "./terraform/rfc2136-record-assign"
zone = "sharing.io."
name = "wireguard"
addresses = [module.sharing-io.cluster_wireguard_ip]
providers = {
dns = dns
}
depends_on = [module.sharing-io]
}
resource "local_sensitive_file" "sharingio-kubeconfig" {
content = module.sharing-io.kubeconfig.kubeconfig_raw
filename = "./tmp/sharing-io-kubeconfig"
lifecycle {
ignore_changes = all
}
}
module "sharing-io-manifests" {
source = "./terraform/manifests"
equinix_metal_project_id = var.equinix_metal_project_id
equinix_metal_metro = local.metro
equinix_metal_auth_token = var.equinix_metal_auth_token
ingress_ip = module.sharing-io.cluster_ingress_ip
dns_ip = module.sharing-io.cluster_dns_ip
wg_ip = module.sharing-io.cluster_wireguard_ip
acme_email_address = "acme@ii.coop"
rfc2136_algorithm = "HMACSHA256"
rfc2136_nameserver = var.rfc2136_nameserver
rfc2136_tsig_keyname = var.rfc2136_tsig_keyname
rfc2136_tsig_key = var.rfc2136_tsig_key
domain = "sharing.io"
pdns_host = var.pdns_host
pdns_api_key = var.pdns_api_key
# for coder to directly authenticate via github
coder_oauth2_github_client_id = var.coder_oauth2_github_client_id
coder_oauth2_github_client_secret = var.coder_oauth2_github_client_secret
# for coder to create gh tokens for rw within workspaces
coder_gitauth_0_client_id = var.coder_gitauth_0_client_id
coder_gitauth_0_client_secret = var.coder_gitauth_0_client_secret
providers = {
kubernetes = kubernetes.sharing-io
random = random
}
depends_on = [local_sensitive_file.sharingio-kubeconfig, module.sharing-io]
}
module "sharing-io-flux-bootstrap" {
source = "./terraform/flux-bootstrap"
github_org = var.github_org
github_repository = var.github_repository
cluster_name = "sharing.io"
kubeconfig = module.sharing-io.kubeconfig.kubeconfig_raw
providers = {
github = github
flux = flux.sharing-io
}
depends_on = [local_sensitive_file.sharingio-kubeconfig, module.sharing-io-manifests]
}
module "sharing-io-flux-github-webhook" {
source = "./terraform/flux-github-webhook"
repo = var.github_repository
# repo = "${var.github_org}/${var.github_repository}"
domain = "sharing.io"
secret = module.sharing-io-manifests.flux_receiver_token
providers = {
github = github
kubernetes = kubernetes.sharing-io
}
depends_on = [module.sharing-io-manifests]
}
# module "sharing-io-authentik-config" {
# source = "./terraform/authentik-config"
# github_oauth_app_id = var.authentik_github_oauth_app_id
# github_oauth_app_secret = var.authentik_github_oauth_app_secret
# authentik_coder_oidc_client_id = module.sharing-io-manifests.authentik_coder_oidc_client_id
# authentik_coder_oidc_client_secret = module.sharing-io-manifests.authentik_coder_oidc_client_secret
# authentik_bootstrap_token = module.sharing-io-manifests.authentik_bootstrap_token
# # repo = var.github_repository
# # # repo = "${var.github_org}/${var.github_repository}"
# # domain = "sharing.io"
# # secret = module.sharing-io-manifests.flux_receiver_token
# providers = {
# authentik = authentik
# flux = flux
# kubernetes = kubernetes.sharing-io
# }
# depends_on = [module.sharing-io-manifests]
# }