Spanner Omni uses TLS 1.3 to encrypt data that flows between the client and server, and between Spanner Omni servers. Spanner Omni provides mTLS for enhanced security where both parties establish the authenticity of each other before exchanging any data. If you use encryption, then your servers must communicate over mTLS. You can choose whether your client and server also use mTLS.
Before you begin
Ensure that you meet the following requirements:
Create a Kubernetes cluster. The configuration supports Google Kubernetes Engine (GKE) and Amazon Elastic Kubernetes Service (Amazon EKS). You might need to customize the configuration to work in other environments.
Ensure the Kubernetes cluster can access the Artifact Registry artifact that hosts the Spanner Omni container.
Install and configure the
kubectlcommand line tool and Helm.If you set up the Kubernetes environment on vSphere virtualization platform machines, disable Time Stamp Counter (TSC) virtualization by adding
monitor_control.virtual_rdtsc = FALSEto the virtual machine's.vmxconfiguration file. This ensures TrueTime works correctly.Verify your environment meets Spanner Omni system requirements.
Step 1: Generate the certificates
You must create three sets of certificates:
API certificates: These help protect the Spanner Omni API server.
Server certificates: These help protect inter-server communication.
Client certificates: End users or applications use these to establish their identity and trust with Spanner Omni servers.
A certificate authority (CA) issues these certificates. Spanner Omni provides tools to create a self-signed CA and all three types of certificates.
Perform the following steps on one of your machines. The steps assume that the
namespace is spanner-ns. Change this to the namespace that you intend to use
in your deployment.
You can create these certificates on your workstation using the Spanner Omni CLI.
1. Create certificate authorities
You must create two separate certificate authorities (CAs) to isolate internal inter-server communication from external client and API communication:
- Internal server CA (
ca.crt): issues server certificates (server.crt) used exclusively for internal mTLS communication between Spanner Omni servers. - API and client CA (
ca-api.crt): issues the API server certificate (api.crt) and client mTLS certificates (client.crt). Alternatively, you can use an externally trusted CA or your organization's CA for the API and client certificates. - Trace collector CA (
ca-otlp.crt): verifies the TLS certificate of a remote trace collector. You need this CA only if you export traces to a remote collector, including the Jaeger collector that the Helm chart installs withmonitoring.enabled=true.
Create the internal server CA for inter-server communication:
./google/spanner/bin/spanner certificates create-ca --ca-certificate-directory=certsThis command creates the internal server CA certificate (
certs/ca.crt) and writes its private key to$HOME/.spanner/private-keys/ca.key.Create a separate CA for the API and client certificates, and copy its CA certificate to
certs/ca-api.crt:./google/spanner/bin/spanner certificates create-ca \ --ca-certificate-directory=api-certs \ --ca-private-key-directory=$HOME/.spanner/api-private-keys cp api-certs/ca.crt certs/ca-api.crtThese commands create the API and client CA certificate (
api-certs/ca.crt, copied tocerts/ca-api.crt) and write its private key to$HOME/.spanner/api-private-keys/ca.key.If you export traces to a remote trace collector, including the Jaeger collector that the Helm chart installs with
monitoring.enabled=true, create a separate CA for the trace collector, and copy its CA certificate tocerts/ca-otlp.crt:./google/spanner/bin/spanner certificates create-ca \ --ca-certificate-directory=otlp-certs \ --ca-private-key-directory=$HOME/.spanner/otlp-private-keys cp otlp-certs/ca.crt certs/ca-otlp.crtThese commands create the trace collector CA certificate (
otlp-certs/ca.crt, copied tocerts/ca-otlp.crt) and write its private key to$HOME/.spanner/otlp-private-keys/ca.key. Servers useca-otlp.crtonly to verify the collector. Alternatively, you can use the CA that issued your collector's existing certificate asca-otlp.crt.Don't use the internal server CA (
ca.crt) asca-otlp.crt, and don't issue the collector's certificate with it. Servers accept clients that present a certificate issued byca.crt, so a collector with such a certificate could call internal services.
Back up and secure $HOME/.spanner/private-keys,
$HOME/.spanner/api-private-keys, and, if you created a trace collector CA,
$HOME/.spanner/otlp-private-keys. Users with access to these private keys can
sign arbitrary certificates that the deployment trusts.
2. Generate server certificates
You must generate two types of server certificates:
API certificate: Use this certificate to encrypt communication from systems interacting with the deployment.
Spanner server certificate: Spanner Omni servers use this certificate to encrypt communication with each other.
This configuration provides flexibility in managing these certificates. For example, it lets you use certificate rotation.
Create the Spanner server certificate
Create the server certificate:
# Comma-separate names of the Spanner servers; wildcards are supported.
SERVER_NAMES=*.pod.NAMESPACE
./google/spanner/bin/spanner certificates create-server --hostnames=${SERVER_NAMES} --ca-certificate-directory certs --output-directory certs
This command creates server.crt and server.key in the certs directory.
Create the API certificate
Create the API certificate using the API CA:
OMNI_ENDPOINT=spanner.NAMESPACE.svc
./google/spanner/bin/spanner certificates create-server \
--filename-prefix=api \
--hostnames=${OMNI_ENDPOINT} \
--ca-certificate-directory=api-certs \
--ca-private-key-directory=$HOME/.spanner/api-private-keys \
--output-directory=certs
This command creates api.crt and api.key in the certs directory. If
necessary, use an externally trusted CA for the API certificates.
Create the trace collector certificate
If you created a trace collector CA, create the collector's TLS certificate using the trace collector CA:
./google/spanner/bin/spanner certificates create-server \
--filename-prefix=collector \
--hostnames=COLLECTOR_HOST \
--ca-certificate-directory=otlp-certs \
--ca-private-key-directory=$HOME/.spanner/otlp-private-keys \
--output-directory=otlp-certs
Replace COLLECTOR_HOST with the hostname of the collector in
the trace exporter endpoint. For the Jaeger collector that the Helm chart
installs with monitoring.enabled=true, use
jaeger.monitoring.svc.cluster.local. If the endpoint uses an IP address, such
as the node IP address of a DaemonSet collector, specify the IP address;
--hostnames adds IP addresses to the certificate as IP subject alternative
names.
This command creates collector.crt and collector.key in the otlp-certs
directory. Use them to enable TLS on the collector, as described in
Export traces over TLS.
For the Jaeger collector that the Helm chart installs, push them to the
jaeger-tls secret in Step 2. Servers don't need these files,
so don't add them to the tls-certs secret.
3. Generate client certificates
You can use client certificates to authenticate users and applications. Client certificates enable mTLS between the client and the server. You can skip this step if you don't plan to use mTLS.
Sign client certificates with the API and client CA (api-certs/ca.crt, which
matches certs/ca-api.crt) and include a username for authorization. Don't sign
client certificates with the internal server CA (certs/ca.crt). For this
example, use the admin user, which is the default user for each new database.
For more information, see Authentication and authorization in
Spanner Omni.
Create the client certificate:
USERNAME=admin
./google/spanner/bin/spanner certificates create-client $USERNAME \
--output-directory=clientcerts \
--ca-certificate-directory=api-certs \
--ca-private-key-directory=$HOME/.spanner/api-private-keys
This command creates client.crt and client.key in the clientcerts
directory. Send these files to any machine that connects to the deployment.
If you plan to use client certificates with the Java client library, you must generate the certificate key in PKCS#8 format. Use the following command:
USERNAME=admin
./google/spanner/bin/spanner certificates create-client $USERNAME \
--output-directory=clientcerts \
--ca-certificate-directory=api-certs \
--ca-private-key-directory=$HOME/.spanner/api-private-keys \
--generate-pkcs8-key
4. Generate the wrapper keyset
Spanner Omni uses a Key Encryption Key (KEK) wrapper keyset
mounted at /spanner/kms/wrapper_key in each server pod to encrypt internal
keys, such as token encryption and signing keys.
To generate a new wrapper keyset file using spanner keys create-keyset, run
the following command:
./google/spanner/bin/spanner keys create-keyset --output-file=kms/wrapper_key
By default, spanner keys create-keyset generates an AES256_GCM key. To
generate a different type of key, use the --key-template flag with one of the
following key type values: AES256_GCM, AES128_GCM, AES256_GCM_RAW,
CHACHA20_POLY1305, or XCHACHA20_POLY1305.
Step 2: Push the certificates, wrapper keyset, and administrator password to the Kubernetes cluster
Run the following commands to create the namespace and push the certificates, wrapper keyset, and administrator password to your Kubernetes cluster:
Create the namespace:
kubectl create namespace NAMESPACEPush the TLS certificates to a secret:
kubectl create secret generic tls-certs \ --from-file=ca.crt="certs/ca.crt" \ --from-file=ca-api.crt="certs/ca-api.crt" \ --from-file=server.crt="certs/server.crt" \ --from-file=server.key="certs/server.key" \ --from-file=api.crt="certs/api.crt" \ --from-file=api.key="certs/api.key" \ -n NAMESPACEIf you created a trace collector CA, include
ca-otlp.crtin the secret instead. Each server pod readsca-otlp.crtfrom thetls-certssecret, which is mounted at/spanner/tls:kubectl create secret generic tls-certs \ --from-file=ca.crt="certs/ca.crt" \ --from-file=ca-api.crt="certs/ca-api.crt" \ --from-file=ca-otlp.crt="certs/ca-otlp.crt" \ --from-file=server.crt="certs/server.crt" \ --from-file=server.key="certs/server.key" \ --from-file=api.crt="certs/api.crt" \ --from-file=api.key="certs/api.key" \ -n NAMESPACEIf you install the Helm chart with
monitoring.enabled=true, as in Step 3, push the trace collector certificate to a TLS secret namedjaeger-tlsin themonitoringnamespace:kubectl create namespace monitoring kubectl create secret tls jaeger-tls -n monitoring \ --cert=otlp-certs/collector.crt --key=otlp-certs/collector.keyStarting with Helm chart version 2.0.0, in deployments with TLS encryption, the Jaeger collector serves TLS by default, and
helm installfails if this secret doesn't exist. For more information, see Export traces over TLS.Push the wrapper keyset to a secret (
wrapper-key), which is mounted at/spanner/kmsin each server pod:kubectl create secret generic wrapper-key \ --from-file=wrapper_key="kms/wrapper_key" \ -n NAMESPACECreate a password file containing the password for the default
adminuser, with restricted permissions (readable only by its owner, permissions 600):printf '%s' 'PASSWORD' > admin_password.txt chmod 600 admin_password.txtThe password must meet the following requirements:
- Between 8 and 32 characters in length.
- At least one uppercase character.
- At least one lowercase character.
- At least one number.
- At least one special character.
Create a secret for the administrator password:
kubectl create secret generic spanner-admin-password \ --from-file=password=admin_password.txt \ -n NAMESPACE
Step 3: Create the deployment with TLS encryption
Follow these steps to create your deployment with TLS encryption.
1. Prepare the Helm configuration
Refer to Create a Helm chart configuration and create the deployment configuration for your environment.
To enable TLS and configure the administrator password, set the following values in your Helm chart configuration:
# Enables TLS
global:
insecureMode: false
# Enables client certificate authentication (mTLS)
deployment:
enableClientCertificateAuthentication: true
# Name of the secret containing the administrator password
adminPasswordSecret: spanner-admin-password
2. Create the deployment
Run the following command to create the deployment:
helm upgrade --install spanner-omni oci://us-docker.pkg.dev/spanner-omni/charts/spanner-omni \
--version VERSION \
--set global.platform=gke \
--set global.insecureMode=false \
--set deployment.enableClientCertificateAuthentication=true \
--set deployment.adminPasswordSecret=spanner-admin-password \
--namespace NAMESPACE \
--set monitoring.enabled=true
The command triggers a bootstrap job. You can track the progress by watching the logs of this job:
kubectl logs -n NAMESPACE -l app.kubernetes.io/component=bootstrap -f
The output indicates the progress. When complete, you see a message stating "Deployment created successfully".
3. Check the status of the pods
Run the following command to verify the pod status:
kubectl get pods --watch --namespace NAMESPACE
All pods are in the READY state.
4. Update the certificate and deployment with load balancer details
This step is required if you want clients to connect from outside the Kubernetes cluster.
# Get the service details
kubectl get service spanner -n NAMESPACE
# The EXTERNAL-IP:PORT is the API or deployment endpoint for your deployment.
# Update the API certificate with these details.
OMNI_ENDPOINT=EXTERNAL_IP,spanner.NAMESPACE.svc
./google/spanner/bin/spanner certificates update \
--certificate-file=certs/api.crt \
--certificate-key-file=certs/api.key \
--hostnames=${OMNI_ENDPOINT} \
--ca-certificate-directory=api-certs \
--ca-private-key-directory=$HOME/.spanner/api-private-keys
# Update the secrets in Kubernetes
kubectl patch secret tls-certs -n NAMESPACE -p "{\"data\":{\"api.crt\":\"$(base64 -w 0 certs/api.crt)\"}}"
Step 4: Interact with Spanner Omni
You can interact with your Spanner Omni deployment from any VM using the Spanner Omni CLI.
If you enabled mTLS for clients, use the following flags with each command:
--client-certificate-directory=CLIENT_CERTIFICATE_DIRECTORY--ca-certificate-file=API_CA_CERT_FILE_PATH
1. Log in to Spanner Omni (optional)
Log in to Spanner Omni (this step is optional if you use client certificates):
./google/spanner/bin/spanner auth login admin \
--ca-certificate-file=certs/ca-api.crt \
--deployment-endpoint=DEPLOYMENT_ENDPOINT
When prompted, enter the password configured in admin_password.txt.
Successfully logged in as "admin"
2. Create a database
Run the following command to create a database:
./google/spanner/bin/spanner --deployment-endpoint=DEPLOYMENT_ENDPOINT databases create DATABASE_NAME --ca-certificate-file=certs/ca-api.crt --client-certificate-directory=clientcerts
3. Open the SQL Shell
Run the following command to open the shell:
./google/spanner/bin/spanner sql --database=DATABASE_NAME --deployment-endpoint=DEPLOYMENT_ENDPOINT --ca-certificate-file=certs/ca-api.crt --client-certificate-directory=clientcerts
4. Create a table and add data
Run the following SQL commands:
spanner> CREATE TABLE names (nameId INT64 NOT NULL, name String(100)) PRIMARY KEY (nameId);
Query OK, 0 rows affected (4.62 sec)
spanner> INSERT names (nameId, name) VALUES (1, "Jack");
Query OK, 1 rows affected (0.18 sec)
5. Verify the deployment
To list the databases, run the following command:
./google/spanner/bin/spanner databases list --ca-certificate-file=certs/ca-api.crt --client-certificate-directory=clientcerts --deployment-endpoint=DEPLOYMENT_ENDPOINT
The output looks similar to the following:
| NAME | STATE | VERSION_RETENTION_PERIOD | EARLIEST_VERSION_TIME | ENABLE_DROP_PROTECTION |
|---|---|---|---|---|
| DATABASE_NAME | READY | 1h | 2025-02-07T12:25:30Z | false |
To query the data, run the following command:
./google/spanner/bin/spanner sql --database=DATABASE_NAME --ca-certificate-file=certs/ca-api.crt --client-certificate-directory=clientcerts --deployment-endpoint=DEPLOYMENT_ENDPOINT
Run the following SQL commands:
SHOW TABLES;
SELECT * FROM names;
Alternatively, you can follow the instructions in Using PGAdapter with
Spanner Omni to configure PGAdapter and
interact using tools like psql.
Step 5: Monitor the deployment
If you installed Spanner Omni with monitoring.enabled=true,
Prometheus scrapes metrics. You can use Grafana to visualize these metrics.
1. Get the service details
Run the following commands to get the service details:
# Prometheus service details. Default port is 9090.
kubectl get service prometheus-service -n monitoring
# Grafana service details. Default port is 3000.
kubectl get service grafana -n monitoring
What's next
- Use Client libraries and JDBC drivers to connect your application with the deployment.
- Manage users and roles.