Skip to content

Set up the platform

In this tutorial you are the platform owner: admin of OpenBao and of the Kubernetes cluster. You give the operator its own OpenBao identity, declare the server and a platform connection, and configure OpenBao in one apply: a policy and an auth method in the root namespace, and the platform's own OpenBao namespace with a secrets engine inside it.

It takes about five minutes.

Before you begin

Finish the quickstart up to step 9 and stay at the root of the repository clone, as Tutorials describes.

1. Give the operator its own identity in OpenBao

In the quickstart the operator logged in as the ServiceAccount of a tenant namespace. The platform connection logs in as the operator itself, with the token the chart mounts in the manager pod for the audience openbao-config-operator. The policy behind it is full admin, because you, the platform owner, are:

examples/tutorials/platform-owner/openbao-config-operator.hcl
path "*" {
  capabilities = ["create", "read", "update", "patch", "delete", "list", "sudo"]
}

Upload the policy and create the role openbao-config-operator, which accepts only the ServiceAccount openbao-config-operator of the namespace openbao-config-operator:

kubectl -n openbao exec -i deploy/openbao -- bao policy write openbao-config-operator - \
  < examples/tutorials/platform-owner/openbao-config-operator.hcl
kubectl -n openbao 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! Uploaded policy: openbao-config-operator
Success! Data written to: auth/kubernetes/role/openbao-config-operator

2. Declare the server and the platform connection

Three objects connect the platform to OpenBao:

  • the namespace platform, where the platform team keeps its resources;
  • the OpenBaoServer openbao, which tenant connections will use later: it admits namespaces labelled openbaoconfig.io/tenant: "true", with the audience openbao only;
  • the ClusterOpenBaoConnection platform, which logs in as the operator and serves resources in the namespace platform only.
# The Kubernetes namespace of the platform team. Only resources in it may use the ClusterOpenBaoConnection
# platform, which logs in to OpenBao as the operator itself.
apiVersion: v1
kind: Namespace
metadata:
  name: platform
# The quickstart's OpenBao, declared by the platform team. OpenBaoConnections in namespaces labelled
# openbaoconfig.io/tenant may use it, with ServiceAccount tokens for the openbao audience only. Evaluation only:
# the dev server speaks plain HTTP, which allowInsecureHTTP permits.
apiVersion: core.openbaoconfig.io/v1alpha1
kind: OpenBaoServer
metadata:
  name: openbao
spec:
  address: http://openbao.openbao.svc:8200
  allowInsecureHTTP: true
  allowedNamespaces:
    matchLabels:
      openbaoconfig.io/tenant: "true"
  allowedAudiences:
    - openbao
# Logs in as the operator's own ServiceAccount with the projected token the chart mounts (audience
# openbao-config-operator). Only resources in the Kubernetes namespace platform may use it.
apiVersion: core.openbaoconfig.io/v1alpha1
kind: ClusterOpenBaoConnection
metadata:
  name: platform
spec:
  serverRef:
    name: openbao
  auth:
    kubernetes:
      role: openbao-config-operator
      injectedIdentity: {}
  allowedNamespaces:
    matchLabels:
      kubernetes.io/metadata.name: platform

Apply them and wait until the server and the connection are Ready:

kubectl apply -f examples/tutorials/platform-owner/namespace.yaml \
  -f examples/tutorials/platform-owner/openbaoserver.yaml \
  -f examples/tutorials/platform-owner/clusteropenbaoconnection.yaml
kubectl wait openbaoserver/openbao clusteropenbaoconnection/platform --for=condition=Ready --timeout=2m
Expected output
namespace/platform created
openbaoserver.core.openbaoconfig.io/openbao created
clusteropenbaoconnection.core.openbaoconfig.io/platform created
openbaoserver.core.openbaoconfig.io/openbao condition met
clusteropenbaoconnection.core.openbaoconfig.io/platform condition met

The connection is Ready once the operator has logged in to OpenBao as itself.

3. Configure OpenBao in one go

Four resources describe the platform's configuration:

  • in the root namespace, the policy platform-auditor and an AppRole auth method at approle;
  • the OpenBao namespace platform, and a KV version 2 secrets engine at secret inside it.
# Configuration of the OpenBao root namespace: a read-only policy for platform auditors and an AppRole auth
# method for CI pipelines.
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: Policy
metadata:
  name: platform-auditor
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform
  policy: |
    path "sys/namespaces" {
      capabilities = ["list"]
    }
    path "sys/policies/acl" {
      capabilities = ["list"]
    }
---
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: AuthMount
metadata:
  name: approle
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform
  type: approle
  description: AppRole logins for CI pipelines
# The platform team's own OpenBao namespace platform, with a KV version 2 secrets engine at secret inside it.
# spec.namespace on the SecretsMount selects the OpenBao namespace, relative to the connection's root.
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: OpenBaoNamespace
metadata:
  name: platform
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform
---
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: SecretsMount
metadata:
  name: platform-secret
  namespace: platform
spec:
  connectionRef:
    kind: ClusterOpenBaoConnection
    name: platform
  namespace: platform
  path: secret
  type: kv-v2
  description: Platform team secrets

Notice namespace: platform in the SecretsMount spec: it is the OpenBao namespace, relative to the connection's, which is the root. The mount waits until the OpenBao namespace exists.

Apply both files and wait until every resource is Ready:

kubectl apply -f examples/tutorials/platform-owner/root-config.yaml \
  -f examples/tutorials/platform-owner/platform-namespace.yaml
kubectl -n platform wait --for=condition=Ready --timeout=3m \
  policy.sys.openbaoconfig.io/platform-auditor \
  authmount.sys.openbaoconfig.io/approle \
  openbaonamespace.sys.openbaoconfig.io/platform \
  secretsmount.sys.openbaoconfig.io/platform-secret
Expected output
policy.sys.openbaoconfig.io/platform-auditor created
authmount.sys.openbaoconfig.io/approle created
openbaonamespace.sys.openbaoconfig.io/platform created
secretsmount.sys.openbaoconfig.io/platform-secret created
policy.sys.openbaoconfig.io/platform-auditor condition met
authmount.sys.openbaoconfig.io/approle condition met
openbaonamespace.sys.openbaoconfig.io/platform condition met
secretsmount.sys.openbaoconfig.io/platform-secret condition met

List them with their Ready and Synced columns:

kubectl -n platform get openbao

Confirm:

  • Every resource in the namespace platform shows Ready True.

4. Check the result in OpenBao

Read the policy, the auth methods, the namespaces, and the secrets engines of the namespace platform:

kubectl -n openbao exec deploy/openbao -- bao policy read platform-auditor
kubectl -n openbao exec deploy/openbao -- bao auth list
kubectl -n openbao exec deploy/openbao -- bao namespace list
kubectl -n openbao exec deploy/openbao -- bao secrets list -namespace=platform

You should see the policy as written in root-config.yaml, approle/ among the auth methods, platform/ in the namespace list, and secret/ of type kv in the namespace platform.

What you built

  • An OpenBao identity for the operator, and a ClusterOpenBaoConnection that only the platform namespace may use.
  • An OpenBaoServer ready for tenant connections, limited by a namespace label and an audience.
  • Root namespace configuration and a child OpenBao namespace, declared in Kubernetes and checked against OpenBao.

Next steps