Skip to content

Manage several OpenBao servers

In this tutorial you are the platform owner again. You start a second OpenBao next to the quickstart's, declare it as its own server with its own connection, and give each server a different configuration plus one policy they share. At the end you check that each server holds exactly its own objects.

It takes about five minutes.

Before you begin

Finish Set up the platform. This tutorial reuses its namespace platform, its connection platform to the first OpenBao, and its operator policy.

1. Start a second OpenBao

Apply examples/tutorials/multiple-instances/openbao-2.yaml: the same dev-mode OpenBao as the quickstart's, in the namespace openbao-2.

kubectl apply -f examples/tutorials/multiple-instances/openbao-2.yaml
kubectl -n openbao-2 rollout status deployment/openbao --timeout=3m
Expected output
namespace/openbao-2 created
serviceaccount/openbao created
clusterrolebinding.rbac.authorization.k8s.io/openbao-2-auth-delegator created
deployment.apps/openbao created
service/openbao created
deployment "openbao" successfully rolled out

2. Give the operator the same identity on the second server

The second server knows nothing of the first. Enable its Kubernetes auth method, point it at the cluster's API server, and create the same policy and role as in Set up the platform:

kubectl -n openbao-2 exec deploy/openbao -- bao auth enable kubernetes
kubectl -n openbao-2 exec deploy/openbao -- bao write auth/kubernetes/config \
  kubernetes_host=https://kubernetes.default.svc:443
kubectl -n openbao-2 exec -i deploy/openbao -- bao policy write openbao-config-operator - \
  < examples/tutorials/platform-owner/openbao-config-operator.hcl
kubectl -n openbao-2 exec deploy/openbao -- bao write auth/kubernetes/role/openbao-config-operator \
  bound_service_account_names=openbao-config-operator \
  bound_service_account_namespaces=openbao-config-operator \
  audience=openbao-config-operator \
  token_policies=openbao-config-operator \
  token_ttl=1h token_max_ttl=4h
Expected output
Success! Enabled kubernetes auth method at: kubernetes/
Success! Data written to: auth/kubernetes/config
Success! Uploaded policy: openbao-config-operator
Success! Data written to: auth/kubernetes/role/openbao-config-operator

3. Declare the second server and its connection

The second OpenBao gets its own OpenBaoServer and its own connection. The server openbao-2 sets no allowedNamespaces, so no tenant connection may use it; the ClusterOpenBaoConnection platform-2 reaches it for the namespace platform.

The first OpenBao is now declared twice: as quickstart by the quickstart and as openbao by the previous tutorial. The tutorials keep both. Each OpenBaoServer has its own allow-lists and its own rateLimit, so on a real platform declare each OpenBao once.

# The second OpenBao. allowedNamespaces is unset, so no OpenBaoConnection may use it: only the platform's
# ClusterOpenBaoConnection platform-2 reaches it.
apiVersion: core.openbaoconfig.io/v1alpha1
kind: OpenBaoServer
metadata:
  name: openbao-2
spec:
  address: http://openbao.openbao-2.svc:8200
  allowInsecureHTTP: true
# Logs in to the second OpenBao as the operator itself, like the connection platform does for the first one.
apiVersion: core.openbaoconfig.io/v1alpha1
kind: ClusterOpenBaoConnection
metadata:
  name: platform-2
spec:
  serverRef:
    name: openbao-2
  auth:
    kubernetes:
      role: openbao-config-operator
      injectedIdentity: {}
  allowedNamespaces:
    matchLabels:
      kubernetes.io/metadata.name: platform
kubectl apply -f examples/tutorials/multiple-instances/openbaoserver.yaml \
  -f examples/tutorials/multiple-instances/clusteropenbaoconnection.yaml
kubectl wait openbaoserver/openbao-2 clusteropenbaoconnection/platform-2 --for=condition=Ready --timeout=2m
Expected output
openbaoserver.core.openbaoconfig.io/openbao-2 created
clusteropenbaoconnection.core.openbaoconfig.io/platform-2 created
openbaoserver.core.openbaoconfig.io/openbao-2 condition met
clusteropenbaoconnection.core.openbaoconfig.io/platform-2 condition met

4. Configure each server

