-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcluster-certmanager.tf
executable file
·74 lines (65 loc) · 1.88 KB
/
cluster-certmanager.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
resource "kubernetes_namespace" "cert_manager" {
depends_on = [hcloud_load_balancer_service.management_lb_k8s_service]
count = var.cluster_configuration.cert_manager.preinstall ? 1 : 0
metadata {
name = "cert-manager"
}
lifecycle {
ignore_changes = [
metadata[0].annotations,
metadata[0].labels,
]
}
}
resource "kubernetes_secret" "cert_manager" {
depends_on = [kubernetes_namespace.cert_manager]
count = var.cluster_configuration.cert_manager.preinstall ? 1 : 0
metadata {
name = "cloudflare-api-token-secret"
namespace = "cert-manager"
}
data = {
api-token = var.cloudflare_token
}
lifecycle {
ignore_changes = [
metadata[0].annotations,
]
}
}
resource "helm_release" "cert_manager" {
depends_on = [kubernetes_namespace.cert_manager]
count = var.cluster_configuration.cert_manager.preinstall ? 1 : 0
name = "cert-manager"
# https://cert-manager.io/docs/installation/helm/
repository = "https://charts.jetstack.io"
chart = "cert-manager"
version = var.cluster_configuration.cert_manager.version
namespace = "cert-manager"
set {
name = "installCRDs"
value = "true"
}
}
resource "kubectl_manifest" "cert_manager_issuer" {
depends_on = [kubernetes_secret.cert_manager, helm_release.cert_manager]
count = var.cluster_configuration.cert_manager.use_for_preinstalled_components ? 1 : 0
yaml_body = <<YAML
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: cloudflare
spec:
acme:
email: ${var.letsencrypt_issuer}
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- dns01:
cloudflare:
apiTokenSecretRef:
name: cloudflare-api-token-secret
key: api-token
YAML
}