openeverest-database-tools

by unxwares-sac

Helm chartv2026.11.6App 1.17.0MITVerified publisher

Jobs that wait for an OpenEverest DatabaseCluster to be ready, then create PostgreSQL, MySQL and MongoDB databases, users, grants and run init scripts.

About this chart

OpenEverest Database Tools Helm Chart

Database initialization Jobs for OpenEverest by UnxWares. Each Job waits until an OpenEverest DatabaseCluster is ready, then creates databases, users and grants and runs your init scripts on PostgreSQL, MySQL (Percona XtraDB Cluster) or MongoDB (Percona Server for MongoDB).

Features

  • PostgreSQL, MySQL and MongoDB: one Job per entry, any number of entries per engine.
  • Waits for the cluster: kubectl wait init containers block until the DatabaseCluster exists and reports status.status: ready, then the client retries until the admin user can log in.
  • Idempotent: databases and users are created when missing, grants are re-applied and user passwords are re-synced from their Secret. Running a Job twice is harmless.
  • Small, patched images: the UnxWares client images (psql, mysql and mongosh alone, rebuilt twice a week, signed, see images/) and the distroless registry.k8s.io/kubectl; nothing is installed when the Job starts, every image is scanned by Artifact Hub.
  • Tested end to end: in CI, the Jobs run against real PostgreSQL, MySQL and MongoDB servers, then the application users log in and their rights and the init scripts are checked, before and after a password rotation.
  • Injection-safe: usernames and passwords stay in Secrets and environment variables, never in SQL or JavaScript text. Database, collection, role and privilege names are validated when rendering.
  • Least privilege: a dedicated ServiceAccount that can only read DatabaseClusters, its token mounted only into the wait containers; non-root (uid 65532), read-only root filesystem, every capability dropped, seccomp RuntimeDefault.
  • Upgrade-friendly: Job names carry a hash of their settings, so helm upgrade never hits the immutable Job spec and a changed Job runs again. Argo CD hook annotations are added by default.

Requirements

Kubernetes: >=1.27.0-0

  • OpenEverest 1.x (tested with 1.17.0): the Jobs wait on databaseclusters.everest.percona.com (API v1alpha1).
  • The Jobs, their ConfigMaps and RBAC are created in global.namespace (default everest-databases), which must be a namespace managed by OpenEverest holding the DatabaseClusters and their credential Secrets. Leave it empty to use the release namespace.
  • The nodes must be able to pull from ghcr.io and registry.k8s.io (or your mirror, see image.*), on amd64 or arm64.

Installation

helm repo add unxwares https://helm.unxwares.studio
helm repo update
helm install db-tools unxwares/openeverest-database-tools \
  --namespace everest-databases \
  --set global.namespace=everest-databases \
  -f my-databases.yaml

Packages are signed with the UnxWares Helm Charts key (7902 E52E A435 EF27 C643 2E53 78D6 B532 C599 DA9B):

curl -fsSL https://helm.unxwares.studio/pgp-public-key.asc | gpg --import
gpg --export 7902E52EA435EF27C6432E5378D6B532C599DA9B > ~/.gnupg/unxwares-helm.gpg
helm install db-tools unxwares/openeverest-database-tools --namespace everest-databases \
  --verify --keyring ~/.gnupg/unxwares-helm.gpg -f my-databases.yaml

The chart deploys nothing long-running: once the Jobs succeed, check their logs (see Troubleshooting).

Architecture

ResourceNamePurpose
Job, one per entry<name>-<hash>Waits for the DatabaseCluster, then runs the client. The hash covers the entry's settings.
ConfigMap, one per entry<name>-<hash>The generated SQL or JavaScript and your init scripts. No credentials.
ServiceAccount<release>-openeverest-database-toolsIdentity of the Jobs (rbac.create), or rbac.serviceAccountName.
Role and RoleBinding<release>-openeverest-database-toolsget, list and watch on databaseclusters.everest.percona.com, nothing else.

All of them are created in global.namespace. Each Job pod has:

  • two init containers, wait-cluster-created and wait-cluster-ready (kubectl), the only ones with the API token, through a projected volume;
  • the client container (init-postgresql, init-mariadb or init-mongodb) with the ConfigMap on /scripts and an in-memory emptyDir on /tmp (its HOME).

