From 68efbc818b93be0bf75e81be9ecfcf0160864c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Huss?= Date: Sun, 8 Oct 2023 09:23:39 +0200 Subject: [PATCH] fix --- share/dataset-maria/index.yaml | 61 +++++++++++++++++++++++++++++++++ share/dataset-maria/mariadb.tf | 62 ++++++++++++++++++++++++++++++++++ share/dataset-mongo/index.yaml | 25 +++++++++++--- share/dataset-mongo/mongo.tf | 4 +-- 4 files changed, 145 insertions(+), 7 deletions(-) create mode 100644 share/dataset-maria/index.yaml create mode 100644 share/dataset-maria/mariadb.tf diff --git a/share/dataset-maria/index.yaml b/share/dataset-maria/index.yaml new file mode 100644 index 0000000..3ec4f69 --- /dev/null +++ b/share/dataset-maria/index.yaml @@ -0,0 +1,61 @@ +--- +apiVersion: vinyl.solidite.fr/v1beta1 +kind: Component +category: share +metadata: + name: dataset-maria + description: null +options: + storage: + default: 8Gi + examples: + - 8Gi + type: string + images: + default: + mariadb: + pullPolicy: IfNotPresent + registry: docker.io + repository: mariadb + tag: 10.7.4 + examples: + - mariadb: + pullPolicy: IfNotPresent + registry: docker.io + repository: mariadb + tag: 10.7.4 + properties: + mariadb: + default: + pullPolicy: IfNotPresent + registry: docker.io + repository: mariadb + tag: 10.7.4 + properties: + pullPolicy: + default: IfNotPresent + enum: + - Always + - Never + - IfNotPresent + type: string + registry: + default: docker.io + type: string + repository: + default: mariadb + type: string + tag: + default: 10.7.4 + type: string + type: object + type: object +dependencies: [] +providers: + kubernetes: true + authentik: null + kubectl: true + postgresql: null + restapi: null + http: null +tfaddtype: null diff --git a/share/dataset-maria/mariadb.tf b/share/dataset-maria/mariadb.tf new file mode 100644 index 0000000..7a68329 --- /dev/null +++ b/share/dataset-maria/mariadb.tf @@ -0,0 +1,62 @@ +locals { + maria-labels = merge(local.common-labels, { + "app.kubernetes.io/component" = "mariadb" + }) + mariadb-password = data.kubernetes_secret_v1.prj_mariadb_secret.data["password"] +} +resource "kubectl_manifest" "prj_mariadb_secret" { + ignore_fields = ["metadata.annotations"] + yaml_body = <<-EOF + apiVersion: "secretgenerator.mittwald.de/v1alpha1" + kind: "StringSecret" + metadata: + name: "${var.instance}-${var.component}" + namespace: "${var.namespace}" + labels: ${jsonencode(local.maria-labels)} + spec: + forceRegenerate: false + data: + username: "${var.instance}" + fields: + - fieldName: "password" + length: "32" + - fieldName: "root-password" + length: "32" + EOF +} +data "kubernetes_secret_v1" "prj_mariadb_secret" { + depends_on = [ kubectl_manifest.prj_mariadb_secret ] + metadata { + name = "${var.instance}-${var.component}" + namespace = var.namespace + } +} +resource "kubectl_manifest" "prj_mariadb" { + yaml_body = <<-EOF + apiVersion: mariadbdbcommunity.mariadbdb.com/v1 + kind: mariadbDBCommunity + metadata: + name: "${var.instance}-${var.component}" + namespace: "${var.namespace}" + labels: ${jsonencode(local.mariadb-labels)} + spec: + database: "${var.instance}" + image: + pullPolicy: "${var.images.mariadb.pullPolicy}" + repository: "${var.images.mariadb.registry}/${var.images.mariadb.repository}" + tag: "${var.images.mariadb.tag}" + passwordSecretKeyRef: + key: password + name: "${var.instance}-${var.component}" + rootPasswordSecretKeyRef: + key: root-password + name: "${var.instance}-${var.component}" + username: "${var.instance}" + volumeClaimTemplate: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "${var.storage}" + EOF +} diff --git a/share/dataset-mongo/index.yaml b/share/dataset-mongo/index.yaml index 027c792..84642af 100644 --- a/share/dataset-mongo/index.yaml +++ b/share/dataset-mongo/index.yaml @@ -20,11 +20,6 @@ options: - IfNotPresent type: string type: object - cacheSizeGB: - default: 1 - examples: - - 1 - type: integer ressources: default: limits: @@ -66,6 +61,26 @@ options: type: string type: object type: object + cacheSizeGB: + default: 1 + examples: + - 1 + type: integer + replicas: + default: 1 + examples: + - 1 + type: integer + mongo: + default: + version: 4.4.0 + examples: + - version: 4.4.0 + properties: + version: + default: 4.4.0 + type: string + type: object dependencies: [] providers: kubernetes: true diff --git a/share/dataset-mongo/mongo.tf b/share/dataset-mongo/mongo.tf index 25af9be..03a3ec5 100644 --- a/share/dataset-mongo/mongo.tf +++ b/share/dataset-mongo/mongo.tf @@ -38,9 +38,9 @@ resource "kubectl_manifest" "prj_mongo" { namespace: "${var.namespace}" labels: ${jsonencode(local.mongo-labels)} spec: - members: 1 + members: ${var.replicas} type: ReplicaSet - version: "4.4.0" + version: "${var.mongo.version}" statefulSet: spec: template: