Skip to main content

Fully automated database management

Use this approach when database management is delegated to the NevisDatabase custom resource, reconciled by nevisOperator, to create and manage the database users, grants, and schema. It is the default Kubernetes behavior for component database patterns.

Responsibilities​

The database administrator must:

  • Provide a database service that is reachable from the Kubernetes cluster.
  • Provide a database user with the privileges required by the dbschema job.
  • Store the database credentials in a Kubernetes Secret.
  • Ensure that the database service permits connections from the cluster.

The nevisAdmin 4 Helm chart and the NevisDatabase custom resource, reconciled by nevisOperator, then perform the database preparation and schema migrations.

Install nevisAdmin 4​

Follow Kubernetes-based installation. Configure the chart with the database type, port, host, and root credential Secret. For PostgreSQL, set the database type and port as follows, and configure the host and root credential Secret separately as described in the installation guide:

--set database.type=postgresql \
--set database.port=5432

The root credential is supplied with the chart's database.root settings. The nevisAdmin 4 database credential Secret contains the schema and application users that the chart creates for nevisAdmin 4.

In this approach, the database user supplied to database.root must be allowed to perform all operations required by the chart dbschema job. On PostgreSQL, this includes creating the database, creating roles, and creating the citext extension. On Azure Database for PostgreSQL, extension availability may also require an Azure server allow-list.

Deploy Nevis components​

For each component database pattern:

  1. Configure the database host, port, database name, and connection settings.
  2. Set Database Management to complete.
  3. Provide the root credential and, if needed, optional schema-owner or application-user overrides using the pattern's credential fields or Kubernetes Secret references.
  4. Deploy the project.

The NevisDatabase custom resource, reconciled by nevisOperator, creates the database prerequisites, creates or updates the required users and grants, and runs the schema migration job. During later deployments, it runs the required migrations automatically.

Database credential preservation in complete mode​

When Database Management is set to complete, nevisOperator stores the generated database credentials in Kubernetes Secrets. This behavior does not apply to the schema mode, where credentials are externally provisioned. For complete-mode component databases, backup Secrets are specific to both the component and the effective database name. The database name is stored in the Secret as databaseName. When the database name is DNS-safe and the full Secret name fits Kubernetes naming limits, the database name is included directly in the Secret name. Otherwise, the Secret name uses a stable hash of the component, namespace, and database identity so that different database names cannot overwrite or reuse one another's backups.

This allows the operator to preserve generated credentials when a deployment switches from database A to database B and later returns to database A. The same behavior applies after a database root password rotation, because the existing database-specific credentials take precedence over newly generated values.

During an upgrade, the operator automatically creates a database-specific backup Secret from an existing component-level backup Secret. Because a legacy Secret has no database identity, the operator reuses it for a seamless migration instead of replacing credentials that may not work for the existing database. The operator treats the legacy Secret as read-only and does not overwrite it. The operator emits the following warning events during migration:

  • LegacyBackupCredentials means that a legacy backup was reused and migrated.
  • UnassociatedLegacyBackupCredentials means that a legacy backup was found but could not be read or associated with a database by the operator, so it was not reused.

If the operator emits UnassociatedLegacyBackupCredentials, review the database name and the root credential Secret before retrying the deployment. Do not manually rename a legacy backup Secret.

Trade-offs​

This is the simplest operational model and requires the least manual preparation. It is not suitable when the application deployment is not allowed to hold a privileged database credential or to change database roles.