This commit is contained in:
2023-10-23 15:04:05 +02:00
parent 0447808b4a
commit 7a24a173f7
3 changed files with 48 additions and 25 deletions

View File

@@ -26,6 +26,18 @@ locals {
db if db.name == name db if db.name == name
] ]
]) ])
roles = concat(var.roles, var.extentions.postgrest.enable?[{
"name" = "anonymous"
}]:[])
sorted-role-name = reverse(distinct(sort([
for role in local.roles: role.name
])))
sorted-roles = flatten([
for name in local.sorted-role-name: [
for role in local.roles:
role if role.name == name
]
])
} }
@@ -74,3 +86,10 @@ resource "postgresql_database" "my_db" {
connection_limit = -1 connection_limit = -1
allow_connections = true allow_connections = true
} }
resource "postgresql_role" "roles" {
depends_on = [ time_sleep.wait_pg_ready ]
count = length(local.sorted-roles)
name = "${local.sorted-roles[count.index].name}"
}

View File

@@ -6,6 +6,16 @@ metadata:
name: dataset-pg name: dataset-pg
description: null description: null
options: options:
replicas:
default: 1
examples:
- 1
type: integer
domain-name:
default: your_company.com
examples:
- your_company.com
type: string
extentions: extentions:
default: default:
pool: pool:
@@ -112,25 +122,10 @@ options:
type: object type: object
type: object type: object
type: object type: object
storage: sub-domain:
default: 8Gi default: dataset-pg
examples: examples:
- 8Gi - dataset-pg
type: string
issuer:
default: letsencrypt-prod
examples:
- letsencrypt-prod
type: string
ingress-class:
default: traefik
examples:
- traefik
type: string
domain-name:
default: your_company.com
examples:
- your_company.com
type: string type: string
backups: backups:
default: default:
@@ -186,11 +181,11 @@ options:
default: backup-settings default: backup-settings
type: string type: string
type: object type: object
replicas: storage:
default: 1 default: 8Gi
examples: examples:
- 1 - 8Gi
type: integer type: string
databases: databases:
default: [] default: []
items: items:
@@ -200,10 +195,15 @@ options:
type: string type: string
type: object type: object
type: array type: array
sub-domain: issuer:
default: dataset-pg default: letsencrypt-prod
examples: examples:
- dataset-pg - letsencrypt-prod
type: string
ingress-class:
default: traefik
examples:
- traefik
type: string type: string
roles: roles:
default: [] default: []

View File

@@ -18,6 +18,7 @@ locals {
} }
resource "kubectl_manifest" "postgrest_config" { resource "kubectl_manifest" "postgrest_config" {
count = var.extentions.postgrest.enable ? 1:0
yaml_body = <<-EOF yaml_body = <<-EOF
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
@@ -29,9 +30,12 @@ resource "kubectl_manifest" "postgrest_config" {
PGDATABASE: "${var.instance}" PGDATABASE: "${var.instance}"
PGHOST: "${var.instance}-${var.component}-rw.${var.namespace}.svc" PGHOST: "${var.instance}-${var.component}-rw.${var.namespace}.svc"
PGPORT: "5432" PGPORT: "5432"
PGRST_DB_SCHEMA: public
PGRST_DB_ANON_ROLE: anonymous
PGRST_OPENAPI_SERVER_PROXY_URI: "https://${local.prest-dns-name}" PGRST_OPENAPI_SERVER_PROXY_URI: "https://${local.prest-dns-name}"
PGRST_ADMIN_SERVER_PORT: "9000" PGRST_ADMIN_SERVER_PORT: "9000"
API_URL: "https://${local.prest-dns-name}" API_URL: "https://${local.prest-dns-name}"
BASE_URL: "/ui"
EOF EOF
} }