-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnifi-registry.tf
94 lines (80 loc) · 3.45 KB
/
nifi-registry.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
locals {
nifi_registry_name = "nifi-registry"
nifi_registry_svc_port = 80
}
resource "kubernetes_service_account" "nifi_registry" {
count = var.enable_nifi_registry ? 1 : 0
metadata {
name = "nifi-registry"
namespace = var.nifi_registry_namespace
annotations = var.nifi_registry_sa_annotations
}
automount_service_account_token = true
depends_on = [
kubernetes_namespace.nifikop
]
}
resource "kubernetes_secret" "nifi_registry_secret" {
count = var.enable_nifi_registry ? 1 : 0
metadata {
name = "nifi-registry-secret"
namespace = var.nifi_registry_namespace
}
data = {
"ssh-key" = "%{if var.nifi_registry_git_config.ssh_key_path != ""}${base64encode(file(var.nifi_registry_git_config.ssh_key_path))}%{else}%{endif}"
"db-pass" = var.nifi_registry_database_config.password
"db-ssl-cert" = var.nifi_registry_database_ssl_config.cert
"db-ssl-private-key" = var.nifi_registry_database_ssl_config.private_key
"db-ssl-server-ca-cert" = var.nifi_registry_database_ssl_config.server_ca_cert
}
depends_on = [
kubernetes_namespace.nifikop
]
}
locals {
deployment_manifest = templatefile("${path.module}/kubernetes/nifi-registry/deployment.yaml.tpl", {
// Deployment configuration
name = local.nifi_registry_name
backend = var.nifi_registry_backend
namespace = var.nifi_registry_namespace
service-account-name = var.enable_nifi_registry ? kubernetes_service_account.nifi_registry[0].metadata[0].name : ""
container-image = var.nifi_registry_image
container-port = var.nifi_registry_container_port
node-selector-node-pool = var.nifi_registry_node_selector_node_pool
secret-name = var.enable_nifi_registry ? kubernetes_secret.nifi_registry_secret[0].metadata[0].name : ""
// External Git storage
git-config-user-email = var.nifi_registry_git_config.user_email
git-remote-url = var.nifi_registry_git_config.remote_url
git-remote-branch = var.nifi_registry_git_config.remote_branch
git-remote-to-push = var.nifi_registry_git_config.remote_to_push
ssh-known-hosts = "%{if var.nifi_registry_git_config.ssh_known_hosts_path != ""}${base64encode(file(var.nifi_registry_git_config.ssh_known_hosts_path))}%{else}%{endif}"
// External DB storage
db-url = var.nifi_registry_database_config.url
db-class = var.nifi_registry_database_config.driver_class
db-user = var.nifi_registry_database_config.user
sidecars = flatten([for sidecar in var.nifi_registry_sidecars : indent(10,yamlencode(sidecar))])
})
svc_manifest = templatefile("${path.module}/kubernetes/nifi-registry/svc.yaml.tpl", {
annotations = var.nifi_registry_svc_annotations
namespace = var.nifi_registry_namespace
target-port = var.nifi_registry_container_port
app-label = local.nifi_registry_name
service-type = var.nifi_registry_service_type
port = local.nifi_registry_svc_port
})
}
resource "k8s_manifest" "nifi_registry_deployment" {
count = var.enable_nifi_registry ? 1 : 0
content = local.deployment_manifest
depends_on = [
kubernetes_service_account.nifi_registry,
kubernetes_secret.nifi_registry_secret
]
}
resource "k8s_manifest" "nifi_registry_svc" {
count = var.enable_nifi_registry ? 1 : 0
content = local.svc_manifest
depends_on = [
k8s_manifest.nifi_registry_deployment
]
}