Manage OpenBao policies with Kubernetes¶
Use a Policy resource to keep an OpenBao ACL policy in Git. The operator writes its HCL to
OpenBao and reconciles later changes. Creating the policy does not grant anyone access: an auth
role or identity group must attach it to a login.
Before you begin¶
- Install the operator and create a Ready connection.
- This example uses connection
openbaoin Kubernetes namespaceopenbao-config. - The connection's OpenBao identity needs
create,readandupdateonsys/policies/acl/guide-app-read. See permissions for the operator. - Use an unused policy name. To take over an existing policy, first follow the import guide and review its current permissions.
The example grants read access to application data in a KV v2 mount named apps. The policy
can be created before that mount exists; Kubernetes auth creates the mount
and connects a workload to this policy.
Declare the policy¶
Save this as app-read.yaml:
apiVersion: sys.openbaoconfig.io/v1alpha1
kind: Policy
metadata:
name: guide-app-read
namespace: openbao-config
spec:
connectionRef:
name: openbao
deletionPolicy: Orphan
name: guide-app-read
policy: |
path "apps/data/app/*" {
capabilities = ["read"]
}
kubectl apply -f app-read.yaml
kubectl -n openbao-config wait policy/guide-app-read --for=condition=Ready --timeout=2m
kubectl -n openbao-config get policy guide-app-read
Expect READY and SYNCED to be True. If the resource is not ready, inspect its conditions
and events with kubectl -n openbao-config describe policy guide-app-read.
Verify the OpenBao result¶
Point the bao CLI at the same server and OpenBao namespace as the connection, using an identity
allowed to read this policy:
The returned HCL must contain the apps/data/app/* path and only the read capability.
metadata.name identifies the Kubernetes object; spec.name identifies the policy in OpenBao.
They happen to match here.
Attach the policy through a role's policyRefs, as in Kubernetes authentication,
or through an identity Group. Keep policy changes in the manifest and let your
GitOps delivery apply them. Avoid having another tool continuously write the same
OpenBao policy.
Remove the Kubernetes resource¶
If another resource names this Policy through policyRefs, update that reference before deleting
the Policy resource. Otherwise the dependent resource reports ReferenceNotReady.
This example explicitly uses deletionPolicy: Orphan, so the OpenBao policy remains. Removing a
policy from OpenBao is a separate access change: review its users first. For lifecycle choices,
see ownership and deletion.
For identity-based path templates, continue with templated policies. The Policy API reference documents all fields.