generated from camptocamp/devops-stack-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocals.tf
82 lines (79 loc) · 3.72 KB
/
locals.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
locals {
domain = format("longhorn.%s", trimprefix("${var.subdomain}.${var.base_domain}", "."))
domain_full = format("longhorn.%s.%s", trimprefix("${var.subdomain}.${var.cluster_name}", "."), var.base_domain)
# Generate a list of tolerations in a string format of `key=value:effect` for all the tolerations that have
# an `operator` equal to `Equal`. This list of strings will be joined to pass as the value of
# `defaultSettings.taintToleration`.
tolerations_list = [for toleration in var.tolerations : "${toleration.key}=${toleration.value}:${toleration.effect}" if toleration.operator == "Equal"]
helm_values = [{
longhorn = {
defaultSettings = {
backupTarget = var.enable_pv_backups ? format("s3://%s@%s/", var.backup_storage.bucket_name, var.backup_storage.region) : ""
backupTargetCredentialSecret = var.enable_pv_backups ? "longhorn-s3-secret" : ""
storageOverProvisioningPercentage = var.storage_over_provisioning_percentage
storageMinimalAvailablePercentage = var.storage_minimal_available_percentage
taintToleration = join(";", local.tolerations_list)
}
persistence = {
defaultClass = tostring(!(var.enable_pv_backups && var.set_default_storage_class))
defaultClassReplicaCount = var.replica_count
recurringJobSelector = {
enable = tostring(var.automatic_filesystem_trim.enabled && !var.set_default_storage_class)
jobList = var.automatic_filesystem_trim.enabled && !var.set_default_storage_class && var.recurring_job_selectors != null ? jsonencode(var.recurring_job_selectors) : null
}
}
longhornManager = {
tolerations = var.tolerations
}
preUpgradeChecker = {
jobEnabled = var.enable_preupgrade_check
}
}
backups = merge({
enabled = var.enable_pv_backups
}, var.enable_pv_backups ? {
defaultStorageClass = var.set_default_storage_class
config = var.backup_configuration
storage = var.backup_storage
} : null)
numberOfReplicas = var.replica_count
oidc = var.oidc != null ? {
oauth2_proxy_image = "quay.io/oauth2-proxy/oauth2-proxy:v7.6.0"
issuer_url = var.oidc.issuer_url
redirect_url = format("https://%s/oauth2/callback", local.domain_full)
client_id = var.oidc.client_id
client_secret = var.oidc.client_secret
cookie_secret = resource.random_string.oauth2_cookie_secret.result
oauth2_proxy_extra_args = var.oidc.oauth2_proxy_extra_args
} : null
ingress = {
enabled = var.enable_dashboard_ingress
hosts = [
local.domain,
local.domain_full
]
annotations = {
"cert-manager.io/cluster-issuer" = "${var.cluster_issuer}"
"traefik.ingress.kubernetes.io/router.entrypoints" = "websecure"
"traefik.ingress.kubernetes.io/router.tls" = "true"
}
}
grafana_dashboard = {
enabled = var.enable_monitoring_dashboard
}
servicemonitor = {
enabled = var.enable_service_monitor
additionalAlertLabels = var.additional_alert_labels
}
automaticFilesystemTrim = {
enabled = var.automatic_filesystem_trim.enabled
cron = var.automatic_filesystem_trim.cron
job_group = var.automatic_filesystem_trim.job_group
}
recurringJobSelector = var.automatic_filesystem_trim.enabled && var.enable_pv_backups && var.set_default_storage_class && var.recurring_job_selectors != null ? jsonencode(var.recurring_job_selectors) : null
}]
}
resource "random_string" "oauth2_cookie_secret" {
length = 32
special = false
}