-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.tf
60 lines (49 loc) · 1.46 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
## https://registry.terraform.io/providers/fluxcd/flux/latest/docs/data-sources/sync
data "flux_install" "main" {
target_path = var.flux_target_path
network_policy = var.flux_network_policy_enabled
version = var.flux_version
namespace = var.namespace
registry = var.registry
image_pull_secrets = var.image_pull_secrets
components = toset(var.components)
log_level = var.log_level
}
data "flux_sync" "main" {
target_path = var.flux_target_path
url = var.git_url
branch = var.git_branch
interval = var.sync_interval
namespace = var.namespace
}
data "kubectl_file_documents" "install" {
content = data.flux_install.main.content
}
data "kubectl_file_documents" "sync" {
content = data.flux_sync.main.content
}
resource "kubernetes_namespace" "flux_system" {
metadata {
name = var.namespace
labels = var.namespace_labels
}
lifecycle {
ignore_changes = [
metadata[0].labels,
]
}
}
resource "kubectl_manifest" "apply" {
for_each = { for v in data.kubectl_file_documents.install.documents : sha1(v) => v }
depends_on = [kubernetes_namespace.flux_system]
yaml_body = each.value
}
# Apply manifests on the cluster
resource "kubectl_manifest" "sync" {
for_each = { for v in data.kubectl_file_documents.sync.documents : sha1(v) => v }
depends_on = [
kubectl_manifest.apply,
kubernetes_namespace.flux_system
]
yaml_body = each.value
}