A resource's connectionRef decides which server it lands on:

  • instance-1.yaml, through platform: a policy and a Kubernetes auth role, on the first server only;
  • instance-2.yaml, through platform-2: a KV version 2 mount and a userpass auth method, on the second server only;
  • shared-policy.yaml: the policy ops-read on both, as one resource per connection with the same spec.name.
# Configuration only the first OpenBao gets: a policy that reads the quickstart's secret, and a Kubernetes auth role
# that gives it to the ServiceAccount app of the namespace quickstart.
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: Policy
metadata:
  name: instance-1-app
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform
  policy: |
    path "quickstart-kv/data/app" {
      capabilities = ["read"]
    }
---
apiVersion: auth.openbaoconfig.io/v1alpha1
kind: KubernetesAuthRole
metadata:
  name: instance-1-app
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform
  boundServiceAccountNames:
    - app
  boundServiceAccountNamespaces:
    - quickstart
  audience: openbao
  tokenTTL: 15m
  policyRefs:
    - name: instance-1-app
# Configuration only the second OpenBao gets: a KV version 2 secrets engine and a userpass auth method.
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: SecretsMount
metadata:
  name: instance-2-kv
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform-2
  type: kv-v2
  description: Secrets of the second OpenBao
---
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: AuthMount
metadata:
  name: instance-2-userpass
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform-2
  path: userpass
  type: userpass
  description: Username and password logins on the second OpenBao
# One policy, ops-read, on both OpenBao servers: a resource names one connection, so each server gets its own
# resource with the same spec.name and policy.
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: Policy
metadata:
  name: ops-read-instance-1
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform
  name: ops-read
  policy: |
    path "sys/mounts" {
      capabilities = ["read"]
    }
    path "sys/auth" {
      capabilities = ["read"]
    }
---
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: Policy
metadata:
  name: ops-read-instance-2
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform-2
  name: ops-read
  policy: |
    path "sys/mounts" {
      capabilities = ["read"]
    }
    path "sys/auth" {
      capabilities = ["read"]
    }
kubectl apply -f examples/tutorials/multiple-instances/instance-1.yaml \
  -f examples/tutorials/multiple-instances/instance-2.yaml \
  -f examples/tutorials/multiple-instances/shared-policy.yaml
kubectl -n platform wait --for=condition=Ready --timeout=3m \
  policy.sys.openbaoconfig.io/instance-1-app \
  kubernetesauthrole.auth.openbaoconfig.io/instance-1-app \
  secretsmount.sys.openbaoconfig.io/instance-2-kv \
  authmount.sys.openbaoconfig.io/instance-2-userpass \
  policy.sys.openbaoconfig.io/ops-read-instance-1 \
  policy.sys.openbaoconfig.io/ops-read-instance-2

Every resource reports condition met.

5. See which server each resource is bound to

Each resource records the cluster id of the OpenBao it was written to in status.serverID:

kubectl -n platform get policies.sys.openbaoconfig.io,kubernetesauthroles,secretsmounts,authmounts \
  -o custom-columns=KIND:.kind,NAME:.metadata.name,CONNECTION:.spec.connectionRef.name,SERVER:.status.serverID

Notice two different ids: the resources of platform, including platform-auditor from the first tutorial, show the id of the first server, and those of platform-2 the id of the second. Concepts: ownership and adoption explains why each object stays bound to that id.

6. Check each server in OpenBao

Ask the first server for its policies and the role:

kubectl -n openbao exec deploy/openbao -- bao policy list
kubectl -n openbao exec deploy/openbao -- bao read -field=token_policies auth/kubernetes/role/instance-1-app

You should see instance-1-app, ops-read and platform-auditor among the policies, and [instance-1-app] as the role's token policies.

Ask the second server for its policies, secrets engines and auth methods:

kubectl -n openbao-2 exec deploy/openbao -- bao policy list
kubectl -n openbao-2 exec deploy/openbao -- bao secrets list
kubectl -n openbao-2 exec deploy/openbao -- bao auth list

You should see ops-read, but neither instance-1-app nor platform-auditor; instance-2-kv/ among the secrets engines; and userpass/ among the auth methods. The first server has neither instance-2-kv/ nor userpass/.

What you built

  • Two OpenBao servers managed from one Kubernetes cluster, each reached through its own OpenBaoServer and connection.
  • Configuration that differs per server, and one policy kept identical on both.
  • Proof that a resource bound to one server never writes to the other.

Next steps