This commit is contained in:
2023-10-08 09:23:39 +02:00
parent a50f7b2eb7
commit 68efbc818b
4 changed files with 145 additions and 7 deletions

View File

@@ -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

View File

@@ -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
}

View File

@@ -20,11 +20,6 @@ options:
- IfNotPresent - IfNotPresent
type: string type: string
type: object type: object
cacheSizeGB:
default: 1
examples:
- 1
type: integer
ressources: ressources:
default: default:
limits: limits:
@@ -66,6 +61,26 @@ options:
type: string type: string
type: object type: object
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: [] dependencies: []
providers: providers:
kubernetes: true kubernetes: true

View File

@@ -38,9 +38,9 @@ resource "kubectl_manifest" "prj_mongo" {
namespace: "${var.namespace}" namespace: "${var.namespace}"
labels: ${jsonencode(local.mongo-labels)} labels: ${jsonencode(local.mongo-labels)}
spec: spec:
members: 1 members: ${var.replicas}
type: ReplicaSet type: ReplicaSet
version: "4.4.0" version: "${var.mongo.version}"
statefulSet: statefulSet:
spec: spec:
template: template: