This sample demonstrates how to deploy a Model Registry instance with a PostgreSQL database that has TLS enabled.
The Model Registry operator is configured to watch a specific namespace. Before deploying, you must identify and use the correct namespace.
Check the operator configuration:
kubectl get deployment -n model-registry-operator-system model-registry-operator-controller-manager -o jsonpath='{.spec.template.spec.containers[0].env[?(@.name=="REGISTRIES_NAMESPACE")].value}'This will output the namespace, for example:
model-registry-test
Set your context to this namespace:
kubectl config set-context --current --namespace=model-registry-testNote: For OpenShift AI or Open Data Hub deployments, the typical namespace is
rhoai-model-registriesorodh-model-registries. The operator's admission webhook will reject ModelRegistry CRs created in namespaces other than the configured namespace.
You must generate TLS certificates for the PostgreSQL server. The operator provides a convenient make target to generate test certificates.
From the root of the repository, run:
make certificatesThis will:
- Create test certificates in the
certs/directory - Generate a Kubernetes secret named
model-registry-db-credentialcontaining:ca.crt- Certificate Authority certificatetls.crt- Server certificatetls.key- Server private key
The test certificates use a self-signed CA and are suitable for development and testing only.
NOTE: For production environments, use a proper certificate manager (e.g., cert-manager) to manage certificates and create Kubernetes secrets with the keys
tls.key,tls.crt, andca.crt.
After generating the certificates, deploy the secure PostgreSQL sample:
kubectl apply -k config/samples/secure-db/postgresThis will create:
- A PostgreSQL database deployment with TLS enabled
- A Model Registry instance configured to connect using
sslmode=verify-full - Required secrets and services
The PostgreSQL container is configured with the following TLS settings:
ssl=on- Enables TLS connectionsssl_cert_file=/etc/server-cert/tls.crt- Server certificatessl_key_file=/etc/server-cert/tls.key- Server private keyssl_ca_file=/etc/server-cert/ca.crt- Certificate Authority certificate
The Model Registry is configured to connect to PostgreSQL with:
sslMode: verify-full- Requires TLS and verifies the server certificatesslRootCertificateConfigMap- References the CA certificate for server verification
Check that the Model Registry was created successfully:
kubectl describe mr modelregistry-sampleCheck the Status field for any failed conditions.
To remove the secure PostgreSQL sample:
kubectl delete -k config/samples/secure-db/postgresTo clean up the test certificates:
make certificates/clean- The sample database secret
model-registry-db-credentialcontains the CA cert, server key, and server cert for demonstration purposes. - In production, the Model Registry only needs access to the CA certificate(s).
- The database server should have its own secret containing the private key and server certificate.
- Use a proper certificate management solution for certificate rotation and lifecycle management.