PluginWorks in Claude CodeCurrent
Alloydb omni
Create, connect, and interact with an AlloyDB Omni database and data.
0
Try it
See what this would do for you. No sign-up needed.
Install in Claude Code
Run these in Claude Code, in order. The first adds the marketplace, the second installs the plugin.
Step 1
/plugin marketplace add anthropics/claude-plugins-official
Step 2
/plugin install alloydb-omni@claude-plugins-official
Review commands before running them. Promptu never runs code on your machine or pushes changes to your repo.
What's inside
2 skills
- alloydb-omni-container
- alloydb-omni-kubernetes
1 MCP server
Security scan
Passed
Promptu's text scan of the files it could read didn't match any known risky patterns. It doesn't run the plugin, and a clean scan doesn't mean the plugin is safe.
Automated pattern check of 5 file(s) found nothing risky. Not a full audit.
Details
# AlloyDB Omni
> [!NOTE]
> Currently in beta (pre-v1.0), and may see breaking changes until the first stable release (v1.0).
This repository packages [MCP Toolbox](https://github.com/googleapis/mcp-toolbox)'s prebuilt `alloydb-omni` server as a plugin/extension to interact with [AlloyDB Omni](https://docs.cloud.google.com/alloydb/omni/docs) instances. It can be used with various AI agents, including [Antigravity](https://antigravity.google/), [Claude Code](https://claude.com/product/claude-code) and [Codex](https://developers.openai.com/codex), to manage your databases, execute queries, explore schemas, and troubleshoot issues using natural language prompts.
> [!IMPORTANT]
> **We Want Your Feedback!**
> Please share your thoughts with us by filling out our feedback [form][form].
> Your input is invaluable and helps us improve the project for everyone.
[form]: https://docs.google.com/forms/d/e/1FAIpQLSfEGmLR46iipyNTgwTmIDJqzkAwDPXxbocpXpUbHXydiN1RTw/viewform?usp=pp_url&entry.157487=alloydb-omni
## Table of Contents
- [Why Use AlloyDB Omni?](#why-use-alloydb-omni)
- [Prerequisites](#prerequisites)
- [Getting Started](#getting-started)
- [Configuration](#configuration)
- [Installation & Usage](#installation--usage)
- [Antigravity](#antigravity)
- [Claude Code](#claude-code)
- [Codex](#codex)
- [Installing via a compatible Agent Plugins client](#installing-via-a-compatible-agent-plugins-client)
- [Usage Examples](#usage-examples)
- [Available Tools](#available-tools)
- [Generating Skills Instead](#generating-skills-instead)
- [Troubleshooting](#troubleshooting)
## Why Use AlloyDB Omni?
- **Seamless Workflow:** Integrates seamlessly into your AI agent's environment. No need to constantly switch contexts for common database tasks.
- **Natural Language Queries:** Stop wrestling with complex commands. Explore schemas and query data by describing what you want in plain English.
- **Full Lifecycle Control:** Manage the entire lifecycle of your database, from creating clusters to exploring schemas and running queries.
- **Code Generation:** Accelerate development by asking your agent to generate data classes and other code snippets based on your table schemas.
## Prerequisites
Before you begin, ensure you have the following:
- One of these AI agents installed
- Antigravity
- [Antigravity CLI](https://github.com/google-gemini/gemini-cli) version **v1.6.0** or higher
- [Antigravity 2.0](https://antigravity.google/product/antigravity-2) version **v2.0.0** or higher.
- [Claude Code](https://claude.com/product/claude-code) version **v2.1.94** or higher.
- [Codex](https://developers.openai.com/codex) **v0.117.0** or higher.
- An active AlloyDB Omni instance.
## Getting Started
### Configuration
Please keep these environment variables handy during the installation process:
* `ALLOYDB_OMNI_HOST`: (Optional: localhost by default) The host of your AlloyDB cluster.
* `ALLOYDB_OMNI_PORT`: (Optional: 5432 by default) The port of your AlloyDB cluster.
* `ALLOYDB_OMNI_DATABASE`: The name of the database to connect to.
* `ALLOYDB_OMNI_USER`: The database username.
* `ALLOYDB_OMNI_PASSWORD`: The password for the database user.
* `ALLOYDB_OMNI_QUERY_PARAMS`: (Optional) Additional query parameters.
### Installation & Usage
To start interacting with your database, install the extension for your preferred AI agent, then launch the agent and use natural language to ask questions or perform tasks.
For the latest version, check the [releases page][releases].
[releases]: https://github.com/gemini-cli-extensions/alloydb-omni/releases
<!-- {x-release-please-start-version} -->
<details open>
<summary id="antigravity">Antigravity</summary>
You can use either of these two agents for Antigravity:
- [Antigravity CLI](https://github.com/google-gemini/gemini-cli) version **v0.2.2** or higher
- [Antigravity 2.0](https://antigravity.google/product/antigravity-2) version **v0.2.2** or higher.
<blockquote>
💡 <strong>Tip — Migrating from Gemini CLI?</strong><br>
If you previously installed this extension with <code>gemini extensions install</code>, you can convert it to an Antigravity plugin instead of reinstalling from scratch:
<ul>
<li><strong>On first launch of Antigravity CLI</strong>, accept the Migration Options prompt to automatically convert your installed Gemini CLI extensions to Antigravity plugins.</li>
<li><strong>Or, from your terminal</strong>, run:
<pre><code class="language-bash">agy plugin import gemini</code></pre>
</li>
</ul>
See <a href="https://antigravity.google/docs/gcli-migration">Migrating from Gemini CLI</a> for details on plugins, context files (<code>GEMINI.md</code> / <code>AGENTS.md</code>), and MCP server config differences.
</blockquote>
#### Antigravity 2.0 (IDE)
**1. Install the plugin:**
Install the plugin directly from the remote GitHub repository:
```bash
agy plugin install https://github.com/gemini-cli-extensions/alloydb-omni
```
**2. Set env vars:**
Set your environment vars as described in the [configuration section](#configuration).
_(Tip: You can verify the MCP server is active by running the `/mcp` command in your active session.)_
#### Antigravity CLI
You can install plugins directly from a remote GitHub repository.
**1. Install the plugin:**
```bash
agy plugin install https://github.com/gemini-cli-extensions/alloydb-omni
```
**2. Set env vars:**
Set your environment vars as described in the [configuration section](#configuration).
</details>
<details>
<summary id="claude-code">Claude Code</summary>
**1. Set env vars:**
In your terminal, set your environment vars as described in the [configuration section](#configuration).
**2. Start the agent:**
```bash
claude
```
**3. Install the plugin:**
```bash
/plugin install alloydb-omni@claude-plugins-official
```
_(Tip: Run `/plugin list` inside Claude Code to verify the plugin is active, or `/reload-plugins` if you just installed it.)
</details>
<details>
<summary id="codex">Codex</summary>
**1. Install marketplace:**
```bash
codex plugin marketplace add GoogleCloudPlatform/data-cloud-plugins
```
**2. Install the plugin:**
```bash
codex plugin add alloydb-omni@data-cloud-plugins
```
**3. Set env vars:**
Enter your environment vars as described in the [configuration section](#configuration).
**4. (Optional) Update the marketplace:**
```sh
codex plugin marketplace upgrade data-cloud-plugins
```
</details>
## Installing via a compatible Agent Plugins client
## Installing via a compatible Agent Plugins client
This repository is a valid [Agent Plugins](https://github.com/agentplugins/agent-plugins-spec) (v1) plugin. Any [Agent Plugins–compatible client](https://agent-plugins.org/compatible-clients) can install it directly using its own built-in plugin command — no extra tooling required — by pointing at this repository:
```
https://github.com/gemini-cli-extensions/alloydb-omni
```
Beyond harnesses covered by the native install above, compatible clients include VS Code, Cursor, GitHub Copilot, and Kiro. See your agent's documentation for its exact install command.
**Set env vars:**
Set your environment vars as described in the [configuration section](#configuration).
<!-- {x-release-please-end} -->
## Usage Examples
Interact with AlloyDB Omni using natural language right from your IDE:
* **Provision Infrastructure:**
* "Create a new AlloyDB Omni container with Docker."
* "Show me all the AlloyDB Omni DBClusters on my Kubernetes cluster."
* **Explore Schemas and Data:**
* "Show me all tables in the 'orders' database."
* "What are the columns in the 'products' table?"
* "How many orders were placed in the last 30 days, and what were the top 5 most purchased items?"
* **Generate Code:**
* "Generate a Python dataclass to represent the 'customers' table."
## Available Tools
The tools come from MCP Toolbox's prebuilt `alloydb-omni` server, grouped into toolsets:
- **data** - Use these tools when you need to explore the database structure, identify schema objects like views and triggers, and execute SQL queries to interact with your data.
- **performance** - Use these tools when you need to analyze query performance, generate execution plans, check table/column statistics, and monitor overall database activity.
- **monitor** - Use these tools when you need to troubleshoot production issues by identifying locks, tracking long-running transactions, and getting a high-level view of server state.
- **optimize** - Use these tools when you need to fine-tune the database engine settings, manage extensions, or optimize the columnar engine for better analytical performance.
- **health** - Use these tools when you need to audit database health, identify storage bloat, find broken indexes, and verify tablespace or maintenance configurations.
- **replication** - Use these tools when you need to monitor the health of database replication, manage sync states between nodes, and audit publication tables for distributed setups.
- **access-control** - Use these tools when you need to manage user roles, inspect permissions, and verify security-related configuration parameters.
For the full, up-to-date list, see the [`alloydb-omni` prebuilt config](https://github.com/googleapis/mcp-toolbox/blob/main/internal/prebuiltconfigs/tools/alloydb-omni.yaml)
in the MCP Toolbox repository.
## Generating Skills Instead
The tool-backed skills this plugin used to ship were generated from the same prebuilt
toolsets. If your agent lacks deferred tool loading, or you prefer skills, regenerate
them with the script in this repository:
```bash
VERSION=<toolbox version> ./.github/scripts/generate_skills.sh
```
Use the toolbox version pinned in [`mcp.json`](./mcp.json). A single toolset, without
the script:
```bash
npx @toolbox-sdk/server@<toolbox version> --prebuilt alloydb-omni skills-generate \
--name "<skill name>" \
--toolset "<toolset>" \
--description "<what it is for>"
```
The generated scripts call the toolbox through `npx`, so no binary download is needed.
See [Generate Agent Skills](https://github.com/googleapis/mcp-toolbox#generate-agent-skills)
in the MCP Toolbox repository.
The hand-authored skills in `skills/` are unaffected and still ship with the plugin.
## Troubleshooting
Use the debug mode of your agent (e.g., `gemini --debug`) to enable debugging.
Common issues:
* "✖ Error during discovery for server: MCP error -32000: Connection closed": The database connection has not been established. Ensure your configuration is set via environment variables.
* "✖ MCP ERROR: Error: spawn ... ENOENT": A skill script or dependency might be missing. Ensure you have Node.js installed and have properly installed the extension.
## skills/alloydb-omni-container/SKILL.md
---
name: alloydb-omni-container
description:
You're an expert in AlloyDB Omni running in a container. You can help users with related tasks such as starting, stopping, listing, connecting to AlloyDB Omni instance running in a container, and querying for logs.
---
# Context
You're an experienced sysadmin and database administrator. You're familiar with
container and container runtime technologies such as Docker, Podman, containerd,
etc. You're also familiar with PostgreSQL and AlloyDB for PostgreSQL. Your focus
is to help users with tasks related to AlloyDB Omni running in a container such
as starting, stopping, listing, connecting to AlloyDB Omni instance running in a
container, and querying for logs.
AlloyDB Omni is a downloadable database software package that offers a
streamlined version of AlloyDB for PostgreSQL for deployment in a standalone
instance in your environment. The container deployment model is the most
lightweight and easiest way to get started with AlloyDB Omni, especially for
offline / local development uses. However, this model lacks many high-end
features such as high availability, automated backups, etc. and therefore it's
not appropriate for production workloads.
# Workflows
You have the following workflows:
1. Running a new AlloyDB Omni container.
2. Checking the status of an existing AlloyDB Omni container.
3. Stopping and removing an existing AlloyDB Omni container.
4. Connecting to an existing AlloyDB Omni container.
## Running a new AlloyDB Omni container
1. Ask the user what version of AlloyDB Omni they want to run. If the user
doesn't have a preference, suggest to use the `latest` version, or to refer
to the documentation page for a list of supported versions:
https://docs.cloud.google.com/alloydb/omni/containers/current/docs/overview.
Use this as the `IMAGE_TAG` placeholder.
2. Ask the user for a name for the container. Suggest `alloydb-omni` as a
default. Use this as the `CONTAINER_NAME` placeholder.
3. Ask the user where to store the database's data directory. If the user
doesn't have a preference, suggest to create one for them under
`~/alloydb-omni/data/<version>/`. Use this as the `DATA_DIR` placeholder.
**Note**: Before running the container, check if the `<DATA_DIR>` exists. If
it doesn't, create it using `mkdir -p <DATA_DIR>`.
4. Ask the user what the password to set for the default `postgres` user. Use
this as the `DATABASE_PASSWORD` placeholder.
5. Ask the user do they prefer to use `docker` or `podman` to run the
container.
a. If `docker`, run this command:
```bash
docker run -d --name <CONTAINER_NAME> \
-e POSTGRES_PASSWORD=<DATABASE_PASSWORD> \
-v <DATA_DIR>:/var/lib/postgresql/data \
-p 5432:5432 \
--restart=always \
google/alloydbomni:<IMAGE_TAG>
```
b. If `podman`, run this command:
```bash
podman run -d --name <CONTAINER_NAME> \
-e POSTGRES_PASSWORD=<DATABASE_PASSWORD> \
-v <DATA_DIR>:/var/lib/postgresql/data \
-p 5432:5432 \
--restart=always \
docker.io/google/alloydbomni:<IMAGE_TAG>
```
## Checking the status of an existing AlloyDB Omni container
1. Ask the user do they prefer to use `docker` or `podman`.
2. Ask the user for the name of the container. If the user doesn't know, run
`docker ps -a` or `podman ps -a` to list all containers.
3. Check the status of the container using:
a. If `docker`: `docker ps -a -f name=<CONTAINER_NAME>` b. If `podman`:
`podman ps -a -f name=<CONTAINER_NAME>`
4. If the user wants, get the logs of the container using:
a. If `docker`: `docker logs <CONTAINER_NAME>` b. If `podman`: `podman logs
<CONTAINER_NAME>`
## Stopping and removing an existing AlloyDB Omni container
1. Ask the user do they prefer to use `docker` or `podman`.
2. Ask the user for the name of the container. If the user doesn't know, run
`docker ps -a` or `podman ps -a` to list all containers.
3. Stop the container:
a. If `docker`: `docker stop <CONTAINER_NAME>` b. If `podman`: `podman stop
<CONTAINER_NAME>`
4. Remove the container (optional, ask user first):
a. If `docker`: `docker rm <CONTAINER_NAME>` b. If `podman`: `podman rm
<CONTAINER_NAME>`
## Connecting to an existing AlloyDB Omni container
1. Ask the user do they prefer to use `docker` or `podman`.
2. Ask the user for the name of the container. If the user doesn't know, run
`docker ps -a` or `podman ps -a` to list all containers.
3. Ask the user to run the following commands. **Important**: do not run this
command yourself. This command is interactive and therefore cannot be run
from Gemini CLI.
a. If `docker`:
```bash
docker exec -it <CONTAINER_NAME> psql -U postgres
```
b. If `podman`:
```bash
podman exec -it <CONTAINER_NAME> psql -U postgres
```
## skills/alloydb-omni-kubernetes/SKILL.md
---
name: alloydb-omni-kubernetes
description:
You're an expert in AlloyDB Omni Operator running in Kubernetes. You can help users with related tasks such as creating, managing, and monitoring AlloyDB Omni DBClusters.
---
# Context
You're an experienced sysadmin and database administrator. You're familiar with
containers and Kubernetes. You're also familiar with PostgreSQL and AlloyDB for
PostgreSQL. Your focus is to help users with tasks related to AlloyDB Omni in
Kubernetes such as creating, managing, and monitoring AlloyDB Omni DBClusters.
# Prerequisites
After activating, confirm with the user that you can run `kubectl` commands and
that it is connected to the right Kubernetes clusters.
**Important**: `kubectl` commands can modify existing resources and may result
in data loss. Always double-check with the user before running any `kubectl`
commands.
# Operator deep dive
By default, the operator runs under the `alloydb-omni-system` namespace. This
namespace can be changed by the user when installing the helm chart, so if
there's nothing there, ask the user where the operator is running.
# Resource Inspection
When monitoring or verifying the state of a resource, use `kubectl describe
<resource_type> <resource_name>` in addition to `kubectl get`. The `describe`
command provides a detailed view of the resource, including the **Events**
section, which often contains critical information regarding the lifecycle and
current state of the resource.
# Connecting to the Database
The most straightforward way to connect to a DBCluster from your local
environment is to use `kubectl port-forward`.
**Important**: The `kubectl port-forward` command is a persistent process that
does not terminate on its own. **The user MUST execute this command in a
separate terminal.** Running it directly within the Gemini CLI will cause the
session to hang and break the agent's functionality.
Example: `kubectl port-forward svc/<service-name> 5432:5432`
# Resource Hierarchy:
**External resources:** are resources that users will interact with directly on
a daily basis. They are equivalent to public APIs of AlloyDB Omni.
```text
backupplans.alloydbomni.dbadmin.goog
backups.alloydbomni.dbadmin.goog
dbclusters.alloydbomni.dbadmin.goog
dbinstances.alloydbomni.dbadmin.goog
failovers.alloydbomni.dbadmin.goog
pgbouncers.alloydbomni.dbadmin.goog
replications.alloydbomni.dbadmin.goog
restores.alloydbomni.dbadmin.goog
sidecars.alloydbomni.dbadmin.goog
switchovers.alloydbomni.dbadmin.goog
tdeconfigs.alloydbomni.dbadmin.goog
userdefinedauthentications.alloydbomni.dbadmin.goog
```
**Internal resources:** are resources that are managed by the AlloyDB Omni
operator and are not meant to be interacted with directly by users. They are
equivalent to private APIs of AlloyDB Omni. However, you may need to interact
with them to get more information.
```text
instances.alloydbomni.internal.dbadmin.goog
```
The central resource is `dbcluster` (full name:
`dbclusters.alloydbomni.dbadmin.goog`). A DBCluster (or database cluster) is a
collection of database instances (fullname:
`instances.alloydbomni.internal.dbadmin.goog`) and other resources that are
managed together. **Important differentiation**: Instances (full name:
`instances.alloydbomni.internal.dbadmin.goog`) are different from DBInstances
(full name: `dbinstances.alloydbomni.dbadmin.goog`). Instances (the internal
resource) represent a unit of compute and storage resource that runs the
database (similar to a Kubernetes `pod`). `DBInstance` (the external resource)
is a read-only group of internal Instances, to be used to scale read-only
workloads on that DBCluster.
The DBCluster, internal instances, and their pods all run under the same
namespace.
To take a backup of a `dbcluster`, you need to first create a `backupplan`
(fullname: `backupplans.alloydbomni.dbadmin.goog`). A `backupplan` defines the
backup schedule, retention, and other configuration. Then `backupplan` will
create individual `backup` (fullname: `backups.alloydbomni.dbadmin.goog`) each
time a backup is taken. You can check the status of each backup by looking at
the `backups` resources.
A highly available dbcluster will have one primary instance and one or more
secondary instances. The primary instance is the one that is used to serve read
and write traffic. The secondary instances can be used to serve read traffic and
can be promoted to primary instances in case of a failover. You can check the
status of each internal instance by looking at the `instances` resources. To
trigger a fail-over (faster, can have data loss), use the `failover` (fullname:
`failovers.alloydbomni.dbadmin.goog`) resource. To trigger a switch-over
(slower, no data loss), use the `switchover` (fullname:
`switchovers.alloydbomni.dbadmin.goog`) resource.
By default, a `restore` (full name: `restores.alloydbomni.dbadmin.goog`) will
restore the data onto the same DBCluster. To create a new DBCluster from a
backup, you need to specify the new DBCluster name under
`clonedDBClusterConfig`.
To deploy a PgBouncer connection pool / proxy fronting the DBCluster, create a
`pgbouncer` (fullname: `pgbouncers.alloydbomni.dbadmin.goog`) resource.
## Inspectin resources
When monitoring or verifying the state of a resource, use `kubectl describe
<resource_type> <resource_name>` in addition to `kubectl get`. The `describe`
command provides a detailed view of the resource, including the **Events**
section, which often contains critical information regarding the lifecycle and
current state of the resource.
## Connecting to the Database
The most straightforward way to connect to a DBCluster from your local
environment is to use `kubectl port-forward`.
**Important**: The `kubectl port-forward` command is a persistent process that
does not terminate on its own. **The user MUST execute this command in a
separate terminal.** Running it directly within the Gemini CLI will cause the
session to hang and break the agent's functionality.
Example: `kubectl port-forward svc/<service-name> 5432:5432`
# AlloyDB Omni on Kubernetes Configuration Samples
## DBCluster examples
### Minimal DBCluster
A basic configuration to get a DBCluster running.
```yaml
# This is a minimal DBCluster spec. See v1_dbcluster_full.yaml for more configurations.
apiVersion: v1
kind: Secret
metadata:
name: db-pw-dbcluster-sample
type: Opaque
data:
dbcluster-sample: "Q2hhbmdlTWUxMjM=" # Password is ChangeMe123
---
apiVersion: alloydbomni.dbadmin.goog/v1
kind: DBCluster
metadata:
name: dbcluster-sample
spec:
databaseVersion: "16.9.0"
primarySpec:
adminUser:
passwordRef:
name: db-pw-dbcluster-sample
resources:
memory: 5Gi
cpu: 1
disks:
- name: DataDisk
size: 10Gi
```
### Full DBCluster
A comprehensive DBCluster configuration showing more options.
```yaml
apiVersion: v1
kind: Secret
metadata:
name: db-pw-dbcluster-sample
type: Opaque
data:
dbcluster-sample: "Q2hhbmdlTWUxMjM=" # Password is ChangeMe123
---
apiVersion: alloydbomni.dbadmin.goog/v1
kind: DBCluster
metadata:
name: dbcluster-sample
spec:
allowExternalIncomingTraffic: true
availability:
healthcheckPeriodSeconds: 30 # The default is 30 seconds. This is a new feature in 1.2.0. The minimum value is 1 and the maximum value is 86400
autoFailoverTriggerThreshold: 3 # The number of failures after which failover is triggered.
autoHealTriggerThreshold: 3
enableAutoFailover: true
enableAutoHeal: true
enableStandbyAsReadReplica: true
numberOfStandbys: 1
controlPlaneAgentsVersion: "1.6.0"
databaseVersion: "16.9.0"
databaseImageOSType: UBI9
isDeleted: false
mode: ""
primarySpec:
adminUser:
passwordRef:
name: db-pw-dbcluster-sample
allowExternalIncomingTrafficToInstance: false
auditLogTarget: {}
dbLoadBalancerOptions:
annotations:
networking.gke.io/load-balancer-type: "internal"
lb.company.com/enabled: "true"
gcp: {}
features:
columnarSpillToDisk:
cacheSize: 50Gi
ultraFastCache:
cacheSize: 100Gi
# either generic volume or local volume
genericVolume:
storageClass: "local-storage"
# localVolume:
# path: "/mnt/disks/raid/0"
# nodeAffinity:
# required:
# nodeSelectorTerms:
# - matchExpressions:
# - key: "cloud.google.com/gke-local-nvme-ssd"
# operator: "In"
# values:
# - "true"
googleMLExtension:
config:
vertexAIKeyRef: vertex-ai-key-alloydb # secret used to enable AlloyDB Omni to access AlloyDB AI features
vertexAIRegion: us-central1 # default
resources:
cpu: "12"
disks:
- name: DataDisk
size: 1000Gi
storageClass: px-ceph
- name: LogDisk
size: 10Gi
storageClass: px-ceph
- name: ObsDisk
size: 4Gi
storageClass: px-ceph
- name: BackupDisk
size: 10Gi
storageClass: px-ceph
memory: 100Gi
walArchiveSetting:
location: wal/log # enable WAL archiving and archive logs to /archive/wal/log
sidecarRef:
name: cv-sidecar-config # provide a sidecar config that is referenced here
parameters:
google_columnar_engine.enabled: "on"
google_columnar_engine.memory_size_in_mb: "256"
shared_preload_libraries: "pg_cron,pg_bigm3"
# operator default values
# shared_preload_libraries='g_stats,google_columnar_engine,google_db_advisor,google_job_scheduler,pg_stat_statements,pglogical,pgaudit'
log_rotation_age: "2" # rotate every two minutes. Set to "0" to disable age-based rotation. If unset, no age-based rotation
log_rotation_size: "400000" # Rotate every 400,000kb. Set to "0" to disable size-based rotation. If unset, rotate every 200,000kb
schedulingconfig:
tolerations:
- effect: NoSchedule
key: alloydb-node-type
operator: Exists
nodeaffinity:
# requiredDuringSchedulingIgnoredDuringExecution: A strong condition; failing to meet this condition prevents pods from being scheduled.
preferredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: alloydb-node-type
operator: In
values:
- database
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- store
topologyKey: "kubernetes.io/hostname"
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: security
operator: In
values:
- S1
topologyKey: "topology.kubernetes.io/zone"
services:
Logging: true
Monitoring: true
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: "example-local-pv"
spec:
capacity:
storage: 375Gi
accessModes:
- "ReadWriteOnce"
persistentVolumeReclaimPolicy: "Retain"
storageClassName: "local-storage"
local:
path: "/mnt/disks/raid/0"
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
# following example key applies to an operator that is deployed on
# Google Cloud and uses the local ssd option
- key: "cloud.google.com/gke-local-nvme-ssd"
operator: "In"
values:
- "true"
---
apiVersion: alloydbomni.dbadmin.goog/v1
kind: DBInstance
metadata:
name: dbcluster-sample-rp-1
spec:
instanceType: ReadPool
dbcParent:
name: dbcluster-sample
nodeCount: 2
resources:
memory: 6Gi
cpu: 2
disks:
- name: DataDisk
size: 15Gi
schedulingconfig:
tolerations:
- key: "node-role.kubernetes.io/control-plane"
operator: "Exists"
effect: "NoSchedule"
nodeaffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: another-node-label-key
operator: In
values:
- another-node-label-value
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- store
topologyKey: "kubernetes.io/hostname"
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: security
operator: In
values:
- S1
topologyKey: "topology.kubernetes.io/zone"
```
### DBCluster with ML agent
Example of configuring the ML agent within a DBCluster.
```yaml
apiVersion: v1
kind: Secret
metadata:
name: db-pw-dbcluster-sample
type: Opaque
data:
dbcluster-sample: "Q2hhbmdlTWUxMjM=" # Password is ChangeMe123
---
apiVersion: v1
kind: Secret
metadata:
name: vertex-ai-key-alloydb
type: Opaque
data:
private-key.json: ""
---
apiVersion: alloydbomni.dbadmin.goog/v1
kind: DBCluster
metadata:
name: dbcluster-sample
spec:
databaseVersion: "16.9.0"
primarySpec:
features:
googleMLExtension:
enabled: true
config:
vertexAIKeyRef: vertex-ai-key-alloydb
vertexAIRegion: us-central1
adminUser:
passwordRef:
name: db-pw-dbcluster-sample
resources:
memory: 5Gi
cpu: 1
disks:
- name: DataDisk
size: 10Gi
```
### DBCluster with load balancer
```yaml
apiVersion: v1
kind: Secret
metadata:
name: db-pw-dbcluster-sample
type: Opaque
data:
dbcluster-sample: "Q2hhbmdlTWUxMjM=" # Password is ChangeMe123
---
apiVersion: alloydbomni.dbadmin.goog/v1
kind: DBCluster
metadata:
name: dbcluster-sample
spec:
databaseVersion: "16.9.0"
primarySpec:
adminUser:
passwordRef:
name: db-pw-dbcluster-sample
resources:
memory: 5Gi
cpu: 1
disks:
- name: DataDisk
size: 10Gi
dbLoadBalancerOptions:
annotations:
# Creates an internal LoadBalancer in GKE.
networking.gke.io/load-balancer-type: "internal"
allowExternalIncomingTraffic: true
```
### DBCluster with Commvault sidecar
```yaml
apiVersion: v1
kind: Secret
metadata:
name: db-pw-dbcluster-sample
type: Opaque
data:
dbcluster-sample: "Q2hhbmdlTWUxMjM=" # Password is ChangeMe123
---
apiVersion: alloydbomni.dbadmin.goog/v1
kind: DBCluster
metadata:
name: dbcluster-sample
spec:
databaseVersion: "16.9.0"
primarySpec:
adminUser:
passwordRef:
name: db-pw-dbcluster-sample
resources:
memory: 5Gi
cpu: 1
disks:
- name: DataDisk
size: 10Gi
- name: LogDisk
size: 10Gi
walArchiveSetting:
location: wal/log # enable WAL archiving and archive logs to /archive/wal/log
sidecarRef:
name: cv-sidecar-config
```
## Backup and Restore
### Backup plan
Example of scheduling full and incremental backups.
```yaml
apiVersion: alloydbomni.dbadmin.goog/v1
kind: BackupPlan
metadata:
name: backupplan1
spec:
dbclusterRef: dbcluster-sample
backupRetainDays: 14
paused: false
backupSchedules:
# Full backup at 00:00 on every Sunday.
full: "0 0 * * 0"
# Incremental backup at 21:00 every day.
incremental: "0 21 * * *"
```
### Restore from backup
```yaml
apiVersion: alloydbomni.dbadmin.goog/v1
kind: Restore
metadata:
name: restore1
spec:
sourceDBCluster: dbcluster-sample
backup: backup1
```
### Clone
```yaml
apiVersion: alloydbomni.dbadmin.goog/v1
kind: Restore
metadata:
name: clone1
spec:
sourceDBCluster: dbcluster-sample
pointInTime: "2024-02-23T19:59:43Z"
clonedDBClusterConfig:
dbclusterName: new-dbcluster-sample
```
## High Availability and Data Resilience
### Failover
Example of performing an unplanned failover to a standby instance.
```yaml
apiVersion: alloydbomni.dbadmin.goog/v1
kind: Failover
metadata:
name: failover-sample
spec:
dbclusterRef: dbcluster-sample
```
### Switchover
Example of performing a controlled switchover to a standby instance.
```yaml
apiVersion: alloydbomni.dbadmin.goog/v1
kind: Switchover
metadata:
name: switchover-sample
spec:
dbclusterRef: dbcluster-sample
newPrimary: aaaa-dbcluster-sample # Replace with the standby instance you selected to switch with the primary instance.
```
## Monitoring and connection pooling
### PgBouncer configuration
```yaml
apiVersion: alloydbomni.dbadmin.goog/v1
kind: PgBouncer
metadata:
name: mypgbouncer
spec:
allowSuperUserAccess: true
dbclusterRef: dbcluster-sample
replicaCount: 1
parameters:
pool_mode: transaction
ignore_startup_parameters: extra_float_digits
default_pool_size: "15"
max_client_conn: "800"
max_db_connections: "160"
podSpec:
resources:
memory: 1Gi
cpu: 1
image: "gcr.io/alloydb-omni-staging/g-pgbouncer:1.4.0"
serviceOptions:
type: "ClusterIP"
```
### Sidecar example
```yaml
apiVersion: alloydbomni.dbadmin.goog/v1
kind: Sidecar
metadata:
name: sidecar-sample
spec:
sidecars:
- image: busybox
name: sidecar-sample
volumeMounts:
- name: obsdisk
mountPath: /logs
command: ["/bin/sh"]
args:
- -c
- |
while [ true ]
do
date
set -x
ls -lh /logs/diagnostic
set +x
done
```

