openeverest-database-tools
by unxwares-sac
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 waitinit containers block until theDatabaseClusterexists and reportsstatus.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,mysqlandmongoshalone, rebuilt twice a week, signed, see images/) and the distrolessregistry.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 upgradenever 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(APIv1alpha1). - The Jobs, their ConfigMaps and RBAC are created in
global.namespace(defaulteverest-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.ioandregistry.k8s.io(or your mirror, seeimage.*), 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
| Resource | Name | Purpose |
|---|---|---|
| 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-tools | Identity of the Jobs (rbac.create), or rbac.serviceAccountName. |
| Role and RoleBinding | <release>-openeverest-database-tools | get, 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-createdandwait-cluster-ready(kubectl), the only ones with the API token, through a projected volume; - the client container (
init-postgresql,init-mariadborinit-mongodb) with the ConfigMap on/scriptsand an in-memoryemptyDiron/tmp(itsHOME).
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>:
wait-cluster-createdandwait-cluster-ready(kubectl) wait up towaitTimeoutSecondseach for the DatabaseCluster to exist, then to beready. Disable them withwaitForCluster: false.- The client container retries the admin login for up to
connectTimeoutSeconds, then: creates thedatabases, creates or updates every user ofuserswith its grants, creates the MongoDBcollections, and runs each entry ofinitScriptsin order.
The admin credentials come from adminCredentialsSecret; each user comes from its own credentialsSecret
(keys username and password by default).
Images
| Engine | Default image | Alternative |
|---|---|---|
| PostgreSQL | ghcr.io/unxwares/postgresql-client:18 (psql of the latest PostgreSQL 18 release) | docker.io/library/postgres:<version>-alpine |
| MySQL | ghcr.io/unxwares/mysql-client:8.4 (Oracle MySQL client of the latest 8.4 release) | docker.io/library/mysql:8.4.x |
| MongoDB | ghcr.io/unxwares/mongosh:<version> (official mongosh release) | docker.io/library/mongo:<version> |
| Wait containers | registry.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:
| Key | Engines | Default | Description |
|---|---|---|---|
name | all | required | Job name (DNS label). The Job and its ConfigMap are named <name>-<hash>. |
clusterName | all | required | Name of the OpenEverest DatabaseCluster to wait for. |
adminCredentialsSecret | all | required | Secret with the admin credentials (credentialsSecret is accepted as an alias). |
hostKey | all | pgbouncer-host / host / host | Key of the host in the admin Secret. |
host | all | Literal host, takes precedence over hostKey (e.g. my-mysql-haproxy). | |
port | all | 5432 / 3306 / 27017 | Port. |
userKey | all | user | Key of the admin username in the admin Secret. |
adminUser | all | Literal admin username, takes precedence over userKey (e.g. root). | |
passwordKey | all | password | Key of the admin password in the admin Secret. |
databases | all | [] | Databases to create (letters, digits, _, -). |
users[].credentialsSecret | all | required | Secret holding the user credentials. |
users[].usernameKey / users[].passwordKey | all | username / password | Keys in that Secret. |
users[].databases | all | [] | Databases the user gets access to (PostgreSQL: owner; MySQL: grants; MongoDB: roles). |
users[].privileges | MySQL | [ALL PRIVILEGES] | Privileges granted on each database. |
users[].roles | MongoDB | [readWrite] | Roles granted on each database. |
initScripts | all | [] | SQL (PostgreSQL, MySQL) or mongosh JavaScript run in order, after users and grants. |
initScriptsDatabase | all | admin database / none / first database | Database the init scripts run in. |
sslMode | PostgreSQL, MySQL | require / PREFERRED | libpq sslmode or MySQL --ssl-mode. |
adminDatabase | PostgreSQL | postgres | Database the admin connects to. |
authDatabase | MongoDB | admin | Authentication database of the admin user. |
uriOptions | MongoDB | Extra connection string options, e.g. replicaSet=rs0&tls=true. | |
collections[] | MongoDB | [] | name + database of collections to create. |
image | all | image.<engine> | Client image: full reference string or {repository, tag, digest}. |
env, extraEnv | all | [] | Extra environment variables of the client container. |
resources | all | resources | Resources of every container of the Job. |
labels, annotations, podAnnotations | all | {} | Extra Job labels (also on the pod), Job annotations and pod annotations. |
ttlSecondsAfterFinished, backoffLimit, restartPolicy, activeDeadlineSeconds | all | global.* | Job settings. |
waitForCluster, waitTimeoutSeconds, connectTimeoutSeconds, updateUserPasswords | all | global.* | 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartopeneverest-database-tools is pinned at v2026.11.6 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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