This commit is contained in:
2023-10-14 13:03:26 +02:00
parent 186b8b9e96
commit 6ed6f28ee3
2 changed files with 209 additions and 88 deletions

View File

@@ -1,17 +1,31 @@
locals { locals {
# postgresqls = merge(flatten([ pg_vars = merge([for pg in var.pg: {
# for pg in var.postgresql: { join("_",["LABEL_pg", pg.namespace, pg.name, pg.dbname]) = join("|",["pg", pg.namespace, pg.name, pg.dbname])
# join("_",["LABEL_pg", pg.namespace, pg.name]) = join("|",["pg", pg.namespace, pg.name]) join("_",["ENGINE_pg", pg.namespace, pg.name, pg.dbname]) = "postgres@dbgate-plugin-postgres"
# join("_",["SERVER_pg", pg.namespace, pg.name]) = join("|",["pg", pg.namespace, pg.name]) join("_",["SERVER_pg", pg.namespace, pg.name, pg.dbname]) = join(".",[pg.name, pg.namespace, "svc"])
# join("_",["ENGINE_pg", pg.namespace, pg.name]) = join("|",["pg", pg.namespace, pg.name]) join("_",["PORT_pg", pg.namespace, pg.name, pg.dbname]) = "5432"
# } join("_",["USER_pg", pg.namespace, pg.name, pg.dbname]) = pg.username
# ])) }]...)
//marias = [] pg_secrets = merge([for pg in var.pg: {
//mongos = [] join("_",["PASSWORD_pg", pg.namespace, pg.name, pg.dbname]) = join("|",["pg", pg.namespace, pg.name, pg.dbname])
//connections = join(",",concat(local.postgresqls, local.marias)) }]...)
connections = "" pg_conns = [for pg in var.pg: join("_",["pg", pg.namespace, pg.name, pg.dbname])]
datas = {}
secrets = {} maria_vars = merge([for m in var.maria: {
join("_",["LABEL_maria", m.namespace, m.name]) = join("|",["maria", m.namespace, pg.name])
join("_",["ENGINE_maria", m.namespace, m.name]) = "mysql@dbgate-plugin-mysql"
join("_",["SERVER_maria", m.namespace, m.name]) = join(".",[m.name, m.namespace, "svc"])
join("_",["PORT_maria", m.namespace, m.name]) = "3306"
join("_",["USER_maria", m.namespace, m.name]) = m.username
}]...)
maria_secrets = merge([for m in var.maria: {
join("_",["PASSWORD_maria", m.namespace, m.name]) = join("|",["maria", m.namespace, m.name, m.dbname])
}]...)
maria_conns = [for m in var.maria: join("_",["maria", m.namespace, m.name])]
connections = join(",",concat(local.pg_conns, local.maria_conns))
connection_vars = merge(local.pg_vars, local.)
connection_secrets = merge(local.pg_secrets)
} }
resource "kubectl_manifest" "dbgate-config" { resource "kubectl_manifest" "dbgate-config" {
@@ -22,7 +36,7 @@ resource "kubectl_manifest" "dbgate-config" {
name: "${var.component}-${var.instance}" name: "${var.component}-${var.instance}"
namespace: "${var.namespace}" namespace: "${var.namespace}"
labels: ${jsonencode(local.common-labels)} labels: ${jsonencode(local.common-labels)}
data: ${jsonencode(local.datas)} data: ${jsonencode(local.connection_vars)}
EOF EOF
} }
@@ -31,5 +45,5 @@ resource "kubernetes_secret_v1" "dbgate-config-secret" {
name = "${var.component}-${var.instance}" name = "${var.component}-${var.instance}"
namespace = var.namespace namespace = var.namespace
} }
data = local.secrets data = local.connection_secrets
} }

View File

