This page shows you how to install AlloyDB Omni and integrate AlloyDB AI in it.
AlloyDB AI is a suite of features included with AlloyDB Omni that let you build enterprise generative AI applications. For more information about the ML functionality of AlloyDB, see Build generative AI applications.
AlloyDB Omni with AlloyDB AI lets you query remote ML models to work with online predictions and text embeddings generated from ML models. AlloyDB Omni with AlloyDB AI can also process vector embeddings from other content such as an image, for example, if you use the google_ml.predict_row
interface and do the translation yourself in the query.
Based on where you want to install AlloyDB Omni with AlloyDB AI, select one of the following options:
Configure your AlloyDB Omni instance to query remote models
If your machine is air-gapped for security reasons, AlloyDB Omni can also query a model that is hosted on the same or any other machine also accessible from the machine where AlloyDB Omni runs.
Before you start querying remote models, enable Vertex AI online predictions in GDC.
Create a Kubernetes secret using the service account key
To create a Kubernetes secret based on the service account key downloaded in the preceding steps, run the following command:
kubectl create secret generic SECRET_NAME \
--from-file=PATH_TO_SERVICE_ACCOUNT_KEY/private-key.json \
-n NAMESPACE
Replace the following:
SECRET_NAME
: the name of the secret used when you create aDBCluster
manifest to enable AlloyDB Omni to access AlloyDB AI features. For example,vertex-ai-key-alloydb
.PATH_TO_SERVICE_ACCOUNT_KEY
: the path to the location where you downloaded theprivate-key.json
service account key.NAMESPACE
: the namespace of the database cluster.
Install the AlloyDB Omni operator
Install the AlloyDB Omni operator using steps listed in Choose a database engine type and create a database cluster.
Create a database cluster with AlloyDB AI
Create a database cluster with AlloyDB AI and set
vertexAIKeyRef
to the Kubernetes secret created in the preceding steps under thegoogleMLExtension
field in theDBCluster
manifest.apiVersion: v1 kind: Secret metadata: name: db-pw-DBCLUSTER_NAME namespace: USER_PROJECT type: Opaque data: DBCLUSTER_NAME: "BASE64_PASSWORD" --- apiVersion: DBENGINE_NAME.dbadmin.gdc.goog/v1 kind: DBCluster metadata: name: DBCLUSTER_NAME namespace: USER_PROJECT spec: primarySpec: adminUser: passwordRef: name: db-pw-DBCLUSTER_NAME features: googleMLExtension: config: vertexAIKeyRef: SECRET_NAME version: "DB_VERSION" resources: memory: DB_MEMORY cpu: DB_CPU disks: - name: DataDisk size: DB_DATA_DISK
Replace the following variables:
DBCLUSTER_NAME
: the name of the database cluster.USER_PROJECT
: the name of the user project where the database cluster will be created.BASE64_PASSWORD
: the base64 encoding of the database's administrator password.DBENGINE_NAME
: the name of the database engine. Set toalloydbomni
.DB_VERSION
: the version of the database engine.DB_MEMORY
: the amount of memory allocated to the database cluster, for example5Gi
.DB_CPU
: the amount of CPUs allocated to the database cluster, for example2
.DB_DATA_DISK
: the amount of space allocated to the database cluster, for example10 Gi
.
Apply the manifest.
kubectl apply -f DB_CLUSTER_YAML
Replace the following:
DB_CLUSTER_YAML
: the name of this database cluster manifest file—for example,alloydb-omni-db-cluster.yaml
.
Verify AlloyDB Omni with AlloyDB AI installation
To verify your installation is successful and uses model prediction, enter the following:
CREATE EXTENSION google_ml_integration CASCADE;
SELECT array_dims(embedding( 'textembedding-gecko@003', 'AlloyDB AI')::real[]);
The output looks similar to the following:
array_dims
------------
[1:768]
(1 row)
In the previous query, the embedding()
call generates embeddings for the input text AlloyDB AI
.
array_dims
returns the dimensions of the array returned by embedding()
.
Since the pre-registered textembedding-gecko
model returns an output with 768 dimensions, the output is [768]
.
What's next
- Run and connect to AlloyDB Omni
- Manage AlloyDB Omni
- Build generative AI applications using AlloyDB AI
- Register and call remote AI models