How a Job runs

For every entry of databases.postgresql, databases.mysql and databases.mongodb the chart renders a ConfigMap (the generated SQL/JavaScript and your init scripts) and a Job named <name>-<hash>:

  1. wait-cluster-created and wait-cluster-ready (kubectl) wait up to waitTimeoutSeconds each for the DatabaseCluster to exist, then to be ready. Disable them with waitForCluster: false.
  2. The client container retries the admin login for up to connectTimeoutSeconds, then: creates the databases, creates or updates every user of users with its grants, creates the MongoDB collections, and runs each entry of initScripts in order.

The admin credentials come from adminCredentialsSecret; each user comes from its own credentialsSecret (keys username and password by default).

Images

EngineDefault imageAlternative
PostgreSQLghcr.io/unxwares/postgresql-client:18 (psql of the latest PostgreSQL 18 release)docker.io/library/postgres:<version>-alpine
MySQLghcr.io/unxwares/mysql-client:8.4 (Oracle MySQL client of the latest 8.4 release)docker.io/library/mysql:8.4.x
MongoDBghcr.io/unxwares/mongosh:<version> (official mongosh release)docker.io/library/mongo:<version>
Wait containersregistry.k8s.io/kubectl:<version> (distroless)

The UnxWares images hold the client alone instead of a whole database server image, run as uid 65532 and are rebuilt twice a week on current bases, signed with cosign (sources and verification command in images/). The mongosh image keeps the SBOM of the release, so scanners also see the dependencies mongosh bundles. Known vulnerabilities are tracked daily in the CVE watch issue.

Each image is a {repository, tag, digest} object; the digest takes precedence over the tag. An entry can override its engine image with image; an entry that sets its own repository or tag without a digest does not inherit the digest of the engine image:

image:
  postgresql:
    repository: docker.io/library/postgres
    tag: 18.6-alpine
  mysql:
    digest: sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef

Configuration

Entries

Keys of each entry of databases.postgresql, databases.mysql and databases.mongodb:

KeyEnginesDefaultDescription
nameallrequiredJob name (DNS label). The Job and its ConfigMap are named <name>-<hash>.
clusterNameallrequiredName of the OpenEverest DatabaseCluster to wait for.
adminCredentialsSecretallrequiredSecret with the admin credentials (credentialsSecret is accepted as an alias).
hostKeyallpgbouncer-host / host / hostKey of the host in the admin Secret.
hostallLiteral host, takes precedence over hostKey (e.g. my-mysql-haproxy).
portall5432 / 3306 / 27017Port.
userKeyalluserKey of the admin username in the admin Secret.
adminUserallLiteral admin username, takes precedence over userKey (e.g. root).
passwordKeyallpasswordKey of the admin password in the admin Secret.
databasesall[]Databases to create (letters, digits, _, -).
users[].credentialsSecretallrequiredSecret holding the user credentials.
users[].usernameKey / users[].passwordKeyallusername / passwordKeys in that Secret.
users[].databasesall[]Databases the user gets access to (PostgreSQL: owner; MySQL: grants; MongoDB: roles).
users[].privilegesMySQL[ALL PRIVILEGES]Privileges granted on each database.
users[].rolesMongoDB[readWrite]Roles granted on each database.
initScriptsall[]SQL (PostgreSQL, MySQL) or mongosh JavaScript run in order, after users and grants.
initScriptsDatabasealladmin database / none / first databaseDatabase the init scripts run in.
sslModePostgreSQL, MySQLrequire / PREFERREDlibpq sslmode or MySQL --ssl-mode.
adminDatabasePostgreSQLpostgresDatabase the admin connects to.
authDatabaseMongoDBadminAuthentication database of the admin user.
uriOptionsMongoDBExtra connection string options, e.g. replicaSet=rs0&tls=true.
collections[]MongoDB[]name + database of collections to create.
imageallimage.<engine>Client image: full reference string or {repository, tag, digest}.
env, extraEnvall[]Extra environment variables of the client container.
resourcesallresourcesResources of every container of the Job.
labels, annotations, podAnnotationsall{}Extra Job labels (also on the pod), Job annotations and pod annotations.
ttlSecondsAfterFinished, backoffLimit, restartPolicy, activeDeadlineSecondsallglobal.*Job settings.
waitForCluster, waitTimeoutSeconds, connectTimeoutSeconds, updateUserPasswordsallglobal.*Wait, connection and password settings.