@@ -11,92 +11,199 @@ options:
examples: examples:
- traefik - traefik
type: string type: string
images:
default:
dbgate:
pullPolicy: IfNotPresent
registry: docker.io
repository: dbgate/dbgate
tag: 5.2.6-alpine
examples:
- dbgate:
pullPolicy: IfNotPresent
registry: docker.io
repository: dbgate/dbgate
tag: 5.2.6-alpine
properties:
dbgate:
default:
pullPolicy: IfNotPresent
registry: docker.io
repository: dbgate/dbgate
tag: 5.2.6-alpine
properties:
pullPolicy:
default: IfNotPresent
enum:
- Always
- Never
- IfNotPresent
type: string
registry:
default: docker.io
type: string
repository:
default: dbgate/dbgate
type: string
tag:
default: 5.2.6-alpine
type: string
type: object
type: object
app-group: app-group:
default: dev default: dev
examples: examples:
- dev - dev
type: string type: string
storage:
default:
size: 1Gi
accessMode: ReadWriteOnce
type: Filesystem
properties:
type:
enum:
- Filesystem
- Block
type: string
default: Filesystem
accessMode:
enum:
- ReadWriteOnce
- ReadOnlyMany
- ReadWriteMany
type: string
default: ReadWriteOnce
size:
type: string
default: 1Gi
examples:
- size: 1Gi
accessMode: ReadWriteOnce
type: Filesystem
type: object
mongo:
default: []
items:
type: object
properties:
namespace:
type: string
default: ''
name:
type: string
default: ''
dbname:
type: string
default: ''
username:
type: string
default: ''
secret:
type: object
properties:
name:
type: string
default: ''
key:
type: string
default: ''
examples:
- []
type: array
domain-name:
default: your_company.com
examples:
- your_company.com
type: string
redis:
default: []
items:
type: object
properties:
namespace:
type: string
default: ''
name:
type: string
default: ''
secret:
type: object
properties:
name:
type: string
default: ''
key:
type: string
default: ''
examples:
- []
type: array
pg:
default: []
items:
type: object
properties:
namespace:
type: string
default: ''
name:
type: string
default: ''
dbname:
type: string
default: ''
username:
type: string
default: ''
secret:
type: object
properties:
name:
type: string
default: ''
key:
type: string
default: ''
examples:
- []
type: array
sub-domain:
default: dbgate
examples:
- dbgate
type: string
domain: domain:
default: your-company default: your-company
examples: examples:
- your-company - your-company
type: string type: string
sub-domain: images:
default: dbgate
examples:
- dbgate
type: string
storage:
default: default:
accessMode: ReadWriteOnce dbgate:
size: 1Gi registry: docker.io
type: Filesystem repository: dbgate/dbgate
examples: tag: 5.2.6-alpine
- accessMode: ReadWriteOnce pullPolicy: IfNotPresent
size: 1Gi
type: Filesystem
properties: properties:
accessMode: dbgate:
default: ReadWriteOnce properties:
enum: pullPolicy:
- ReadWriteOnce enum:
- ReadOnlyMany - Always
- ReadWriteMany - Never
type: string - IfNotPresent
size: type: string
default: 1Gi default: IfNotPresent
type: string registry:
type: type: string
default: Filesystem default: docker.io
enum: repository:
- Filesystem type: string
- Block default: dbgate/dbgate
type: string tag:
type: object type: string
domain-name: default: 5.2.6-alpine
default: your_company.com type: object
default:
registry: docker.io
repository: dbgate/dbgate
tag: 5.2.6-alpine
pullPolicy: IfNotPresent
examples: examples:
- your_company.com - dbgate:
type: string registry: docker.io
repository: dbgate/dbgate
tag: 5.2.6-alpine
pullPolicy: IfNotPresent
type: object
maria:
default: []
items:
type: object
properties:
namespace:
type: string
default: ''
name:
type: string
default: ''
username:
type: string
default: ''
secret:
type: object
properties:
name:
type: string
default: ''
key:
type: string
default: ''
examples:
- []
type: array
issuer: issuer:
default: letsencrypt-prod default: letsencrypt-prod
examples: examples: