Skip to main content
Enterprise

PostgreSQL Configuration

NetBox Enterprise supports two PostgreSQL deployment modes:

  • Internal (default): Managed by the Crunchy Postgres Operator (PGO), installed as a chart dependency
  • External: Connect to an existing PostgreSQL instance you manage

Internal PostgreSQL (Default)

When postgresql.external: false (the default), the operator deploys a PostgresCluster resource that PGO manages.

KeyTypeDefaultDescription
postgresql.externalboolfalseUse internal PostgreSQL
postgresql.instancesuint81Number of PostgreSQL replicas for redundancy (0–255)
postgresql.versionstring18PostgreSQL major version
postgresql.storageSizestring4GiStorage size for each PostgreSQL instance
postgresql.storageClassNamestringStorage class (uses cluster default if not set)
postgresql.registrystringContainer registry override for PGO images

Example with redundancy:

netboxEnterprise:
spec:
postgresql:
external: false
instances: 2
version: "18"
storageSize: "20Gi"

PGO automatically handles:

  • Database creation (netbox, diode, hydra databases)
  • User management and credential rotation
  • Replication between primary and replica instances
  • Failover and recovery

The operator detects PGO password rotations automatically using resourceVersion-based change detection and triggers rolling updates without reading sensitive secret data.

External PostgreSQL

Set postgresql.external: true to use an externally managed PostgreSQL instance.

netboxEnterprise:
spec:
postgresql:
external: true

When using an external database, you must provide connection details through netbox.config.postgres:

netboxEnterprise:
spec:
netbox:
config:
postgres:
database: "netbox"
user: "netbox"
password:
name: netbox-db-credentials
key: password

Host and port are configured via postgresqlProfiles (see below).

You can disable PGO entirely when using an external database:

pgo:
enabled: false

See the External Database Guide for a complete step-by-step walkthrough.

PostgreSQL Profiles

When multiple components (NetBox, Diode, Hydra) connect to the same PostgreSQL server, define a named profile in postgresqlProfiles so connection details and TLS settings are specified once:

netboxEnterprise:
spec:
postgresqlProfiles:
netbox:
host: "postgres.example.com"
port: 5432
tlsConfig:
sslmode: verify-full
keychainCaCertificates:
- postgres-ca

postgresql:
external: true
postgresqlProfile: netbox

diode:
config:
reconciler:
postgres:
postgresqlProfile: netbox
password:
name: diode-db-credentials
key: password
hydra:
postgresqlProfile: netbox

Each component references the profile by name and provides only its own password secret. See the NetBoxEnterprise CRD for the full profile field reference.

TLS Configuration

TLS for PostgreSQL connections is configured through postgresqlProfiles:

KeyTypeDefaultDescription
postgresqlProfiles.<name>.tlsConfig.sslmodeenumpreferSSL mode for connections
postgresqlProfiles.<name>.tlsConfig.insecureSkipVerifyboolfalseSkip TLS verification (dev only)
postgresqlProfiles.<name>.tlsConfig.keychainCaCertificateslistCA certificate names from tlsKeychain
postgresqlProfiles.<name>.tlsConfig.keychainClientCertificatestringClient certificate name from tlsKeychain

SSL Modes

ModeDescription
disableNo SSL
allowTry non-SSL first, then SSL
preferTry SSL first, then non-SSL (default)
requireSSL required, no certificate verification
verify-caSSL required, verify server CA
verify-fullSSL required, verify CA and hostname
note

When CA certificates are configured via keychainCaCertificates, libpq verifies the server certificate even with sslmode: require (effectively upgrading it to verify-ca behavior). This is because the operator sets PGSSLROOTCERT when CA certificates are provided. Ensure the CA certificate matches the server, or omit it to use require without verification.

TLS with CA Verification

netboxEnterprise:
spec:
postgresqlProfiles:
netbox:
host: "postgres.example.com"
port: 5432
tlsConfig:
sslmode: verify-ca
keychainCaCertificates:
- my-postgres-ca

postgresql:
external: true
postgresqlProfile: netbox

tlsKeychain:
caCertificateSecrets:
- name: my-postgres-ca
secret: postgres-ca-secret
key: ca.crt

TLS with Client Certificates (mTLS)

netboxEnterprise:
spec:
postgresqlProfiles:
netbox:
host: "postgres.example.com"
port: 5432
tlsConfig:
sslmode: verify-full
keychainCaCertificates:
- my-postgres-ca
keychainClientCertificate: my-client-cert

postgresql:
external: true
postgresqlProfile: netbox

tlsKeychain:
caCertificateSecrets:
- name: my-postgres-ca
secret: postgres-ca-secret
key: ca.crt
clientCertificateSecrets:
- name: my-client-cert
secret: postgres-client-cert
certKey: tls.crt
privateKey: tls.key

Database Users

When using internal PostgreSQL, PGO creates the following database users by default:

UserDatabasePurpose
netboxnetboxNetBox application
diodediodeDiode reconciler (if Diode enabled)
hydrahydraHydra OIDC server (if Diode enabled)

Next Steps