Global settings

global.* sets the defaults of every entry: namespace (where the Jobs, ConfigMaps and RBAC go), ttlSecondsAfterFinished (180 s; null keeps finished Jobs), backoffLimit (5), restartPolicy (OnFailure), activeDeadlineSeconds, waitForCluster, waitTimeoutSeconds (300 s per wait step), connectTimeoutSeconds (120 s of login retries) and updateUserPasswords (reset existing users to the password of their Secret).

RBAC

With rbac.create: true (default) the chart creates the ServiceAccount, Role and RoleBinding above. With rbac.create: false, set rbac.serviceAccountName to an account that can get, list and watch databaseclusters.everest.percona.com in global.namespace, or set global.waitForCluster: false.

Resources and scheduling

resources applies to every container (10m CPU and 64 Mi requested, 512 Mi memory limit), and an entry can override it. nodeSelector, tolerations, affinity, priorityClassName and imagePullSecrets apply to every Job pod; labels, annotations, podAnnotations and extraEnv add to all of them.

Argo CD

With global.argocd.enabled (default), the Jobs carry argocd.argoproj.io/hook: Sync, hook-delete-policy: HookSucceeded and sync-options: Replace=true: Argo CD runs them on every sync and deletes them once they succeed. Set global.argocd.enabled: false to manage them as plain resources.

Without Argo CD, Helm keeps the Jobs as release resources: an unchanged Job keeps its name (helm upgrade recreates it, and it runs again, once ttlSecondsAfterFinished has deleted it), a changed one gets a new name and runs again. Either way the Job spec is never patched, so upgrades cannot fail on its immutability.

Examples

PostgreSQL

OpenEverest stores the postgres superuser in everest-secrets-<cluster> with the keys the chart expects by default (pgbouncer-host, user, password).

databases:
  postgresql:
    - name: laravel-db-init
      clusterName: my-pg
      adminCredentialsSecret: everest-secrets-my-pg
      databases:
        - laravel-app
      users:
        - credentialsSecret: laravel-app-db   # keys: username, password
          databases:
            - laravel-app
      initScriptsDatabase: laravel-app
      initScripts:
        - CREATE EXTENSION IF NOT EXISTS pg_trgm;
        - CREATE EXTENSION IF NOT EXISTS pgcrypto;

Each user owns its databases and their public schema, which is closed to PUBLIC.

MySQL (Percona XtraDB Cluster)

everest-secrets-<cluster> holds the root password under the key root; the cluster is reached through its HAProxy (or ProxySQL) service.

databases:
  mysql:
    - name: wordpress-db-init
      clusterName: my-mysql
      adminCredentialsSecret: everest-secrets-my-mysql
      host: my-mysql-haproxy
      adminUser: root
      passwordKey: root
      databases:
        - wordpress
      users:
        - credentialsSecret: wordpress-db
          databases:
            - wordpress
          privileges:       # default: ALL PRIVILEGES
            - SELECT
            - INSERT
            - UPDATE
            - DELETE
            - CREATE
            - ALTER
            - INDEX
            - DROP

MongoDB (Percona Server for MongoDB)

The admin user needs userAdmin on the target databases to manage users, and readWrite to create collections and run initScripts. With the system users kept in everest-secrets-<cluster>, use for example MONGODB_USER_ADMIN_USER/MONGODB_USER_ADMIN_PASSWORD for users and MONGODB_DATABASE_ADMIN_* for collections and scripts (two entries), or a dedicated admin user with both.

databases:
  mongodb:
    - name: app-mongo-users
      clusterName: my-mongo
      adminCredentialsSecret: everest-secrets-my-mongo
      host: m

Deploy openeverest-database-tools with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has openeverest-database-tools on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartopeneverest-database-tools is pinned at v2026.11.6 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply