Refacto and add modules

This commit is contained in:
2024-02-06 11:03:20 +01:00
parent 159b576b24
commit bcdf666cc0
47 changed files with 661 additions and 338 deletions

View File

@@ -1,27 +1,30 @@
locals {
app_slug = (var.component == var.instance || var.component=="") ? var.instance : format("%s-%s", var.component, var.instance)
app_slug = "${var.instance}${var.component == "" ? "" : "-"}${var.component}"
pvc_labels = merge(var.labels, {
"app.kubernetes.io/component" = "pvc"
})
pvc_spec = merge({
"accessModes" = [var.storage.accessMode]
"volumeMode" = var.storage.type
"accessModes" = [var.storage.access_mode]
"volumeMode" = var.storage.type
"resources" = {
"requests" = {
"storage" = "${var.storage.size}"
}
}
}, var.storage.volume.class != "" ?{
}, var.storage.class != "" ? {
"storageClassName" = var.storage.class
}:{})
} : {})
}
resource "kubectl_manifest" "pvc" {
yaml_body = <<-EOF
yaml_body = <<-EOF
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${local.app_slug}
namespace: "${var.namespace}"
annotations:
k8up.io/backup: "true"
labels: ${jsonencode(local.labels)}
k8up.io/backup: "${var.backup}"
labels: ${jsonencode(local.pvc_labels)}
spec: ${jsonencode(local.pvc_spec)}
EOF
}