New to KubeVault? Please start here.

CockroachDB

In the CockroachDB storage backend, Vault data will be stored in CockroachDB. CockroachDB speaks the PostgreSQL wire protocol, so this backend is configured the same way as postgresql. Vault documentation for the CockroachDB storage backend can be found here.

spec.backend.cockroachdb is only available on the kubevault.com/v1alpha2 VaultServer API.

apiVersion: kubevault.com/v1alpha2
kind: VaultServer
metadata:
  name: vault-with-cockroachdb
  namespace: demo
spec:
  version: "2.0.0"
  replicas: 1
  backend:
    cockroachdb:
      address: "cockroachdb-public.demo.svc:26257"
      credentialSecretRef:
        name: cockroachdb-cred
      sslMode: verify-full

spec.backend.cockroachdb

To use CockroachDB as backend storage in Vault, specify spec.backend.cockroachdb in the VaultServer CRD.

spec:
  backend:
    cockroachdb:
      address: <host:port>
      database: <database_name>
      credentialSecretRef:
        name: <secret_name>
      databaseRef:
        name: <appbinding_name>
        namespace: <appbinding_namespace>
      sslMode: <disable|require|verify-ca|verify-full>
      tlsSecretRef:
        name: <secret_name>
      table: <table_name>
      maxParallel: <max_parallel>
      transactionMaxParallel: <transaction_max_parallel>
      skipCreateTable: <true/false>
      haEnabled: <true/false>
      haTable: <ha_table_name>

Here, we are going to describe the various attributes of the spec.backend.cockroachdb field.

cockroachdb.address

cockroachdb.address specifies the address (host:port) of the CockroachDB cluster to connect to. This is required unless databaseRef is set, in which case the address is resolved from the referenced AppBinding instead, or the credential secret holds a connection_url, which replaces it.

spec:
  backend:
    cockroachdb:
      address: "cockroachdb-public.demo.svc:26257"

cockroachdb.database

cockroachdb.database is an optional field that specifies the name of the database in which the tables for Vault data are created. The database must already exist: Vault creates the tables, not the database. Defaults to vault.

spec:
  backend:
    cockroachdb:
      database: "vault"

cockroachdb.credentialSecretRef

cockroachdb.credentialSecretRef is an optional field that specifies the name of the Secret, in the same namespace as the VaultServer, containing the username and password (and, optionally, a full connection_url) used to connect to CockroachDB. The secret contains the following keys:

  • username
  • password (can be left out when logging in with a client certificate, see tlsSecretRef)
  • connection_url (optional; when present, it is used verbatim instead of being built from address/database/username/password/sslMode)
spec:
  backend:
    cockroachdb:
      credentialSecretRef:
        name: cockroachdb-cred

cockroachdb.databaseRef

cockroachdb.databaseRef is an optional field that references a KubeDB-managed AppBinding for the CockroachDB cluster. When set, the host (and, if the AppBinding carries one, the credential secret) is resolved from it instead of from address/credentialSecretRef.

spec:
  backend:
    cockroachdb:
      databaseRef:
        name: cockroachdb-appbinding
        namespace: demo

cockroachdb.sslMode

cockroachdb.sslMode is an optional field that specifies the SSL mode to use when connecting to CockroachDB. Must be one of disable, require, verify-ca, or verify-full. Defaults to verify-full.

spec:
  backend:
    cockroachdb:
      sslMode: verify-full

cockroachdb.tlsSecretRef

cockroachdb.tlsSecretRef is an optional field that specifies the name of the Secret, in the same namespace as the VaultServer, containing the TLS material used to connect to CockroachDB. The secret contains the following keys:

  • ca.crt: CA certificate used to verify the server (required)
  • tls.crt: client certificate (optional, for mutual TLS; needs tls.key)
  • tls.key: client private key (optional, for mutual TLS; needs tls.crt)

If databaseRef is set and this field is empty, the TLS material is taken from the CA bundle and client certificate of the referenced AppBinding.

spec:
  backend:
    cockroachdb:
      tlsSecretRef:
        name: cockroachdb-tls

cockroachdb.table

cockroachdb.table is an optional field that specifies the name of the table in which to write Vault data. Defaults to openbao_kv_store.

spec:
  backend:
    cockroachdb:
      table: "vault_kv_store"

cockroachdb.maxParallel

cockroachdb.maxParallel is an optional field that specifies the maximum number of parallel operations to take place.

spec:
  backend:
    cockroachdb:
      maxParallel: 128

cockroachdb.transactionMaxParallel

cockroachdb.transactionMaxParallel is an optional field that specifies the maximum number of concurrent operations to take place within a single CockroachDB transaction.

spec:
  backend:
    cockroachdb:
      transactionMaxParallel: 32

cockroachdb.skipCreateTable

cockroachdb.skipCreateTable is an optional field that, when true, skips the CREATE TABLE (and, if haEnabled is set, CREATE TABLE for the HA table) statement Vault would otherwise run against the database. This field accepts a boolean value. The default is false.

spec:
  backend:
    cockroachdb:
      skipCreateTable: true

cockroachdb.haEnabled

cockroachdb.haEnabled is an optional field that specifies whether this backend should be used to run Vault in high availability mode. This field accepts a boolean value. The default value is false.

spec:
  backend:
    cockroachdb:
      haEnabled: true

cockroachdb.haTable

cockroachdb.haTable is an optional field that specifies the name of the table used for HA lock information, when haEnabled is true. Defaults to openbao_ha_locks.

spec:
  backend:
    cockroachdb:
      haTable: "vault_ha_locks"