<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Security – TechBlog about OpenShift/Ansible/Satellite and much more</title><link>https://blog.stderr.at/categories/security/</link><description>TechBlog about OpenShift/Ansible/Satellite and much more</description><generator>Hugo 0.164.0</generator><language>en-us</language><copyright>Toni Schmidbauer &amp; Thomas Jungbauer</copyright><lastBuildDate>Sat, 24 Oct 2026 00:00:00 +0200</lastBuildDate><atom:link href="https://blog.stderr.at/categories/security/index.xml" rel="self" type="application/rss+xml"/><item><title>[Ep.20] Managing ACM Policies with OpenShift GitOps</title><link>https://blog.stderr.at/gitopscollection/2026-10-24-acm-policies-with-gitops/</link><guid isPermaLink="true">https://blog.stderr.at/gitopscollection/2026-10-24-acm-policies-with-gitops/</guid><pubDate>Sat, 24 Oct 2026 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>GitOps</category><category>Security</category><description>Policies as code: let OpenShift GitOps deploy Advanced Cluster Management policies from Git, generate them with the PolicyGenerator, use hub templates for per-cluster values and bootstrap Argo CD on every new cluster with a policy.</description><content:encoded><![CDATA[<div class="paragraph">
<p>In <a href="/gitopscollection/2026-10-20-openshift-gitops-vs-acm/">[Ep.18]</a> I recommended ACM policies for the audited baseline of a cluster and Argo CD for everything that needs rendering. <a href="/gitopscollection/2026-10-23-acm-gitops-push-pull-agent/">[Ep.19]</a> showed how ACM feeds Argo CD with clusters and the different models that can be used in Argo CD. This part turns the integration around: <strong>Argo CD deploys ACM policies</strong>, and a policy <strong>bootstraps Argo CD</strong> on every new cluster.</p>
</div>
<div class="paragraph">
<p>The result is a setup where the policies live in Git, are reviewed in pull requests like any other change, and ACM does what it is good at: distribution, enforcement and compliance reporting.</p>
</div>
<div class="paragraph">
<p>The topic turned out to be too big for a single article, so I have split it into multiple parts and maybe I should have split into even more. This is the third:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="/gitopscollection/2026-10-20-openshift-gitops-vs-acm/">[Ep.18] OpenShift GitOps or Advanced Cluster Management? Choosing the right tool</a> What each tool does, where they overlap and a decision guide.</p>
</li>
<li>
<p><a href="/gitopscollection/2026-10-23-acm-gitops-push-pull-agent/">[Ep.19] ACM and OpenShift GitOps: push, pull and the Argo CD Agent</a>: how ACM registers clusters in Argo CD, and how to set up each of the three delivery models.</p>
</li>
<li>
<p><strong>[Ep.20] Managing ACM Policies with OpenShift GitOps</strong> (this article): policies as code, the PolicyGenerator, hub templates and bootstrapping Argo CD with a policy.</p>
</li>
</ol>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Everything in this series was written against <strong>OpenShift GitOps 1.22</strong> (Argo CD 3.5) and <strong>Advanced Cluster Management 2.17</strong> (Open Cluster Management). Technology Preview and GA states move quickly in both products, so check the release notes of your versions before you commit to a design.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
While I am using the term &#34;Advanced Cluster Management&#34; in this article, I am referring to the product formerly known as Open Cluster Management. Same counts for Argo CD and OpenShift GitOps.
</td>
</tr>
</tbody></table>
</div>
<div class="sect1">
<h2 id="_three_integration_patterns">Three integration patterns</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There are three ways to combine policies and Argo CD. They are not exclusive, most mature setups combine the first two.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 12.5%;"/>
<col style="width: 37.5%;"/>
<col style="width: 25%;"/>
<col style="width: 25%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Pattern</th>
<th class="tableblock halign-left valign-top">How it works</th>
<th class="tableblock halign-left valign-top">Strength</th>
<th class="tableblock halign-left valign-top">Weakness</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>A: Argo CD deploys policies</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Policies live in Git, generated by the PolicyGenerator. The hub Argo CD syncs them to the hub, ACM propagates and evaluates them.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Policy as code with review, compliance dashboard in ACM</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Needs the PolicyGenerator plugin in Argo CD</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>B: A policy bootstraps Argo CD</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">One enforced policy installs OpenShift GitOps and a root Application on every placed cluster. From there, Argo CD takes over.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">New clusters configure themselves on import</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The bootstrap needs proper planning and automation.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>C: Policies configure directly</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ConfigurationPolicies apply the cluster configuration themselves. No Argo CD on the spokes.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">One tool, compliance built in</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Weaker diff and ordering, large YAML in policies</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>Pattern C is fine for small, compliance-driven setups. For everything else I recommend A for governance and B for the fleet bootstrap. The rest of this article shows both.</p>
</div>
<div class="paragraph">
<p>Whatever option you choose, one rule from <a href="/gitopscollection/2026-10-20-openshift-gitops-vs-acm/">Ep.18</a> still applies: <strong>one owner per object</strong>. If Argo CD manages an object, a policy may only look at it in <code>inform</code> mode.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_preparing_the_hub_argo_cd">Preparing the hub Argo CD</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You need an Argo CD instance on the hub that can sync to the hub itself. That instance needs three things before it can deploy policies:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>permissions for the policy API,</p>
</li>
<li>
<p>the PolicyGenerator plugin,</p>
</li>
<li>
<p>optionally, health checks for policies.</p>
</li>
</ol>
</div>
<div class="sect2">
<h3 id="_a_second_argo_cd_instance_for_the_hub">A second Argo CD instance for the hub</h3>
<div class="paragraph">
<p>In Ep.19, the default instance <code>openshift-gitops</code> became the principal of the Argo CD Agent. Its application-controller is disabled, so it cannot sync anything to the hub itself, and the manifests of agent Applications are rendered on the managed clusters anyway. The policies, however, must be created on the hub.</p>
</div>
<div class="paragraph">
<p>This article therefore uses a second, small Argo CD instance on the hub that only takes care of the hub configuration: <code>policy-gitops</code> in the namespace of the same name. If your default instance still has its application-controller (push or pull model), you can use it instead. Replace <code>policy-gitops</code> with <code>openshift-gitops</code> in the examples below.</p>
</div>
<div class="listingblock linenums">
<div class="title">Second Argo CD instance for the hub configuration</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: v1
kind: Namespace
metadata:
  name: policy-gitops
---
apiVersion: argoproj.io/v1beta1
kind: ArgoCD
metadata:
  name: policy-gitops <i class="conum" data-value="1"></i><b>(1)</b>
  namespace: policy-gitops
spec: {} <i class="conum" data-value="2"></i><b>(2)</b>
---
apiVersion: v1
kind: Namespace
metadata:
  name: acm-policies
  labels:
    argocd.argoproj.io/managed-by: policy-gitops <i class="conum" data-value="3"></i><b>(3)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The service account of the application-controller is named after the instance: <code>policy-gitops-argocd-application-controller</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The PolicyGenerator plugin is added in the next sections.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td><code>policy-gitops</code> is a namespace-scoped instance. The label allows it to manage the namespace <code>acm-policies</code>, where the policies live. The namespace must exist before the first sync, because the instance cannot create namespaces itself.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_permissions">Permissions</h3>
<div class="paragraph">
<p>The application-controller of the instance cannot create policies and Placements. Create a ClusterRole and bind it to the controller’s service account:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Not required if Argo CD runs as cluster-admin.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock linenums">
<div class="title">ClusterRole and ClusterRoleBinding for the hub Argo CD</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: openshift-gitops-policy-admin
rules:
  - apiGroups:
      - policy.open-cluster-management.io
    resources:
      - policies
      - configurationpolicies
      - certificatepolicies
      - operatorpolicies
      - policysets
      - placementbindings
    verbs: [&#34;get&#34;, &#34;list&#34;, &#34;watch&#34;, &#34;create&#34;, &#34;update&#34;, &#34;patch&#34;, &#34;delete&#34;]
  - apiGroups:
      - cluster.open-cluster-management.io
    resources:
      - placements
      - placements/status
      - placementdecisions
      - placementdecisions/status
    verbs: [&#34;get&#34;, &#34;list&#34;, &#34;watch&#34;, &#34;create&#34;, &#34;update&#34;, &#34;patch&#34;, &#34;delete&#34;]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: policy-gitops-policy-admin
subjects:
  - kind: ServiceAccount
    name: policy-gitops-argocd-application-controller
    namespace: policy-gitops
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: openshift-gitops-policy-admin</code></pre>
</div>
</div>
<div class="paragraph">
<p>The ClusterRole in the ACM documentation also contains <code>placementrules</code>. I left them out on purpose: PlacementRules are deprecated.</p>
</div>
</div>
<div class="sect2">
<h3 id="_the_policygenerator_plugin">The PolicyGenerator plugin</h3>
<div class="paragraph">
<p>Creating the policy YAML by hand is tough and error-prone. Every manifest has to be wrapped in a ConfigurationPolicy, which is wrapped in a Policy, which needs a Placement and a PlacementBinding. The <strong>PolicyGenerator</strong> solves this. It is a Kustomize generator plugin that takes plain manifests and wraps them for you.</p>
</div>
<div class="paragraph">
<p>The plugin is not part of the OpenShift GitOps images. An init container copies it from an ACM image into the repo-server, and Kustomize must be allowed to run alpha plugins.</p>
</div>
<div class="paragraph">
<p>The setup is described in the ACM documentation: <a href="https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/2.17/html/gitops/gitops-overview#access-policy-gen-gitops" rel="noopener" target="_blank">ACM 2.17: Accessing the Policy Generator from OpenShift GitOps</a>.</p>
</div>
<div class="listingblock linenums">
<div class="title">ArgoCD resource on the hub with the PolicyGenerator plugin (excerpt)</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: argoproj.io/v1beta1
kind: ArgoCD
metadata:
  name: policy-gitops
  namespace: policy-gitops
spec:
  kustomizeBuildOptions: --enable-alpha-plugins <i class="conum" data-value="1"></i><b>(1)</b>
  repo:
    env:
      - name: KUSTOMIZE_PLUGIN_HOME
        value: /etc/kustomize/plugin
    initContainers:
      - name: policy-generator-install
        image: registry.redhat.io/rhacm2/multicluster-operators-subscription-rhel9:v2.17 <i class="conum" data-value="2"></i><b>(2)</b>
        command:
          - /bin/bash
        args:
          - -c
          - cp /policy-generator/PolicyGenerator-not-fips-compliant /policy-generator-tmp/PolicyGenerator <i class="conum" data-value="3"></i><b>(3)</b>
        volumeMounts:
          - mountPath: /policy-generator-tmp
            name: policy-generator
    volumeMounts:
      - mountPath: /etc/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator
        name: policy-generator
    volumes:
      - name: policy-generator
        emptyDir: {}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Allows Kustomize to execute the generator plugin.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The tag must match the minor version of your ACM hub (<code>oc get multiclusterhub -n open-cluster-management -o jsonpath=&#39;{.items[0].status.currentVersion}&#39;</code>). Update it after every hub upgrade, or let a policy do it (see <a href="#_keeping_the_image_tag_in_sync">Keeping the image tag in sync</a>).</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Copies the plugin from the image to the plugin directory.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>If your policy folders contain Helm charts that should be rendered before the policies are generated, add the environment variable <code>POLICY_GEN_ENABLE_HELM</code> with the value <code>&#34;true&#34;</code> to <code>spec.repo.env</code>.</p>
</div>
<div class="sect3">
<h4 id="_keeping_the_image_tag_in_sync">Keeping the image tag in sync</h4>
<div class="paragraph">
<p>A fixed tag has one weakness: after a hub upgrade, the PolicyGenerator in the repo-server is still the old one until somebody updates the tag. The ACM documentation provides an example of a policy that keeps the image tag in sync. After an upgrade of the hub, the policy changes the image of the init container automatically.</p>
</div>
<div class="paragraph">
<p>The policy runs on the hub only, so it needs a Placement for <code>local-cluster</code>. The hub carries the label <code>local-cluster=true</code>, and it is part of the cluster set <code>global</code>, which must be bound to the policy namespace:</p>
</div>
<div class="listingblock linenums">
<div class="title">Policy that keeps the PolicyGenerator image in sync with the hub</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
  name: global
  namespace: acm-policies
spec:
  clusterSet: global <i class="conum" data-value="1"></i><b>(1)</b>
---
apiVersion: policy.open-cluster-management.io/v1
kind: Policy
metadata:
  name: argocd-policy-generator
  namespace: acm-policies
  annotations:
    policy.open-cluster-management.io/standards: NIST SP 800-53
    policy.open-cluster-management.io/categories: CM Configuration Management
    policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
spec:
  remediationAction: enforce <i class="conum" data-value="2"></i><b>(2)</b>
  disabled: false
  policy-templates:
    - objectDefinition:
        apiVersion: policy.open-cluster-management.io/v1
        kind: ConfigurationPolicy
        metadata:
          name: argocd-policy-generator
        spec:
          severity: medium
          object-templates:
            - complianceType: musthave
              objectDefinition:
                apiVersion: argoproj.io/v1beta1
                kind: ArgoCD
                metadata:
                  name: policy-gitops
                  namespace: policy-gitops
                spec:
                  kustomizeBuildOptions: --enable-alpha-plugins
                  repo:
                    env:
                      - name: KUSTOMIZE_PLUGIN_HOME
                        value: /etc/kustomize/plugin
                    initContainers:
                      - name: policy-generator-install
                        image: &#39;{{ (index (lookup &#34;apps/v1&#34; &#34;Deployment&#34; &#34;open-cluster-management&#34; &#34;multicluster-operators-hub-subscription&#34;).spec.template.spec.containers 0).image }}&#39; <i class="conum" data-value="3"></i><b>(3)</b>
                        command:
                          - /bin/bash
                        args:
                          - -c
                          - cp /policy-generator/PolicyGenerator-not-fips-compliant /policy-generator-tmp/PolicyGenerator
                        volumeMounts:
                          - mountPath: /policy-generator-tmp
                            name: policy-generator
                    volumeMounts:
                      - mountPath: /etc/kustomize/plugin/policy.open-cluster-management.io/v1/policygenerator
                        name: policy-generator
                    volumes:
                      - name: policy-generator
                        emptyDir: {}
---
apiVersion: cluster.open-cluster-management.io/v1beta1
kind: Placement
metadata:
  name: hub-only
  namespace: acm-policies
spec:
  clusterSets:
    - global
  predicates:
    - requiredClusterSelector:
        labelSelector:
          matchLabels:
            local-cluster: &#34;true&#34; <i class="conum" data-value="4"></i><b>(4)</b>
---
apiVersion: policy.open-cluster-management.io/v1
kind: PlacementBinding
metadata:
  name: argocd-policy-generator
  namespace: acm-policies
placementRef:
  apiGroup: cluster.open-cluster-management.io
  kind: Placement
  name: hub-only
subjects:
  - apiGroup: policy.open-cluster-management.io
    kind: Policy
    name: argocd-policy-generator</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The cluster set <code>global</code> contains every managed cluster, including the hub. The Placement below narrows it down to the hub. Creating a ManagedClusterSetBinding requires the permissions <code>managedclustersetbindings</code> and <code>managedclustersets/bind</code>, which are not part of the ClusterRole above. Create it once as cluster administrator, or extend the ClusterRole if Argo CD shall sync it.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>We enforce this policy.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td><code>lookup</code> reads the deployment of the ACM subscription controller, and the template takes the image of its first container. That is exactly the image the init container needs, in the version of the running hub.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>ACM sets this label on the hub’s own ManagedCluster.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Two things to keep in mind:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Write this policy as plain YAML</strong>, not as PolicyGenerator input. It installs the generator, so it cannot depend on it (hen-egg problem). Argo CD can sync it from Git without the plugin.</p>
</li>
<li>
<p><strong>One owner per object.</strong> The policy now manages the plugin part of the ArgoCD resource <code>policy-gitops</code>. If that resource is also deployed by Argo CD (for example, from a Helm chart for OpenShift GitOps), remove the plugin settings from there, or the two will overwrite each other.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_policy_health_in_argo_cd">Policy health in Argo CD</h3>
<div class="paragraph">
<p>By default, Argo CD considers a policy healthy as soon as it exists. That is not very useful: you want to see in Argo CD whether the policy is <strong>compliant</strong>. The policy collection of the Open Cluster Management project contains a policy that adds the matching health checks (<code>resourceHealthChecks</code>) to the ArgoCD resource: <a href="https://github.com/open-cluster-management-io/policy-collection/blob/main/stable/CM-Configuration-Management/argocd-policy-healthchecks.yaml" rel="noopener" target="_blank">argocd-policy-healthchecks.yaml</a>. The policy adds the health checks to every ArgoCD instance it finds on the cluster, so <code>policy-gitops</code> is covered as well. It is shipped with <code>remediationAction: inform</code>: set it to <code>enforce</code>, otherwise it only reports the missing health checks. After that, Argo CD shows a non-compliant policy as <strong>Degraded</strong>.</p>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_pattern_a_policies_as_code">Pattern A: policies as code</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Pattern A is the governance part of the integration: the policies live in Git, Argo CD on the hub brings them into the cluster, and ACM does the rest. You never create a policy in the ACM console or with <code>oc apply</code> again. Every change is a pull request, and the history of your compliance is stored in Git.</p>
</div>
<div class="paragraph">
<p>The example in this section builds two policies that show both sides of a policy:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>service-mesh</strong> installs Red Hat OpenShift Service Mesh 3 on the selected clusters: the Operator and a control plane. It is <em>enforced</em> and the manifests are applied in a fixed order, because the control plane resources can only be created after the Operator has installed its CRDs.</p>
</li>
<li>
<p><strong>no-kubeadmin</strong> checks that the <code>kubeadmin</code> secret does not exist anymore. It only <em>informs</em>: ACM reports every cluster where the secret is still present, but nothing is deleted automatically.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Both start as plain Kubernetes manifests in Git. The PolicyGenerator wraps them into Policy, Placement and PlacementBinding, so you do not have to write the policy structure yourself.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This requires the hub Argo CD instance <code>policy-gitops</code> with the PolicyGenerator plugin, as described in the previous section.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The following diagram shows the complete flow, from Git to the compliance status in ACM and Argo CD:</p>
</div>
<div class="paragraph">
<div class="imageblock animated-svg" data-animated-svg>
  <div class="content">
<svg width="1400" height="680" viewBox="0 0 1400 680" role="img" aria-label="Policies as code: the hub Argo CD renders Policy, Placement and PlacementBinding from Git into the namespace acm-policies. ACM propagates a replicated policy per selected cluster, the policy framework on the managed cluster evaluates and enforces it, and the compliance status flows back to the ACM governance view and, with health checks, to Argo CD." version="1.1" id="as95c1e90-svg-policies-as-code" xmlns="http://www.w3.org/2000/svg" xmlns:c2pa="http://c2pa.org/manifest">
  <title id="as95c1e90-title-policies-as-code">Policies as code: the hub Argo CD renders Policy, Placement and PlacementBinding from Git into the namespace acm-policies. ACM propagates a replicated policy per selected cluster, the policy framework on the managed cluster evaluates and enforces it, and the compliance status flows back to the ACM governance view and, with health checks, to Argo CD.</title>
  <defs id="as95c1e90-defs-policies-as-code">
    <marker id="as95c1e90-arrow-0F766E" viewBox="0 0 10 10" refX="8.5" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="#0F766E" id="as95c1e90-marker-path-0F766E" /></marker>
    <marker id="as95c1e90-arrow-C2410C" viewBox="0 0 10 10" refX="8.5" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="#C2410C" id="as95c1e90-marker-path-C2410C" /></marker>
    <marker id="as95c1e90-arrow-4B5563" viewBox="0 0 10 10" refX="8.5" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="#4B5563" id="as95c1e90-marker-path-4B5563" /></marker>
    </defs>
  <rect id="as95c1e90-bg" width="1400" height="680" fill="#FFFFFF" />
  <rect id="as95c1e90-zone-git" x="20" y="20" width="210" height="400" rx="14" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5" />
  <text id="as95c1e90-label-git" x="40" y="48" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#4B5563" text-anchor="start">GIT</text>
  <rect id="as95c1e90-zone-hub" x="250" y="20" width="1130" height="400" rx="14" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5" />
  <text id="as95c1e90-label-hub" x="270" y="48" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#4B5563" text-anchor="start">HUB</text>
  <rect id="as95c1e90-zone-spoke" x="250" y="450" width="1130" height="190" rx="14" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5" />
  <text id="as95c1e90-label-spoke" x="270" y="478" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#4B5563" text-anchor="start">MANAGED CLUSTERS  ·  bm, sno</text>
  <rect id="as95c1e90-ns-gitops" x="270" y="60" width="290" height="340" rx="10" fill="#FFFFFF" stroke="#CBD5E1" stroke-width="1.2" />
  <text id="as95c1e90-label-ns-gitops" x="286" y="84" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#C2410C" text-anchor="start">openshift-gitops</text>
  <rect id="as95c1e90-ns-policies" x="580" y="60" width="320" height="340" rx="10" fill="#FFFFFF" stroke="#CBD5E1" stroke-width="1.2" />
  <text id="as95c1e90-label-ns-policies" x="596" y="84" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#0F766E" text-anchor="start">acm-policies</text>
  <rect id="as95c1e90-ns-cluster" x="920" y="60" width="440" height="340" rx="10" fill="#FFFFFF" stroke="#CBD5E1" stroke-width="1.2" />
  <text id="as95c1e90-label-ns-cluster" x="936" y="84" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#4B5563" text-anchor="start">cluster namespaces  ·  bm, sno</text>
  <rect id="as95c1e90-rect-git" x="40" y="100" width="170" height="120" rx="10" fill="#E6F4F1" stroke="#0F766E" stroke-width="1.6" />
  <text id="as95c1e90-title-git" x="56" y="129" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#0F766E" text-anchor="start">Git</text>
  <text id="as95c1e90-line0-git" x="56" y="152" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">input/: plain</text>
  <text id="as95c1e90-line1-git" x="56" y="168" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">manifests, plus the</text>
  <text id="as95c1e90-line2-git" x="56" y="184" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">generator config</text>
  <text id="as95c1e90-note-git1" x="40" y="250" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#4B5563" text-anchor="start">Every policy change</text>
  <text id="as95c1e90-note-git2" x="40" y="266" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#4B5563" text-anchor="start">is a pull request.</text>
  <rect id="as95c1e90-rect-argocd" x="290" y="100" width="250" height="120" rx="10" fill="#FDF0E8" stroke="#C2410C" stroke-width="1.6" />
  <text id="as95c1e90-title-argocd" x="306" y="129" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#C2410C" text-anchor="start">hub Argo CD</text>
  <text id="as95c1e90-line0-argocd" x="306" y="152" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">renders the policies</text>
  <text id="as95c1e90-line1-argocd" x="306" y="168" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">(PolicyGenerator plugin</text>
  <text id="as95c1e90-line2-argocd" x="306" y="184" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">or Helm chart) and syncs</text>
  <circle id="as95c1e90-badge-1" cx="520" cy="120" r="11" fill="#1F2937" />
  <text id="as95c1e90-badge-1-text" x="520" y="124.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">1</text>
  <rect id="as95c1e90-rect-policies" x="600" y="100" width="280" height="120" rx="10" fill="#FFFFFF" stroke="#C2410C" stroke-width="1.6" stroke-dasharray="6 4" />
  <text id="as95c1e90-title-policies" x="616" y="129" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#C2410C" text-anchor="start">Policies</text>
  <text id="as95c1e90-line0-policies" x="616" y="152" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">Policy, Placement,</text>
  <text id="as95c1e90-line1-policies" x="616" y="168" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#4B5563" text-anchor="start">PlacementBinding</text>
  <text id="as95c1e90-line2-policies" x="616" y="184" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">rendered from Git</text>
  <circle id="as95c1e90-badge-2" cx="860" cy="120" r="11" fill="#1F2937" />
  <text id="as95c1e90-badge-2-text" x="860" y="124.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">2</text>
  <rect id="as95c1e90-rect-replicated" x="940" y="100" width="400" height="120" rx="10" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text id="as95c1e90-title-replicated" x="956" y="129" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#0F766E" text-anchor="start">Replicated policies</text>
  <text id="as95c1e90-line0-replicated" x="956" y="152" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">acm-policies.&lt;policy&gt; in bm and sno</text>
  <text id="as95c1e90-line1-replicated" x="956" y="168" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">created by ACM for every selected cluster,</text>
  <text id="as95c1e90-line2-replicated" x="956" y="184" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">IgnoreExtraneous set automatically</text>
  <circle id="as95c1e90-badge-3" cx="1320" cy="120" r="11" fill="#1F2937" />
  <text id="as95c1e90-badge-3-text" x="1320" y="124.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">3</text>
  <rect id="as95c1e90-rect-health" x="290" y="260" width="250" height="110" rx="10" fill="#F1F5F9" stroke="#4B5563" stroke-width="1.4" />
  <text id="as95c1e90-title-health" x="306" y="289" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#4B5563" text-anchor="start">Argo CD health</text>
  <text id="as95c1e90-line0-health" x="306" y="312" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">Healthy if compliant,</text>
  <text id="as95c1e90-line1-health" x="306" y="328" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">Degraded if not (with the</text>
  <text id="as95c1e90-line2-health" x="306" y="344" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">policy health checks)</text>
  <circle id="as95c1e90-badge-6" cx="520" cy="280" r="11" fill="#1F2937" />
  <text id="as95c1e90-badge-6-text" x="520" y="284.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">6</text>
  <rect id="as95c1e90-rect-governance" x="940" y="260" width="300" height="110" rx="10" fill="#F1F5F9" stroke="#4B5563" stroke-width="1.4" />
  <text id="as95c1e90-title-governance" x="956" y="289" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#4B5563" text-anchor="start">ACM governance</text>
  <text id="as95c1e90-line0-governance" x="956" y="312" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">compliance per policy and</text>
  <text id="as95c1e90-line1-governance" x="956" y="328" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">cluster, with history</text>
  <circle id="as95c1e90-badge-5" cx="1220" cy="280" r="11" fill="#1F2937" />
  <text id="as95c1e90-badge-5-text" x="1220" y="284.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">5</text>
  <rect id="as95c1e90-rect-framework" x="940" y="500" width="400" height="110" rx="10" fill="#F1F5F9" stroke="#4B5563" stroke-width="1.4" />
  <text id="as95c1e90-title-framework" x="956" y="529" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#4B5563" text-anchor="start">Policy framework</text>
  <text id="as95c1e90-line0-framework" x="956" y="552" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">pulls the replicated policy,</text>
  <text id="as95c1e90-line1-framework" x="956" y="568" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">evaluates it and enforces it</text>
  <text id="as95c1e90-line2-framework" x="956" y="584" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">(inform or enforce)</text>
  <circle id="as95c1e90-badge-4" cx="1320" cy="520" r="11" fill="#1F2937" />
  <text id="as95c1e90-badge-4-text" x="1320" y="524.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">4</text>
  <rect id="as95c1e90-rect-resources" x="600" y="500" width="280" height="110" rx="10" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text id="as95c1e90-title-resources" x="616" y="529" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#0F766E" text-anchor="start">Objects on the spoke</text>
  <text id="as95c1e90-line0-resources" x="616" y="552" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">created or checked</text>
  <text id="as95c1e90-line1-resources" x="616" y="568" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">by the policy</text>
  <path id="as95c1e90-flow-git-argocd" d="M 212 160 L 286 160" fill="none" stroke="#4B5563" stroke-width="2" stroke-linejoin="round" marker-end="url(#as95c1e90-arrow-4B5563)" />
  <text id="as95c1e90-label-sync" x="249" y="151" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="11" font-weight="600" fill="#4B5563" text-anchor="middle">sync</text>
  <path id="as95c1e90-flow-argocd-policies" d="M 542 160 L 596 160" fill="none" stroke="#C2410C" stroke-width="2" stroke-linejoin="round" marker-end="url(#as95c1e90-arrow-C2410C)" />
  <path id="as95c1e90-flow-policies-replicated" d="M 882 150 L 936 150" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#as95c1e90-arrow-0F766E)" />
  <path id="as95c1e90-flow-replicated-framework" d="M 1290 222 L 1290 496" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#as95c1e90-arrow-0F766E)" />
  <text id="as95c1e90-label-pulled" x="1280" y="440" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="11" font-weight="600" fill="#0F766E" text-anchor="end">pulled by the spoke</text>
  <path id="as95c1e90-flow-framework-resources" d="M 938 555 L 884 555" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#as95c1e90-arrow-0F766E)" />
  <path id="as95c1e90-status-framework-replicated" d="M 1320 498 L 1320 224" fill="none" stroke="#0F766E" stroke-width="1.6" stroke-linejoin="round" stroke-dasharray="5 3" marker-end="url(#as95c1e90-arrow-0F766E)" />
  <text id="as95c1e90-label-status" x="1330" y="440" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="11" font-weight="600" fill="#0F766E" text-anchor="start">status</text>
  <path id="as95c1e90-status-replicated-policies" d="M 938 200 L 884 200" fill="none" stroke="#0F766E" stroke-width="1.6" stroke-linejoin="round" stroke-dasharray="5 3" marker-end="url(#as95c1e90-arrow-0F766E)" />
  <path id="as95c1e90-status-replicated-governance" d="M 1090 222 L 1090 256" fill="none" stroke="#0F766E" stroke-width="1.6" stroke-linejoin="round" stroke-dasharray="5 3" marker-end="url(#as95c1e90-arrow-0F766E)" />
  <path id="as95c1e90-status-policies-health" d="M 740 222 L 740 315 L 544 315" fill="none" stroke="#0F766E" stroke-width="1.6" stroke-linejoin="round" stroke-dasharray="5 3" marker-end="url(#as95c1e90-arrow-0F766E)" />
  <text id="as95c1e90-label-compliant" x="642" y="307" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="11" font-weight="600" fill="#0F766E" text-anchor="middle">status.compliant</text>
  <rect id="as95c1e90-legend-you" x="40" y="652" width="22" height="14" rx="3" fill="#E6F4F1" stroke="#0F766E" stroke-width="1.6" />
  <text id="as95c1e90-legend-you-text" x="70" y="664" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">created by you</text>
  <rect id="as95c1e90-legend-acm" x="194.609375" y="652" width="22" height="14" rx="3" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text id="as95c1e90-legend-acm-text" x="224.609375" y="664" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">generated by ACM</text>
  <rect id="as95c1e90-legend-argo" x="370.5625" y="652" width="22" height="14" rx="3" fill="#FFFFFF" stroke="#C2410C" stroke-width="1.6" stroke-dasharray="6 4" />
  <text id="as95c1e90-legend-argo-text" x="400.5625" y="664" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">generated by Argo CD</text>
  <rect id="as95c1e90-legend-platform" x="566.984375" y="652" width="22" height="14" rx="3" fill="#F1F5F9" stroke="#4B5563" stroke-width="1.6" />
  <text id="as95c1e90-legend-platform-text" x="596.984375" y="664" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">platform component</text>
  <text id="as95c1e90-legend-extra" x="1380" y="664" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="600" fill="#4B5563" text-anchor="end">Dashed arrows: compliance status back to the hub</text>
<circle class="flow-dot" style="--d:0.00s" visibility="hidden" r="3.5" fill="#4B5563" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 212 160 L 286 160" begin="indefinite" data-begin="0.00" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:0.40s" visibility="hidden" r="4.5" fill="#C2410C" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 542 160 L 596 160" begin="indefinite" data-begin="0.40" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:0.80s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 882 150 L 936 150" begin="indefinite" data-begin="0.80" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:1.20s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 1290 222 L 1290 496" begin="indefinite" data-begin="1.20" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:1.60s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 938 555 L 884 555" begin="indefinite" data-begin="1.60" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:2.00s" visibility="hidden" r="3.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 1320 498 L 1320 224" begin="indefinite" data-begin="2.00" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:2.40s" visibility="hidden" r="3.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 938 200 L 884 200" begin="indefinite" data-begin="2.40" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:2.40s" visibility="hidden" r="3.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 1090 222 L 1090 256" begin="indefinite" data-begin="2.40" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:2.80s" visibility="hidden" r="3.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 740 222 L 740 315 L 544 315" begin="indefinite" data-begin="2.80" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  </svg>
</div>
  <div class="title">Policies as code: from plain manifests in Git to compliance on every cluster</div>
</div>

</div>
<div class="paragraph">
<p>What happens under the hood:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The <strong>hub Argo CD</strong> renders the policies from Git and syncs them to the hub.</p>
</li>
<li>
<p>The result is a set of <strong>Policy</strong>, <strong>Placement</strong> and <strong>PlacementBinding</strong> objects in the namespace <code>acm-policies</code>.</p>
</li>
<li>
<p>ACM creates a <strong>replicated policy</strong> in the namespace of every selected cluster on the hub.</p>
</li>
<li>
<p>The <strong>policy framework</strong> on each managed cluster pulls its replicated policy, evaluates it and, in <code>enforce</code> mode, fixes what is different.</p>
</li>
<li>
<p>The compliance status flows back to the hub and shows up in the <strong>ACM governance</strong> view, per policy and cluster.</p>
</li>
<li>
<p>With the policy health checks, Argo CD shows a non-compliant policy as <strong>Degraded</strong>.</p>
</li>
</ol>
</div>
<hr/>
<div class="sect2">
<h3 id="_repository_layout">Repository layout</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-text hljs" data-lang="text">acm-policies/
├── kustomization.yaml
├── policy-generator.yaml
└── input
    ├── service-mesh
    │   ├── 01-subscription.yaml       # OpenShift Service Mesh 3 Operator
    │   ├── 02-namespace-istio-system.yaml
    │   ├── 03-namespace-istio-cni.yaml
    │   ├── 04-istiocni.yaml           # CNI plugin, required on OpenShift
    │   └── 05-istio.yaml              # the control plane
    └── no-kubeadmin
        └── kubeadmin-secret.yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p>The files in <code>input/</code> are plain Kubernetes manifests, exactly as you would apply them with <code>oc apply</code>. The Operator is installed in the namespace <code>openshift-operators</code>, which already has an OperatorGroup for all namespaces, so neither a namespace nor an OperatorGroup is needed for it:</p>
</div>
<div class="listingblock linenums">
<div class="title">input/service-mesh/01-subscription.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: servicemeshoperator3
  namespace: openshift-operators
spec:
  channel: stable-3.4 <i class="conum" data-value="1"></i><b>(1)</b>
  installPlanApproval: Automatic
  name: servicemeshoperator3
  source: redhat-operators
  sourceNamespace: openshift-marketplace</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Pins the minor version. Use <code>stable</code> to always get the latest version.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The control plane consists of two cluster-scoped resources, <code>IstioCNI</code> and <code>Istio</code>, each pointing to its own namespace (<code>istio-cni</code> and <code>istio-system</code>):</p>
</div>
<div class="listingblock linenums">
<div class="title">input/service-mesh/04-istiocni.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: sailoperator.io/v1
kind: IstioCNI
metadata:
  name: default
spec:
  namespace: istio-cni</code></pre>
</div>
</div>
<div class="listingblock linenums">
<div class="title">input/service-mesh/05-istio.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: sailoperator.io/v1
kind: Istio
metadata:
  name: default
spec:
  namespace: istio-system</code></pre>
</div>
</div>
<div class="paragraph">
<p>And the kubeadmin secret that must not exist:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
if your original kubeadmin secret is still present, you can ignore this yaml. Honestly, I am not even sure if this would work, once you have removed the secret.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock linenums">
<div class="title">input/no-kubeadmin/kubeadmin-secret.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: v1
kind: Secret
metadata:
  name: kubeadmin
  namespace: kube-system</code></pre>
</div>
</div>
<div class="paragraph">
<p>The <code>kustomization.yaml</code> only references the generator:</p>
</div>
<div class="listingblock linenums">
<div class="title">kustomization.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">generators:
  - policy-generator.yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p>Render the folder locally before you push. If it does not render on your machine, it will not render in Argo CD either. With the PolicyGenerator binary in your Kustomize plugin path:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">kustomize build --enable-alpha-plugins acm-policies/</code></pre>
</div>
</div>
<div class="paragraph">
<p>The output contains a Policy, a Placement and a PlacementBinding per policy.</p>
</div>
<hr/>
</div>
<div class="sect2">
<h3 id="_the_policygenerator_configuration">The PolicyGenerator configuration</h3>
<div class="paragraph">
<p>The file <code>policy-generator.yaml</code> is the heart of the setup. It does not contain any policy itself, it only describes which policies the generator shall create from the manifests in <code>input/</code>. It has two parts:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>policyDefaults</code> apply to every policy: the namespace on the hub where the policies are created, the default remediation action and severity, and the Placement that decides which clusters receive them.</p>
</li>
<li>
<p><code>policies</code> lists the policies, each with its name, the manifests it contains and the settings that differ from the defaults.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For every entry in <code>policies</code>, the generator creates a Policy, a Placement and a PlacementBinding. The manifests are wrapped into a ConfigurationPolicy inside the Policy: by default all manifests of a policy into one, with <code>consolidateManifests: false</code> one per manifest. Our two policies use this as follows: <code>service-mesh</code> overrides the defaults to enforce and to apply its manifests in order, while <code>no-kubeadmin</code> keeps the defaults and only changes the compliance type.</p>
</div>
<div class="listingblock linenums">
<div class="title">policy-generator.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: policy.open-cluster-management.io/v1
kind: PolicyGenerator
metadata:
  name: cluster-baseline
policyDefaults:
  namespace: acm-policies
  remediationAction: inform <i class="conum" data-value="1"></i><b>(1)</b>
  severity: medium
  placement:
    labelSelector:
      matchExpressions:
        - key: name <i class="conum" data-value="5"></i><b>(5)</b>
          operator: In
          values:
            - sno
            - bm
policies:
  - name: service-mesh
    remediationAction: enforce <i class="conum" data-value="2"></i><b>(2)</b>
    orderManifests: true <i class="conum" data-value="3"></i><b>(3)</b>
    consolidateManifests: false
    manifests:
      - path: input/service-mesh/01-subscription.yaml
      - path: input/service-mesh/02-namespace-istio-system.yaml
      - path: input/service-mesh/03-namespace-istio-cni.yaml
      - path: input/service-mesh/04-istiocni.yaml
      - path: input/service-mesh/05-istio.yaml
  - name: no-kubeadmin
    manifests:
      - path: input/no-kubeadmin/
        complianceType: mustnothave <i class="conum" data-value="4"></i><b>(4)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Default for all policies: report only.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>This policy is enforced.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Creates one ConfigurationPolicy per manifest and makes each one depend on the previous one: first the Subscription, then the namespaces, then IstioCNI and Istio. Note that the Subscription policy is compliant as soon as the Subscription exists, not when the Operator is installed. Until the CRDs are there, the IstioCNI policy reports an error and is evaluated again. If you want to wait for the installed Operator, use an OperatorPolicy instead of the Subscription, as shown in Pattern B.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The kubeadmin secret must not exist. In inform mode, ACM reports every cluster where it still exists. Remove it with care, only after an identity provider is configured.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Selects the clusters <code>sno</code> and <code>bm</code>. ACM sets the label <code>name</code> on every ManagedCluster. For a growing fleet, a label such as <code>environment=production</code> or the cluster set label <code>cluster.open-cluster-management.io/clusterset</code> scales better than a list of names.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_bind_the_cluster_sets_to_the_policy_namespace">Bind the cluster sets to the policy namespace</h3>
<div class="paragraph">
<p>A Placement only sees the clusters of cluster sets that are bound to its own namespace. The bindings from Ep.19 live in <code>openshift-gitops</code>, so the Placements in <code>acm-policies</code> would find no cluster at all. ACM then shows the warning <em>&#34;ClusterSets failed to load. Verify that there is at least one ClusterSet bound to your selected namespace.&#34;</em></p>
</div>
<div class="paragraph">
<p>Bind the cluster set <code>production</code> to <code>acm-policies</code>, and <code>global</code> as well if you use the policy that keeps the PolicyGenerator image in sync (its Placement selects the hub from <code>global</code>):</p>
</div>
<div class="listingblock linenums">
<div class="title">ManagedClusterSetBindings in the policy namespace</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
  name: production
  namespace: acm-policies
spec:
  clusterSet: production
---
apiVersion: cluster.open-cluster-management.io/v1beta2
kind: ManagedClusterSetBinding
metadata:
  name: global
  namespace: acm-policies
spec:
  clusterSet: global</code></pre>
</div>
</div>
<div class="paragraph">
<p>The generated Placements select <code>sno</code> and <code>bm</code> by name, from the cluster sets bound to <code>acm-policies</code>. Check the result:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get placementdecisions -n acm-policies \
  -o custom-columns=NAME:.metadata.name,CLUSTERS:.status.decisions[*].clusterName</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_the_argo_cd_application">The Argo CD Application</h3>
<div class="paragraph">
<p>On the hub, one Application syncs the folder:</p>
</div>
<div class="listingblock linenums">
<div class="title">Application for the policies</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: acm-policies
  namespace: policy-gitops <i class="conum" data-value="1"></i><b>(1)</b>
spec:
  project: default
  source:
    repoURL: https://github.com/tjungbauer/acm-policies.git
    targetRevision: main
    path: .
  destination:
    server: https://kubernetes.default.svc
    namespace: acm-policies
  syncPolicy:
    automated:
      prune: true
      selfHeal: true</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The Application belongs to the instance <code>policy-gitops</code>. No <code>CreateNamespace=true</code>: the namespace <code>acm-policies</code> already exists with the <code>managed-by</code> label.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_replicated_policies">Replicated policies</h3>
<div class="paragraph">
<p>When ACM propagates a policy, it creates a copy in the namespace of every managed cluster on the hub, the <strong>replicated policy</strong>. Argo CD could treat these copies as extraneous resources of the Application and show it as <em>OutOfSync</em> or even try to delete them. ACM prevents that: it automatically sets the annotation <code>argocd.argoproj.io/compare-options: IgnoreExtraneous</code> on every replicated policy.</p>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_pattern_b_a_policy_bootstraps_argo_cd">Pattern B: a policy bootstraps Argo CD</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The bootstrap question from <a href="/gitopscollection/2026-10-20-openshift-gitops-vs-acm/">Ep.18</a>: who installs Argo CD on a new cluster? With ACM, the answer is a policy. As soon as a cluster is imported and matches the Placement of the policy, the policy installs OpenShift GitOps and creates a root Application that points to the cluster’s folder in Git. From there, Argo CD configures the rest.</p>
</div>
<div class="paragraph">
<div class="imageblock animated-svg" data-animated-svg>
  <div class="content">
<svg width="1400" height="720" viewBox="0 0 1400 720" role="img" aria-label="Bootstrap policy: the Placement selects the ManagedClusters sno and bm by their name label. The enforced policy gitops-bootstrap applies five templates in order: namespace, OperatorPolicy for OpenShift GitOps, ClusterRoleBinding, repository secret and root Application. The local Argo CD then syncs everything else from Git." version="1.1" id="asa8d4a31-svg-bootstrap-policy" xmlns="http://www.w3.org/2000/svg" xmlns:c2pa="http://c2pa.org/manifest">
  <title id="asa8d4a31-title-bootstrap-policy">Bootstrap policy: the Placement selects the ManagedClusters sno and bm by their name label. The enforced policy gitops-bootstrap applies five templates in order: namespace, OperatorPolicy for OpenShift GitOps, ClusterRoleBinding, repository secret and root Application. The local Argo CD then syncs everything else from Git.</title>
  <defs id="asa8d4a31-defs-bootstrap-policy">
    <marker id="asa8d4a31-arrow-0F766E" viewBox="0 0 10 10" refX="8.5" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="#0F766E" id="asa8d4a31-marker-path-0F766E" /></marker>
    <marker id="asa8d4a31-arrow-C2410C" viewBox="0 0 10 10" refX="8.5" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="#C2410C" id="asa8d4a31-marker-path-C2410C" /></marker>
    <marker id="asa8d4a31-arrow-4B5563" viewBox="0 0 10 10" refX="8.5" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M 0 0 L 10 5 L 0 10 z" fill="#4B5563" id="asa8d4a31-marker-path-4B5563" /></marker>
    </defs>
  <rect id="asa8d4a31-bg" width="1400" height="720" fill="#FFFFFF" />
  <rect id="asa8d4a31-zone-hub" x="20" y="20" width="560" height="660" rx="14" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5" />
  <text id="asa8d4a31-label-hub" x="40" y="48" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#4B5563" text-anchor="start">HUB</text>
  <rect id="asa8d4a31-zone-spoke" x="610" y="20" width="770" height="660" rx="14" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5" />
  <text id="asa8d4a31-label-spoke" x="630" y="48" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#4B5563" text-anchor="start">MANAGED CLUSTER  ·  sno</text>
  <rect style="--d:0.20s" class="rv" id="asa8d4a31-rect-cluster" x="40" y="70" width="250" height="100" rx="10" fill="#E6F4F1" stroke="#0F766E" stroke-width="1.6" />
  <text style="--d:0.20s" class="rv" id="asa8d4a31-title-cluster" x="56" y="99" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#0F766E" text-anchor="start">ManagedCluster sno</text>
  <text style="--d:0.20s" class="rv" id="asa8d4a31-line0-cluster" x="56" y="122" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#1F2937" text-anchor="start">label name=sno</text>
  <text style="--d:0.20s" class="rv" id="asa8d4a31-line1-cluster" x="56" y="138" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">the only manual step</text>
  <rect style="--d:0.20s" class="rv" id="asa8d4a31-rect-placement" x="310" y="70" width="250" height="100" rx="10" fill="#E6F4F1" stroke="#0F766E" stroke-width="1.6" />
  <text style="--d:0.20s" class="rv" id="asa8d4a31-title-placement" x="326" y="99" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#0F766E" text-anchor="start">Placement</text>
  <text style="--d:0.20s" class="rv" id="asa8d4a31-line0-placement" x="326" y="122" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">labelSelector</text>
  <text style="--d:0.20s" class="rv" id="asa8d4a31-line1-placement" x="326" y="138" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#1F2937" text-anchor="start">name in [sno, bm]</text>
  <path style="--d:0.20s" class="rv" id="asa8d4a31-flow-cluster-placement" d="M 292 120 L 306 120" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-0F766E)" />
  <rect style="--d:0.70s" class="rv" id="asa8d4a31-ns-policies" x="40" y="196" width="520" height="464" rx="10" fill="#FFFFFF" stroke="#CBD5E1" stroke-width="1.2" />
  <text style="--d:0.70s" class="rv" id="asa8d4a31-label-ns-policies" x="56" y="220" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="700" fill="#0F766E" text-anchor="start">acm-policies</text>
  <rect style="--d:0.70s" class="rv" id="asa8d4a31-rect-policy" x="56" y="232" width="488" height="412" rx="10" fill="#E6F4F1" stroke="#0F766E" stroke-width="1.6" />
  <text style="--d:0.70s" class="rv" id="asa8d4a31-title-policy" x="72" y="261" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#0F766E" text-anchor="start">Policy gitops-bootstrap</text>
  <text style="--d:0.70s" class="rv" id="asa8d4a31-line0-policy" x="72" y="282" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">enforce · templates applied in order, each one waits</text>
  <text style="--d:0.70s" class="rv" id="asa8d4a31-line1-policy" x="72" y="298" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">until the previous one is compliant</text>
  <rect style="--d:1.30s" class="rv" id="asa8d4a31-rect-tpl1" x="72" y="316" width="456" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.4" />
  <circle style="--d:1.30s" class="rv" id="asa8d4a31-badge-tpl1" cx="96" cy="342" r="12" fill="#0F766E" />
  <text style="--d:1.30s" class="rv" id="asa8d4a31-badge-tpl1-text" x="96" y="346.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">1</text>
  <text style="--d:1.30s" class="rv" id="asa8d4a31-title-tpl1" x="120" y="338" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">Namespace</text>
  <text style="--d:1.30s" class="rv" id="asa8d4a31-line0-tpl1" x="120" y="356" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">openshift-gitops-operator</text>
  <rect style="--d:1.70s" class="rv" id="asa8d4a31-rect-obj1" x="650" y="316" width="320" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text style="--d:1.70s" class="rv" id="asa8d4a31-title-obj1" x="666" y="338" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">Namespace</text>
  <text style="--d:1.70s" class="rv" id="asa8d4a31-line0-obj1" x="666" y="356" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#4B5563" text-anchor="start">openshift-gitops-operator</text>
  <path style="--d:1.70s" class="rv" id="asa8d4a31-flow-tpl1" d="M 530 342 L 646 342" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-0F766E)" />
  <rect style="--d:2.10s" class="rv" id="asa8d4a31-rect-tpl2" x="72" y="380" width="456" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.4" />
  <circle style="--d:2.10s" class="rv" id="asa8d4a31-badge-tpl2" cx="96" cy="406" r="12" fill="#0F766E" />
  <text style="--d:2.10s" class="rv" id="asa8d4a31-badge-tpl2-text" x="96" y="410.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">2</text>
  <text style="--d:2.10s" class="rv" id="asa8d4a31-title-tpl2" x="120" y="402" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">OperatorPolicy</text>
  <text style="--d:2.10s" class="rv" id="asa8d4a31-line0-tpl2" x="120" y="420" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">OpenShift GitOps, channel gitops-1.22</text>
  <rect style="--d:2.50s" class="rv" id="asa8d4a31-rect-obj2" x="650" y="380" width="320" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text style="--d:2.50s" class="rv" id="asa8d4a31-title-obj2" x="666" y="402" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">OpenShift GitOps</text>
  <text style="--d:2.50s" class="rv" id="asa8d4a31-line0-obj2" x="666" y="420" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#4B5563" text-anchor="start">operator and default Argo CD instance</text>
  <path style="--d:2.50s" class="rv" id="asa8d4a31-flow-tpl2" d="M 530 406 L 646 406" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-0F766E)" />
  <rect style="--d:2.90s" class="rv" id="asa8d4a31-rect-tpl3" x="72" y="444" width="456" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.4" />
  <circle style="--d:2.90s" class="rv" id="asa8d4a31-badge-tpl3" cx="96" cy="470" r="12" fill="#0F766E" />
  <text style="--d:2.90s" class="rv" id="asa8d4a31-badge-tpl3-text" x="96" y="474.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">3</text>
  <text style="--d:2.90s" class="rv" id="asa8d4a31-title-tpl3" x="120" y="466" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">ClusterRoleBinding</text>
  <text style="--d:2.90s" class="rv" id="asa8d4a31-line0-tpl3" x="120" y="484" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">rights for the local application-controller</text>
  <rect style="--d:3.30s" class="rv" id="asa8d4a31-rect-obj3" x="650" y="444" width="320" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text style="--d:3.30s" class="rv" id="asa8d4a31-title-obj3" x="666" y="466" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">ClusterRoleBinding</text>
  <text style="--d:3.30s" class="rv" id="asa8d4a31-line0-obj3" x="666" y="484" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#4B5563" text-anchor="start">local controller may deploy</text>
  <path style="--d:3.30s" class="rv" id="asa8d4a31-flow-tpl3" d="M 530 470 L 646 470" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-0F766E)" />
  <rect style="--d:3.70s" class="rv" id="asa8d4a31-rect-tpl4" x="72" y="508" width="456" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.4" />
  <circle style="--d:3.70s" class="rv" id="asa8d4a31-badge-tpl4" cx="96" cy="534" r="12" fill="#0F766E" />
  <text style="--d:3.70s" class="rv" id="asa8d4a31-badge-tpl4-text" x="96" y="538.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">4</text>
  <text style="--d:3.70s" class="rv" id="asa8d4a31-title-tpl4" x="120" y="530" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">Repository secret</text>
  <text style="--d:3.70s" class="rv" id="asa8d4a31-line0-tpl4" x="120" y="548" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">copySecretData from the hub</text>
  <rect style="--d:4.10s" class="rv" id="asa8d4a31-rect-obj4" x="650" y="508" width="320" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text style="--d:4.10s" class="rv" id="asa8d4a31-title-obj4" x="666" y="530" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">Repository secret</text>
  <text style="--d:4.10s" class="rv" id="asa8d4a31-line0-obj4" x="666" y="548" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#4B5563" text-anchor="start">Git credentials for the local Argo CD</text>
  <path style="--d:4.10s" class="rv" id="asa8d4a31-flow-tpl4" d="M 530 534 L 646 534" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-0F766E)" />
  <rect style="--d:4.50s" class="rv" id="asa8d4a31-rect-tpl5" x="72" y="572" width="456" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.4" />
  <circle style="--d:4.50s" class="rv" id="asa8d4a31-badge-tpl5" cx="96" cy="598" r="12" fill="#0F766E" />
  <text style="--d:4.50s" class="rv" id="asa8d4a31-badge-tpl5-text" x="96" y="602.5" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#FFFFFF" text-anchor="middle">5</text>
  <text style="--d:4.50s" class="rv" id="asa8d4a31-title-tpl5" x="120" y="594" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">Root Application</text>
  <text style="--d:4.50s" class="rv" id="asa8d4a31-line0-tpl5" x="120" y="612" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">path clusters/sno/bootstrap</text>
  <rect style="--d:4.90s" class="rv" id="asa8d4a31-rect-obj5" x="650" y="572" width="320" height="52" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text style="--d:4.90s" class="rv" id="asa8d4a31-title-obj5" x="666" y="594" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13.5" font-weight="700" fill="#0F766E" text-anchor="start">Root Application</text>
  <text style="--d:4.90s" class="rv" id="asa8d4a31-line0-obj5" x="666" y="612" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#4B5563" text-anchor="start">app-of-apps for sno, prune: false</text>
  <path style="--d:4.90s" class="rv" id="asa8d4a31-flow-tpl5" d="M 530 598 L 646 598" fill="none" stroke="#0F766E" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-0F766E)" />
  <text id="asa8d4a31-label-applied" x="650" y="306" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="11" font-weight="600" fill="#0F766E" text-anchor="start">applied in order by the policy framework on sno</text>
  <rect style="--d:3.00s" class="rv" id="asa8d4a31-rect-localargo" x="1010" y="380" width="350" height="100" rx="10" fill="#FDF0E8" stroke="#C2410C" stroke-width="1.6" />
  <text style="--d:3.00s" class="rv" id="asa8d4a31-title-localargo" x="1026" y="409" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#C2410C" text-anchor="start">Local Argo CD</text>
  <text style="--d:3.00s" class="rv" id="asa8d4a31-line0-localargo" x="1026" y="432" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">installed by the operator,</text>
  <text style="--d:3.00s" class="rv" id="asa8d4a31-line1-localargo" x="1026" y="448" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#1F2937" text-anchor="start">reads the repository secret</text>
  <path style="--d:3.00s" class="rv" id="asa8d4a31-flow-operator-localargo" d="M 972 406 L 1006 406" fill="none" stroke="#C2410C" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-C2410C)" />
  <rect style="--d:5.40s" class="rv" id="asa8d4a31-rect-rest" x="1010" y="540" width="350" height="110" rx="10" fill="#FFFFFF" stroke="#C2410C" stroke-width="1.6" stroke-dasharray="6 4" />
  <text style="--d:5.40s" class="rv" id="asa8d4a31-title-rest" x="1026" y="569" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="15" font-weight="700" fill="#C2410C" text-anchor="start">Everything else</text>
  <text style="--d:5.40s" class="rv" id="asa8d4a31-line0-rest" x="1026" y="592" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">operators, OAuth, RBAC, apps ...</text>
  <text style="--d:5.40s" class="rv" id="asa8d4a31-line1-rest" x="1026" y="608" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">synced by the local Argo CD</text>
  <text style="--d:5.40s" class="rv" id="asa8d4a31-line2-rest" x="1026" y="624" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="700" fill="#4B5563" text-anchor="start">from clusters/sno/</text>
  <path style="--d:5.40s" class="rv" id="asa8d4a31-flow-root-rest" d="M 972 598 L 1006 598" fill="none" stroke="#C2410C" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-C2410C)" />
  <path style="--d:5.40s" class="rv" id="asa8d4a31-flow-localargo-rest" d="M 1185 482 L 1185 536" fill="none" stroke="#C2410C" stroke-width="2" stroke-linejoin="round" marker-end="url(#asa8d4a31-arrow-C2410C)" />
  <rect style="--d:6.00s" class="rv" id="asa8d4a31-rect-owner" x="650" y="80" width="710" height="96" rx="8" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.2" stroke-dasharray="6 4" />
  <text style="--d:6.00s" class="rv" id="asa8d4a31-owner1" x="670" y="110" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13" font-weight="600" fill="#0F766E" text-anchor="start">The policy owns the five objects on the left.</text>
  <text style="--d:6.00s" class="rv" id="asa8d4a31-owner2" x="670" y="132" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="13" font-weight="600" fill="#C2410C" text-anchor="start">Argo CD owns everything the root Application brings in.</text>
  <text style="--d:6.00s" class="rv" id="asa8d4a31-owner3" x="670" y="154" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12.5" font-weight="400" fill="#4B5563" text-anchor="start">Never manage the same object from both sides.</text>
  <rect id="asa8d4a31-legend-you" x="40" y="692" width="22" height="14" rx="3" fill="#E6F4F1" stroke="#0F766E" stroke-width="1.6" />
  <text id="asa8d4a31-legend-you-text" x="70" y="704" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">created by you</text>
  <rect id="asa8d4a31-legend-acm" x="194.609375" y="692" width="22" height="14" rx="3" fill="#FFFFFF" stroke="#0F766E" stroke-width="1.6" stroke-dasharray="6 4" />
  <text id="asa8d4a31-legend-acm-text" x="224.609375" y="704" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">generated by ACM</text>
  <rect id="asa8d4a31-legend-argo" x="370.5625" y="692" width="22" height="14" rx="3" fill="#FFFFFF" stroke="#C2410C" stroke-width="1.6" stroke-dasharray="6 4" />
  <text id="asa8d4a31-legend-argo-text" x="400.5625" y="704" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">generated by Argo CD</text>
  <rect id="asa8d4a31-legend-platform" x="566.984375" y="692" width="22" height="14" rx="3" fill="#F1F5F9" stroke="#4B5563" stroke-width="1.6" />
  <text id="asa8d4a31-legend-platform-text" x="596.984375" y="704" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="400" fill="#1F2937" text-anchor="start">platform component</text>
  <text id="asa8d4a31-legend-extra" x="1380" y="704" font-family="Inter, 'Liberation Sans', Arial, sans-serif" font-size="12" font-weight="600" fill="#4B5563" text-anchor="end">Build-up order = order of the policy templates</text>
<circle class="flow-dot" style="--d:0.20s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 292 120 L 306 120" begin="indefinite" data-begin="0.20" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:1.70s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 530 342 L 646 342" begin="indefinite" data-begin="1.70" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:2.50s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 530 406 L 646 406" begin="indefinite" data-begin="2.50" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:3.30s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 530 470 L 646 470" begin="indefinite" data-begin="3.30" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:4.10s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 530 534 L 646 534" begin="indefinite" data-begin="4.10" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:4.90s" visibility="hidden" r="4.5" fill="#0F766E" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 530 598 L 646 598" begin="indefinite" data-begin="4.90" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:3.00s" visibility="hidden" r="4.5" fill="#C2410C" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 972 406 L 1006 406" begin="indefinite" data-begin="3.00" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:5.40s" visibility="hidden" r="4.5" fill="#C2410C" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 972 598 L 1006 598" begin="indefinite" data-begin="5.40" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  <circle class="flow-dot" style="--d:5.40s" visibility="hidden" r="4.5" fill="#C2410C" stroke="#FFFFFF" stroke-width="1.5"><animateMotion path="M 1185 482 L 1185 536" begin="indefinite" data-begin="5.40" dur="1.40s" repeatCount="indefinite" calcMode="linear"/></circle>
  </svg>
</div>
  <div class="title">Bootstrap policy: the templates are applied in order, then the local Argo CD takes over</div>
</div>

</div>
<div class="paragraph">
<p>We extend our repository with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-text hljs" data-lang="text">acm-policies/
└── input
    └── gitops-bootstrap
        ├── 01-namespace.yaml          # openshift-gitops-operator
        ├── 02-operatorpolicy.yaml     # OpenShift GitOps Operator
        ├── 03-controller-rbac.yaml    # rights for the local controller
        ├── 04-repo-credentials.yaml   # Git credentials, copied from the hub
        └── 05-root-application.yaml   # app-of-apps for this cluster</code></pre>
</div>
</div>
<div class="paragraph">
<p>The first file creates the namespace for the Operator. The OperatorPolicy in the next step expects it to exist:</p>
</div>
<div class="listingblock linenums">
<div class="title">input/gitops-bootstrap/01-namespace.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: v1
kind: Namespace
metadata:
  name: openshift-gitops-operator</code></pre>
</div>
</div>
<div class="listingblock linenums">
<div class="title">input/gitops-bootstrap/02-operatorpolicy.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: policy.open-cluster-management.io/v1beta1
kind: OperatorPolicy <i class="conum" data-value="1"></i><b>(1)</b>
metadata:
  name: openshift-gitops-operator
spec:
  remediationAction: enforce
  severity: high
  complianceType: musthave
  subscription:
    name: openshift-gitops-operator
    namespace: openshift-gitops-operator
    channel: gitops-1.22 <i class="conum" data-value="2"></i><b>(2)</b>
    source: redhat-operators
    sourceNamespace: openshift-marketplace
  upgradeApproval: Automatic</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The PolicyGenerator adds OperatorPolicy manifests unchanged as a policy template, no extra wrapping.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Pin the channel. Moving to the next version is a one-line pull request.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The root Application is the app-of-apps that contains the Application for every cluster.</p>
</div>
<div class="listingblock linenums">
<div class="title">input/gitops-bootstrap/05-root-application.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: root
  namespace: openshift-gitops
spec:
  project: default
  source:
    repoURL: https://github.com/tjungbauer/openshift-clusterconfig-gitops.git
    targetRevision: main
    path: &#39;{{hub printf &#34;clusters/%s/bootstrap&#34; .ManagedClusterName hub}}&#39; <i class="conum" data-value="1"></i><b>(1)</b>
  destination:
    server: https://kubernetes.default.svc
  syncPolicy:
    automated:
      prune: false <i class="conum" data-value="2"></i><b>(2)</b>
      selfHeal: true</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>A hub template, resolved on the hub for every cluster: <code>sno</code> gets <code>clusters/sno/bootstrap</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Never prune on the root Application. A broken path would otherwise remove everything below it.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The local Argo CD must be allowed to create whatever the root Application brings in. <code>03-controller-rbac.yaml</code> grants its application-controller cluster-admin rights, the same as in the pull model of <a href="/gitopscollection/2026-10-23-acm-gitops-push-pull-agent/">Ep.19</a>:</p>
</div>
<div class="listingblock linenums">
<div class="title">input/gitops-bootstrap/03-controller-rbac.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: argo-admin
subjects:
  - kind: ServiceAccount
    name: openshift-gitops-argocd-application-controller <i class="conum" data-value="1"></i><b>(1)</b>
    namespace: openshift-gitops
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin <i class="conum" data-value="2"></i><b>(2)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The service account of the default instance <code>openshift-gitops</code>, which the Operator creates after the installation.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Simple and usually fine for platform configuration. For application teams, prefer namespaces labelled with <code>argocd.argoproj.io/managed-by</code>.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>And the generator configuration ties it together:</p>
</div>
<div class="listingblock linenums">
<div class="title">policy-generator.yaml (excerpt)</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">policies:
  - name: gitops-bootstrap
    remediationAction: enforce
    orderManifests: true <i class="conum" data-value="1"></i><b>(1)</b>
    consolidateManifests: false
    placement:
      labelSelector:
        matchExpressions:
          - key: name <i class="conum" data-value="2"></i><b>(2)</b>
            operator: In
            values:
              - sno
              - bm
    manifests:
      - path: input/gitops-bootstrap/01-namespace.yaml
      - path: input/gitops-bootstrap/02-operatorpolicy.yaml
      - path: input/gitops-bootstrap/03-controller-rbac.yaml
      - path: input/gitops-bootstrap/04-repo-credentials.yaml
      - path: input/gitops-bootstrap/05-root-application.yaml</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The order matters: the Application CRD only exists after the operator is installed. With <code>orderManifests</code>, the root Application is only created when the operator policy is compliant.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The same selection as for the other policies: the clusters <code>sno</code> and <code>bm</code>, selected by the <code>name</code> label that ACM sets on every ManagedCluster. In a larger fleet, a dedicated label such as <code>gitops=enabled</code> makes the bootstrap an opt-in per cluster.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Pattern B is meant for clusters that get their Argo CD from this policy. If you followed the pull or agent part of Ep.19, the GitOps add-on of ACM has already installed OpenShift GitOps on <code>sno</code> and <code>bm</code>, and the policy and the add-on would then manage the same operator. Decide which of the two owns the operator before you enforce this policy, or test Pattern B on a cluster without the add-on.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Who owns what afterwards? The policy owns exactly five objects: the namespace, the operator, the ClusterRoleBinding, the repository secret and the root Application. Everything the root Application brings in belongs to Argo CD. Keep it that way: if you also manage the OpenShift GitOps Subscription with Argo CD on the spoke, the two will fight.</p>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_the_result_in_acm_argo_cd">The result in ACM &amp; Argo CD</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Once Argo CD has synced the repository, the policies show up in the ACM console under <strong>Governance</strong>.</p>
</div>
<div class="paragraph">
<p>The list of <strong>Policies</strong> shows the three policies of this article in the namespace <code>acm-policies</code>: <code>service-mesh</code>, <code>no-kubeadmin</code> and <code>gitops-bootstrap</code>. For each policy you see the remediation action (inform or enforce), the cluster violations and the policy set, if there is one.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/gitopscollection/images/ep-20/acm-governance-policies.png?width=80%" alt="ACM Governance policies"/>
</div>
<div class="title">Figure 1. Policies in the namespace acm-policies</div>
</div>
<div class="paragraph">
<p>A click on a policy opens the details. The <strong>Details</strong> tab shows the policy templates, here the ConfigurationPolicies and the OperatorPolicy that the PolicyGenerator created from the plain manifests, and the Placement with the selected clusters <code>sno</code> and <code>bm</code>.</p>
</div>
<div class="paragraph">
<p>The <code>no-kubeadmin</code> policy is a good example for <code>inform</code>: ACM only reports that the secret <code>kubeadmin</code> still exists, it does not delete it.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/gitopscollection/images/ep-20/acm-policy-no-kubeadmin-results.png?width=80%" alt="Results of the policy no-kubeadmin"/>
</div>
<div class="title">Figure 2. Results of the policy no-kubeadmin</div>
</div>
<div class="paragraph">
<p>In the Argo CD UI we can also verify the status (including the resource tree).</p>
</div>
<div class="paragraph">
<p>The Application <code>acm-policies</code> shows the status <strong>Degraded</strong>. This is because the policy <code>no-kubeadmin</code> is non-compliant …​ the secrets are still present.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/gitopscollection/images/ep-20/policy-gitops-acm-policies-tile.png?width=50%" alt="Application acm-policies in Argo CD"/>
</div>
<div class="title">Figure 3. Application acm-policies in Argo CD</div>
</div>
<div class="paragraph">
<p>The resource tree proves this:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/gitopscollection/images/ep-20/policy-gitops-acm-policies-tree.png?width=80%" alt="Resource tree of the application acm-policies"/>
</div>
<div class="title">Figure 4. Resource tree of the application acm-policies</div>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_summary">Summary</h2>
<div class="sectionbody">
<div class="paragraph">
<p>That concludes the mini-series. ACM decides <em>where</em> and checks <em>compliance</em>, Argo CD decides <em>what</em> and keeps it <em>in sync</em>, and Git is the only place where changes are made.</p>
</div>
<div class="paragraph">
<p>And as always: <strong>If it is not in Git, it does not exist.</strong> That includes your ACM policies.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The diagrams in this article have been manually drawn on a whiteboard. AI then generated the SVGs from photos and made them look equal in all articles.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/2.17/html/gitops/gitops-overview" rel="noopener" target="_blank">ACM 2.17: GitOps (managing policy definitions with OpenShift GitOps, Policy Generator integration)</a></p>
</li>
<li>
<p><a href="https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/2.17/html/governance/index" rel="noopener" target="_blank">ACM 2.17: Governance (Policy Generator, OperatorPolicy, hub templates)</a></p>
</li>
<li>
<p><a href="https://github.com/open-cluster-management-io/policy-collection" rel="noopener" target="_blank">Open Cluster Management: policy collection</a></p>
</li>
<li>
<p><a href="/gitopscollection/2024-04-02-configure_app_of_apps/">[Ep.4] Configure App-of-Apps</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>ValidatingAdmissionPolicy and how to use it</title><link>https://blog.stderr.at/openshift-platform/security/compliance/2026-10-15-namespace-labels-validating-admission-policy/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/compliance/2026-10-15-namespace-labels-validating-admission-policy/</guid><pubDate>Thu, 15 Oct 2026 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><category>Compliance</category><description>Enforce mandatory ownership labels on OpenShift namespaces with a CEL ValidatingAdmissionPolicy—and block removal of those labels after creation.</description><content:encoded><![CDATA[<div class="paragraph">
<p>In my last article about the Compliance Operator, <a href="/openshift-platform/security/compliance/2026-10-09-compliance-operator-customrules-cel/">Compliance Operator: Writing Your Own Checks with CEL and CustomRules</a>, we discussed <code>CustomRule</code> and how they can enhance the Compliance Operator. CustomRules are good for defining your own policies, for example to check whether a namespace is created with the correct labels. But they cannot stop someone from changing something on the cluster.</p>
</div>
<div class="paragraph">
<p>The Compliance Operator can <strong>detect</strong> violations, but it cannot <strong>prevent</strong> them. This is where <code>ValidatingAdmissionPolicy</code> comes in. It is a native Kubernetes feature that runs directly inside the kube-apiserver. It uses the same language as the CustomRules, CEL, and it can be used to prevent violations from happening in the first place.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this article we will write a policy that:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>rejects the creation of an application namespace without the mandatory labels <code>example.com/owner</code> and <code>example.com/cost-centre</code>,</p>
</li>
<li>
<p>rejects removing these labels (or setting them to an empty value),</p>
</li>
<li>
<p>ignores platform namespaces, or, in a second variant, only applies to namespaces that follow a naming convention.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The list of excluded platform namespaces is the same as in the Compliance Operator article. This is important: the admission policy and the CustomRule must look at the same set of namespaces, otherwise one of them reports something the other one ignores.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_why_a_validatingadmissionpolicy">Why a ValidatingAdmissionPolicy?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For a long time, admission control meant writing your own webhook or installing a policy engine such as Gatekeeper or Kyverno. Both are fine tools and worth checking out, but for a simple rule like ours they bring a lot of moving parts that we can avoid if we do not need them.</p>
</div>
<div class="paragraph">
<p>A <code>ValidatingAdmissionPolicy</code> (VAP) is evaluated <strong>inside</strong> the kube-apiserver. The API <code>admissionregistration.k8s.io/v1</code> is available since Kubernetes 1.30, which means OpenShift 4.17 and later. A VAP consists of two objects:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>ValidatingAdmissionPolicy</strong></dt>
<dd>
<p><em>What</em> is checked: which requests are matched and which CEL expressions must be true.</p>
</dd>
<dt class="hdlist1"><strong>ValidatingAdmissionPolicyBinding</strong></dt>
<dd>
<p><em>Where</em> and <em>how</em> the policy is enforced (bound to): which namespaces or objects it applies to and what happens on a violation (<code>Deny</code>, <code>Warn</code>, <code>Audit</code>).</p>
</dd>
</dl>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If you have followed the <a href="/openshift-platform/security/compliance/2026-10-09-compliance-operator-customrules-cel/">Compliance Operator article</a>, the CEL expressions below will look familiar. The difference: a CustomRule evaluates a <strong>list</strong> of objects on a schedule; a VAP evaluates <strong>one</strong> object at the moment it is created or changed.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p>OpenShift 4.17 or newer with cluster-admin permissions.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_designing_the_policy">Designing the Policy</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before writing any YAML, three design decisions have to be made. At the end they will define the policy and its behaviour:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>What exactly is forbidden on UPDATE?</p>
</li>
<li>
<p>Which namespaces are affected?</p>
</li>
<li>
<p>How to roll it out?</p>
</li>
</ol>
</div>
<div class="sect2">
<h3 id="_decision_1_what_exactly_is_forbidden_on_update">Decision 1: What exactly is forbidden on UPDATE?</h3>
<div class="paragraph">
<p>This is an important decision and it hit me hard during my tests. The initial approach would be: <em>&#34;every namespace must always have the labels&#34;</em>, checked on CREATE and UPDATE. This is a TRAP.</p>
</div>
<div class="paragraph">
<p>Kubernetes clusters already contain namespaces without these labels. Controllers and operators update namespaces all the time; for example OpenShift synchronises the Pod Security labels and sets the annotations for the SCC UID ranges. If we enforced the labels on every UPDATE, we would eventually break the platform.</p>
</div>
<div class="paragraph">
<p>Therefore the policy must treat the two operations CREATE and UPDATE differently:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;"/>
<col style="width: 75%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Operation</th>
<th class="tableblock halign-left valign-top">Rule</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">CREATE</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">All required labels must be present with a non-empty value. If the labels are missing, the request is rejected.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">UPDATE</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">A required label that was set before (non-empty) must not be removed or emptied. However, changing the value, for example when the ownership moves to another team, is allowed. Updates of old namespaces that never had the labels are allowed as well. If the label is removed or emptied, the request is rejected.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_decision_2_which_namespaces_are_affected">Decision 2: Which namespaces are affected?</h3>
<div class="paragraph">
<p>Typically, there are two approaches:</p>
</div>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>Variant A: exclude platform namespaces</strong></dt>
<dd>
<p>Everything is checked except the platform namespaces. This was used in the Compliance Operator article: everything that starts with <code>openshift</code> or <code>kube-</code>, the namespace <code>default</code>, plus additional namespaces that are used by the platform. Adapt the list to whatever runs on your clusters. This is a good approach, but requires you to maintain the list of namespaces that are excluded.</p>
</dd>
<dt class="hdlist1"><strong>Variant B: namespaces with a naming convention</strong></dt>
<dd>
<p>Only namespaces that follow a convention, for example <code>app-&lt;name&gt;</code>, are checked. Everything else, such as sandboxes or personal projects, is left alone. This is a good approach as well, but requires you to enforce the naming convention when namespaces are created.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_decision_3_how_to_roll_it_out">Decision 3: How to roll it out?</h3>
<div class="paragraph">
<p>A policy on namespaces affects everybody, including cluster administrators, GitOps tools and the OpenShift project request template. Therefore we start in <code>Warn</code>/<code>Audit</code> mode and switch to <code>Deny</code> once we know that nothing breaks. I mean, it is always good practice to test first :)</p>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_1_the_validatingadmissionpolicy">Step 1: The ValidatingAdmissionPolicy</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Create the following file <code>01-vap-namespace-ownership-labels.yaml</code>. It will check for the existence of the required labels on CREATE and UPDATE requests. Such rules are typically built like this:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>matchConstraints</strong>: decide which requests are matched.</p>
</li>
<li>
<p><strong>matchConditions</strong>: decide which namespaces are affected or not affected.</p>
</li>
<li>
<p><strong>variables</strong>: define the labels that are required.</p>
</li>
<li>
<p><strong>validations</strong>: define the rules that are checked.</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="title">01-vap-namespace-ownership-labels.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: namespace-ownership-labels
spec:
  failurePolicy: Fail <i class="conum" data-value="1"></i><b>(1)</b>
  matchConstraints: <i class="conum" data-value="2"></i><b>(2)</b>
    resourceRules:
      - apiGroups: [&#34;&#34;]
        apiVersions: [&#34;v1&#34;]
        operations: [&#34;CREATE&#34;, &#34;UPDATE&#34;]
        resources: [&#34;namespaces&#34;]
  matchConditions: <i class="conum" data-value="3"></i><b>(3)</b>
    - name: exclude-platform-namespaces
      expression: &gt;-
        !object.metadata.name.matches(&#39;^(openshift.*|kube-.*|open-cluster-management.*|cert-manager.*|stackrox.*|rhacs-.*|default)$&#39;)
  variables:
    - name: requiredLabels <i class="conum" data-value="4"></i><b>(4)</b>
      expression: &gt;-
        [&#39;example.com/owner&#39;, &#39;example.com/cost-centre&#39;]
    - name: missingLabels <i class="conum" data-value="5"></i><b>(5)</b>
      expression: &gt;-
        variables.requiredLabels.filter(key,
          !has(object.metadata.labels) ||
          !(key in object.metadata.labels) ||
          object.metadata.labels[key] == &#39;&#39;)
    - name: removedLabels <i class="conum" data-value="6"></i><b>(6)</b>
      expression: &gt;-
        request.operation != &#39;UPDATE&#39; || !has(oldObject.metadata.labels) ? [] :
        variables.missingLabels.filter(key,
          key in oldObject.metadata.labels &amp;&amp;
          oldObject.metadata.labels[key] != &#39;&#39;)
  validations:
    - expression: &gt;- <i class="conum" data-value="7"></i><b>(7)</b>
        request.operation != &#39;CREATE&#39; || size(variables.missingLabels) == 0
      messageExpression: &gt;- <i class="conum" data-value="8"></i><b>(8)</b>
        &#39;Namespace &#39; + object.metadata.name + &#39; must carry the label(s) &#39; +
        variables.missingLabels.join(&#39;, &#39;) + &#39; with a non-empty value.&#39;
      reason: Invalid
    - expression: &gt;- <i class="conum" data-value="9"></i><b>(9)</b>
        size(variables.removedLabels) == 0
      messageExpression: &gt;-
        &#39;The label(s) &#39; + variables.removedLabels.join(&#39;, &#39;) +
        &#39; must not be removed from namespace &#39; + object.metadata.name +
        &#39; or set to an empty value.&#39;
      reason: Forbidden</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td><code>failurePolicy: Fail</code> rejects the request if the expression cannot be evaluated. The other option is <code>Ignore</code>. For a required policy that must always be applied this is the right choice.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The policy matches <strong>CREATE</strong> and <strong>UPDATE</strong> requests for namespaces. <strong>DELETE</strong> is not matched, so namespaces can still be removed.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td><code>matchConditions</code> decide whether the policy applies to a request at all. Here, the platform namespaces are skipped (Variant A). The regular expression is the same as in the CustomRules. Do not forget the anchors <code>^</code> and <code>$</code>: without them <code>matches()</code> searches for a substring.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td><code>variables</code> define the labels that are required. <code>requiredLabels</code> is the single place where the label keys are defined.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td><code>missingLabels</code> is the list of required labels that are missing or empty in the <strong>new</strong> object.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td><code>removedLabels</code> is the list of labels that are missing now but were set (non-empty) in <code>oldObject</code>. For CREATE requests there is no <code>oldObject</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>Validation for CREATE: nothing may be missing.</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td><code>messageExpression</code> gives feedback to the user and tells <strong>which</strong> labels are the problem.</td>
</tr>
<tr>
<td><i class="conum" data-value="9"></i><b>9</b></td>
<td>Validation for UPDATE: nothing that existed may be removed.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The exclusion regex now lives in three places: the CEL <code>expression</code> of the CustomRule and in its <code>instructions</code>, and this policy. When you change one of them, change all three.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_2_the_binding">Step 2: The Binding</h2>
<div class="sectionbody">
<div class="paragraph">
<p>As a second step we need to bind the policy to the namespaces that are affected (all). For the first test we only warn and write audit events. Create the file <code>02-vapbinding-namespace-ownership-labels.yaml</code>:</p>
</div>
<div class="listingblock">
<div class="title">02-vapbinding-namespace-ownership-labels.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
  name: namespace-ownership-labels
spec:
  policyName: namespace-ownership-labels <i class="conum" data-value="1"></i><b>(1)</b>
  validationActions: [&#34;Warn&#34;, &#34;Audit&#34;] <i class="conum" data-value="2"></i><b>(2)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Reference to the name of the policy.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td><code>validationActions</code> tells Kubernetes what to do on a violation: <code>Warn</code> returns a warning to the client, <code>Audit</code> adds the violation to the API audit log. The other option is <code>Deny</code>.</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_3_apply_the_policy_and_initial_test">Step 3: Apply the Policy and initial test</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Apply both objects:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc apply -f 01-vap-namespace-ownership-labels.yaml
oc apply -f 02-vapbinding-namespace-ownership-labels.yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p>and check that the API server has accepted the expressions.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get validatingadmissionpolicy namespace-ownership-labels -o jsonpath=&#39;{.status}{&#34;\n&#34;}&#39;</code></pre>
</div>
</div>
<div class="paragraph">
<p>In <code>Warn</code> mode, creating a namespace without labels still works, but <code>oc</code> shows a warning:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc create namespace app-warn</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">Warning: Validation failed for ValidatingAdmissionPolicy &#39;namespace-ownership-labels&#39; with binding &#39;namespace-ownership-labels&#39;: Namespace app-warn must carry the label(s) example.com/owner, example.com/cost-centre with a non-empty value.
namespace/app-warn created</code></pre>
</div>
</div>
<div class="paragraph">
<p>Leave the policy in this mode for a while. Watch the output of your GitOps tools and pipelines as well as the audit log, and fix whoever creates namespaces without labels.</p>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_4_switch_to_deny">Step 4: Switch to Deny</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Once you are confident, switch the binding to <code>Deny</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc patch validatingadmissionpolicybinding namespace-ownership-labels --type=merge \
  -p &#39;{&#34;spec&#34;:{&#34;validationActions&#34;:[&#34;Deny&#34;]}}&#39;</code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Do not combine <code>Deny</code> and <code>Warn</code> in one binding. <code>Deny</code> already returns the message to the client, <code>Warn</code> would only duplicate it.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_5_test_the_policy">Step 5: Test the Policy</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now let us run some detailed tests. We want to make sure that our policy works and that it does not disrupt any platform namespaces or controllers.</p>
</div>
<div class="paragraph">
<p><strong>Create a namespace without labels.</strong> This is rejected, and the message lists the missing labels:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc create namespace team-a</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">The namespaces &#34;team-a&#34; is invalid: : ValidatingAdmissionPolicy &#39;namespace-ownership-labels&#39; with binding &#39;namespace-ownership-labels&#39; denied request: Namespace team-a must carry the label(s) example.com/owner, example.com/cost-centre with a non-empty value.</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Create a namespace without labels via the UI.</strong> This is rejected as well, and the message is shown directly as feedback to the user.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/compliance/images/ValidationAdmissionPolicy-Deny.png?width=520px" alt="Namespace Ownership Labels UI Error"/>
</div>
</div>
<div class="paragraph">
<p><strong>Create a namespace with only one of the labels.</strong> This is rejected as well, and this time only <code>example.com/cost-centre</code> is mentioned:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">cat &lt;&lt;&#39;EOF&#39; | oc apply -f -
apiVersion: v1
kind: Namespace
metadata:
  name: team-a
  labels:
    example.com/owner: payments
EOF</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">The namespaces &#34;team-a&#34; is invalid: : ValidatingAdmissionPolicy &#39;namespace-ownership-labels&#39; with binding &#39;namespace-ownership-labels&#39; denied request: Namespace team-a must carry the label(s) example.com/cost-centre with a non-empty value.</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Create the namespace with both labels.</strong> This works — yay:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">cat &lt;&lt;&#39;EOF&#39; | oc apply -f -
apiVersion: v1
kind: Namespace
metadata:
  name: team-a
  labels:
    example.com/owner: payments
    example.com/cost-centre: CC-4711
EOF</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Remove a label or set it to an empty value.</strong> Both are rejected:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc label namespace team-a example.com/owner-
oc label namespace team-a example.com/owner= --overwrite</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">Error from server (Forbidden): namespaces &#34;team-a&#34; is forbidden: ValidatingAdmissionPolicy &#39;namespace-ownership-labels&#39; with binding &#39;namespace-ownership-labels&#39; denied request: The label(s) example.com/owner must not be removed from namespace team-a or set to an empty value.</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Change the value of a label, or add an annotation.</strong> Both are allowed:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc label namespace team-a example.com/owner=shop --overwrite
oc annotate namespace team-a example.com/comment=hello</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Platform namespaces</strong> are not affected:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc create namespace openshift-demo</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Old namespaces</strong> that were created before the policy existed can still be updated. Once a label has been added, it is protected as well. Here <code>legacy-app</code> stands for any namespace that existed before the policy:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc annotate namespace legacy-app example.com/comment=hello      # allowed
oc label namespace legacy-app example.com/owner=legacy          # allowed
oc label namespace legacy-app example.com/owner-                # rejected</code></pre>
</div>
</div>
<div class="paragraph">
<p>Clean up:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc delete namespace team-a openshift-demo app-warn</code></pre>
</div>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_what_if_i_need_an_emergency_exit">What if I need an emergency exit?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The policy above also applies to cluster administrators. Unlike RBAC, admission policies cannot be bypassed with <code>cluster-admin</code>. The labels are protected against accidents, no matter who makes the change.</p>
</div>
<div class="paragraph">
<p>If you need an emergency exit, you have to build it into the policy yourself, for example with an additional <code>matchCondition</code> on <code>request.userInfo.username</code> for the break-glass account from the cluster-admin allow-list of the previous article.</p>
</div>
<div class="paragraph">
<p>On purpose I did not build this into the policy, because I think it is a bad idea to have an emergency exit in the policy. If you need namespaces without such labels, add dummy labels that indicate that the namespace is not an application namespace. At least that’s my opinion :)</p>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_variant_b_only_namespaces_following_a_naming_convention">Variant B: Only Namespaces Following a Naming Convention</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Many organisations use a naming convention to distinguish &#34;real&#34; application namespaces from sandboxes or personal projects, for example <code>app-&lt;name&gt;</code> and <code>sandbox-&lt;name&gt;</code>. In that case, copy the policy from Step 1 to <code>01-vap-namespace-ownership-labels-naming.yaml</code> and replace the <code>matchConditions</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">  matchConditions:
    - name: only-application-namespaces
      expression: &gt;-
        object.metadata.name.matches(&#39;^app-[a-z0-9-]+$&#39;)</code></pre>
</div>
</div>
<div class="paragraph">
<p>We only move from an exclude list to an include list. Everything else stays the same. To test it, we create the following namespaces:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;"/>
<col style="width: 16.6666%;"/>
<col style="width: 50.0001%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Namespace</th>
<th class="tableblock halign-left valign-top">Labels</th>
<th class="tableblock halign-left valign-top">Result</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sandbox-test</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">none</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">allowed (does not follow the convention)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>application</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">none</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">allowed (does not start with <code>app-</code>)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>app-shop</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">none</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">rejected</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>app-shop</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">both</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">allowed; removing a label afterwards is rejected</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Use <strong>one</strong> of the two variants only. Both policies have the same name, so applying one replaces the other.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If you use the naming convention, adapt the <code>filter()</code> of the CustomRules from the previous article in the same way, for example <code>.filter(ns, ns.metadata.name.matches(&#39;^app-[a-z0-9-]+$&#39;))</code>. Otherwise the Compliance Operator reports namespaces that the admission policy deliberately ignores.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_openshift_specifics_self_service_projects">OpenShift Specifics: Self-Service Projects</h2>
<div class="sectionbody">
<div class="paragraph">
<p>On OpenShift, users usually do not create namespaces directly. They run <code>oc new-project</code>, which creates a <code>ProjectRequest</code>. The OpenShift API server then processes the project template and creates the project with its own privileged client. The resulting namespace passes the same admission chain, and therefore the same policy.</p>
</div>
<div class="paragraph">
<p><strong>A project request cannot pass arbitrary labels</strong>. As a consequence, with Variant A in <code>Deny</code> mode, <strong>self-service project requests are rejected</strong>. You have the following options:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Disable self-provisioning</strong> (Recommended) and create application namespaces only through your onboarding process (GitOps, a pipeline, a service catalogue). This is what most regulated customers do anyway. Remove the subjects from the cluster role binding <code>self-provisioners</code> and prevent the API server from restoring them:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc patch clusterrolebinding.rbac self-provisioners -p &#39;{&#34;subjects&#34;: null}&#39;
oc patch clusterrolebinding.rbac self-provisioners \
  -p &#39;{&#34;metadata&#34;:{&#34;annotations&#34;:{&#34;rbac.authorization.kubernetes.io/autoupdate&#34;:&#34;false&#34;}}}&#39;</code></pre>
</div>
</div>
</li>
<li>
<p><strong>Use Variant B.</strong> Self-service projects that do not follow the naming convention (for example <code>sandbox-<strong></strong></code><strong>) are still possible, while <code>app-</code></strong> namespaces must be created with labels through the official process.</p>
</li>
<li>
<p><strong>Set labels in the project template.</strong> Labels defined on the <code>Project</code> object of the template end up on the namespace. However, the template only knows a few parameters, such as the project name and the requesting user, so it cannot fill in a meaningful cost centre. A static value such as <code>unassigned</code> would satisfy the policy, but not the auditor.</p>
</li>
</ol>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_summary">Summary</h2>
<div class="sectionbody">
<div class="paragraph">
<p>With the two objects <code>ValidatingAdmissionPolicy</code> and <code>ValidatingAdmissionPolicyBinding</code>, the kube-apiserver itself makes sure that every new application namespace is created with its ownership labels and that nobody removes them by accident. No webhook, no additional operator, no extra pods everything here is native Kubernetes. Together with the CustomRule from the previous article, you now have both sides: <strong>prevention</strong> at admission time and <strong>detection</strong> on a schedule, with evidence for the auditor.</p>
</div>
<div class="paragraph">
<p>The same idea works for the other two guardrails of the previous article. A VAP on <code>ClusterRoleBindings</code> could reject new <code>cluster-admin</code> bindings for identities that are not on the allow-list. Whether this is a good idea depends on how many operators in your cluster create such bindings themselves, so I highly recommend to start in <code>Warn</code> mode there as well.</p>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_thank_you">Thank You</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This article would not exist without <a href="https://www.linkedin.com/in/mthuring/" rel="noopener" target="_blank">Max Thüringer</a> and <a href="https://www.linkedin.com/in/steffen-l-b0a840249/" rel="noopener" target="_blank">Steffen Lützenkirchen</a>. After listening to the talk <strong>&#34;More than just Compliance&#34;</strong> at OpenShift User Conference in Vienna, I wanted to see how far the CEL scanner of the Compliance Operator can go.</p>
</div>
<div class="paragraph">
<p>Thank you, <a href="https://www.linkedin.com/in/mthuring/" rel="noopener" target="_blank">Max Thüringer</a> and <a href="https://www.linkedin.com/in/steffen-l-b0a840249/" rel="noopener" target="_blank">Steffen Lützenkirchen</a>, for sharing your ideas and for the inspiration.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy/" rel="noopener" target="_blank">Kubernetes Documentation: Validating Admission Policy</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>Compliance Operator: Writing Your Own Checks with CEL and CustomRules</title><link>https://blog.stderr.at/openshift-platform/security/compliance/2026-10-09-compliance-operator-customrules-cel/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/compliance/2026-10-09-compliance-operator-customrules-cel/</guid><pubDate>Fri, 09 Oct 2026 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><category>Compliance</category><description>Turn organisation-specific audit requirements into automated checks with the CEL scanner and the CustomRule resource of the OpenShift Compliance Operator.</description><content:encoded><![CDATA[<div class="paragraph">
<p>Five years ago I first tested and described how to achieve compliance for a Kubernetes cluster in my article <a href="/openshift-platform/security/compliance/2021-07-19-complianceoperator/">Compliance Operator</a>. Many years passed since then, but up to this day the Compliance Operator is still one of the most important tools I recommend to my customers and one of the first that is installed on a new cluster. Since the first release of the Operator, it has been constantly improved and extended, for example by adding your own guardrails to the cluster to make sure that the cluster is compliant with your organisation’s requirements.</p>
</div>
<div class="paragraph">
<p>Today I would like to show you how to write your own checks with the CEL scanner and the CustomRule resource.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The Compliance Operator does a great job when it comes to industry benchmarks such as CIS, NIST 800-53, PCI-DSS or BSI. The idea described at <a href="/openshift-platform/security/compliance/2021-07-19-complianceoperator/">Compliance Operator</a> still works today. You define or select a profile and a time of scanning and the operator does the rest for you. Sooner or later, however, every auditor asks a question that is not part of any benchmark because it is individual for each organisation.</p>
</div>
<div class="paragraph">
<p>For example: <em>&#34;Who owns this namespace?&#34;</em>, <em>&#34;Show me that every application is isolated on the network by default.&#34;</em> or <em>&#34;Who exactly is cluster-admin, and why?&#34;</em> Until now, the answer usually was a shell script, an automation playbook, a screenshot or a check mark in a spreadsheet. With the <strong>CEL scanner</strong> and the <strong>CustomRule</strong> resource, the Compliance Operator can finally check such organisation-specific requirements itself — scheduled, repeatable and with results in the same place as all other compliance checks. All of this defined declaratively, so you can easily integrate it into your GitOps pipeline.</p>
</div>
<div class="paragraph">
<p>In this article I will build a small but real-world examples: three custom checks that act as <strong>platform guardrails</strong>. Two of them look at <code>application namespaces</code>, the third one audits who holds <code>cluster-admin</code>. This will extend the standard profile of the Compliance Operator and make it more useful for your organisation.</p>
</div>
<div class="paragraph">
<p>Once you have the rules in place, you can add them to a <code>TailoredProfile</code> so they become part of your compliance assessment.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The idea is to build the three rules and then add them to a <code>TailoredProfile</code> to make them part of your compliance assessment. If you just need one of the rules, simply remove the other two from the profile.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_a_bit_of_history_cel_in_the_compliance_operator">A Bit of History: CEL in the Compliance Operator</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The Compliance Operator traditionally uses OpenSCAP to evaluate its rules. The content (<a href="https://csrc.nist.gov/projects/security-content-automation-protocol/specifications/xccdf" rel="noopener" target="_blank">XCCDF</a> / <a href="https://ovalproject.github.io/" rel="noopener" target="_blank">OVAL</a>) is generated by the <a href="https://github.com/ComplianceAsCode/content" rel="noopener" target="_blank">ComplianceAsCode1</a> project and shipped with the operator. Writing your own rules in that format is possible, but let us be honest: nobody enjoys building their own content image just to check a label.</p>
</div>
<div class="paragraph">
<p>The <strong>Common Expression Language (CEL)</strong> changes this. CEL is a small, side-effect free expression language. If you have ever written a <code>ValidatingAdmissionPolicy</code>, you already know it. The integration into the Compliance Operator was finally globally available in version 1.10.0.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
CEL does not replace the existing XCCDF profiles. It extends them. Your CIS or PCI-DSS scans continue to work exactly as before.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_the_use_case_platform_guardrails">The Use Case: Platform Guardrails</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Many customers have some kind of &#34;platform contract&#34;. It is written down in a Confluence page, and it is usually not checked by anybody. Three requirements appear in nearly all of them:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Ownership</strong>: every application namespace carries labels that tell who owns it and who pays for it. That is the asset inventory an auditor asks for.</p>
</li>
<li>
<p><strong>Network segmentation by default</strong>: every application namespace contains a <em>default-deny</em> NetworkPolicy for incoming traffic. Applications then explicitly allow what they need.</p>
</li>
<li>
<p><strong>Privileged access</strong>: only an approved list of identities is bound to the ClusterRole <code>cluster-admin</code>. The platform’s own service accounts are allowed, of course, but personal accounts or application service accounts are not.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Why are these good candidates for a CustomRule?</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The label keys and the list of administrators are specific to each organisation. The operator cannot ship a generic rule for them.</p>
</li>
<li>
<p>The built-in CIS rule <code>ocp4-configure-network-policies-namespaces</code> only verifies that a namespace has <em>at least one</em> NetworkPolicy. A single policy that allows everything would pass. We want a real check: <strong>we want the deny-baseline</strong>.</p>
</li>
<li>
<p>All three checks only need information from the Kubernetes API. This is exactly what CustomRules are designed for.</p>
</li>
</ul>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
CustomRules evaluate Kubernetes/OpenShift API resources only. They cannot inspect files or processes on the nodes. For node-level checks you still use the shipped node profiles, such as <code>ocp4-cis-node</code>.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p>An OpenShift cluster with cluster-admin permissions.</p>
</li>
<li>
<p>The Compliance Operator <strong>1.10.0 or newer</strong> installed in the namespace <code>openshift-compliance</code>. Version 1.8.0 and 1.9.x work as well, but the feature is Technology Preview there.</p>
</li>
<li>
<p>The command line tools <code>oc</code> and <code>jq</code>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>If the operator is not installed yet, have a look at my older articles:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="/openshift-platform/security/compliance/2021-07-19-complianceoperator/">Compliance Operator</a> for the manual way, or</p>
</li>
<li>
<p><a href="/gitopscollection/2024-04-25-installing-compliance-operator/">[Ep.5] Setup &amp; Configure Compliance Operator</a> for the GitOps way.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Verify the installed version:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get csv -n openshift-compliance</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_how_a_customrule_works">How a CustomRule Works</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before we write our own rules, let us look at the anatomy of a <code>CustomRule</code>. Such YAML files can get large and messy, but the most important parts are <code>expression</code> and <code>inputs</code>:</p>
</div>
<div class="listingblock">
<div class="title">CustomRule YAML</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: compliance.openshift.io/v1alpha1
kind: CustomRule
metadata:
  name: my-rule
  namespace: openshift-compliance <i class="conum" data-value="1"></i><b>(1)</b>
spec:
  id: my_rule <i class="conum" data-value="2"></i><b>(2)</b>
  title: A short title
  severity: medium <i class="conum" data-value="3"></i><b>(3)</b>
  checkType: Platform <i class="conum" data-value="4"></i><b>(4)</b>
  scannerType: CEL <i class="conum" data-value="5"></i><b>(5)</b>
  inputs: <i class="conum" data-value="6"></i><b>(6)</b>
    - name: pods
      kubernetesInputSpec:
        apiVersion: v1
        resource: pods
  expression: |- <i class="conum" data-value="7"></i><b>(7)</b>
    pods.items.all(p, has(p.spec.securityContext))
  failureReason: Text shown when the check fails <i class="conum" data-value="8"></i><b>(8)</b>
  instructions: How to find and fix the problem <i class="conum" data-value="9"></i><b>(9)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>CustomRules live in the namespace of the operator.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The ID becomes part of the name of the ComplianceCheckResult (underscores are automatically converted to dashes).</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Can be one of <code>info</code>, <code>low</code>, <code>medium</code>, <code>high</code> (default is <code>medium</code>).</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>CustomRules only support <code>Platform</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Must be <code>CEL</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The Kubernetes resources the rule needs. Each input becomes a variable in the expression. Without <code>resourceName</code> you get a <strong>list</strong> object, so the actual objects are found in <code>.items</code>. With <code>resourceNamespace</code> you can limit the query to one namespace.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>The CEL expression. It must return <code>true</code> when the cluster is <strong>compliant</strong>.</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td>The <code>failureReason</code> is added to the warnings of the ComplianceCheckResult if the check fails.</td>
</tr>
<tr>
<td><i class="conum" data-value="9"></i><b>9</b></td>
<td><code>instructions</code> (as well as <code>description</code> and <code>rationale</code>) are copied into the ComplianceCheckResult. Use them to tell the reader how to find the offending objects.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The operator reads the inputs with the ServiceAccount <code>api-resource-collector</code>. This account is basically a cluster-reader, so namespaces, NetworkPolicies, pods, RBAC objects etc. can be read without any additional configuration. If your rule needs resources of an operator (for example <code>HyperConverged</code> of OpenShift Virtualization), you must grant read access to this ServiceAccount yourself.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
A CustomRule produces <strong>one</strong> result for the whole rule, not one result per object. If one namespace out of 200 violates the policy, the rule fails. That is why the <code>instructions</code> field should always contain a command that lists the offending objects.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_1_the_ownership_rule">Step 1: The Ownership Rule</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The first rule, that I would like to build, verifies that every application namespace has the labels <code>example.com/owner</code> and <code>example.com/cost-centre</code> with a non-empty value. Our auditor wants to know who owns the namespace and who pays for it.</p>
</div>
<div class="paragraph">
<p>Platform namespaces must be excluded, otherwise the rule would fail immediately as they do no not have such labels. A regular expression for this: everything that starts with <code>openshift</code> or <code>kube-</code>, plus the namespace <code>default</code> is ignored. In addition, I have also added the namespaces <code>open-cluster-management</code>, <code>stackrox</code> and <code>rhacs-</code> to the exclusion list, these are namespace for <strong>Advanced Cluster Management</strong> and <strong>Advanced Cluster Security</strong> respectively and at least on my own demo cluster they exist.</p>
</div>
<div class="admonitionblock tip">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
Do not worry about the following YAML. It looks huge, but most of it is <strong>just comments</strong>. The important parts are the <code>expression</code> field and the <code>inputs</code> section: they define <strong>what</strong> to check and <strong>where</strong>.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="title">01-customrule-namespace-ownership-labels.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: compliance.openshift.io/v1alpha1
kind: CustomRule
metadata:
  name: namespace-ownership-labels
  namespace: openshift-compliance
  annotations:
    example.com/controls: &#34;Nist Rule 1.2.3.4&#34; <i class="conum" data-value="1"></i><b>(1)</b>
spec:
  id: namespace_ownership_labels
  title: Application namespaces must have ownership labels set <i class="conum" data-value="2"></i><b>(2)</b>
  severity: medium <i class="conum" data-value="3"></i><b>(3)</b>
  checkType: Platform
  scannerType: CEL
  inputs:
    - name: namespaces <i class="conum" data-value="4"></i><b>(4)</b>
      kubernetesInputSpec:
        apiVersion: v1
        resource: namespaces
  expression: |- <i class="conum" data-value="5"></i><b>(5)</b>
    namespaces.items
      .filter(ns, !ns.metadata.name.matches(&#39;^(openshift.*|kube-.*|open-cluster-management.*|cert-manager.*|stackrox.*|rhacs-.*|default)$&#39;))
      .all(ns,
        has(ns.metadata.labels) &amp;&amp;
        [&#39;example.com/owner&#39;, &#39;example.com/cost-centre&#39;].all(key,
          key in ns.metadata.labels &amp;&amp; ns.metadata.labels[key] != &#39;&#39;
        )
      )
  description: |- <i class="conum" data-value="6"></i><b>(6)</b>
    Every application namespace must have the labels &#39;example.com/owner&#39;
    and &#39;example.com/cost-centre&#39; with a non-empty value set. Platform namespaces (openshift*, kube-*, default)
    are excluded.
  rationale: |- <i class="conum" data-value="7"></i><b>(7)</b>
    Auditors expect an up-to-date inventory of system components and a named
    owner for each of them.
  failureReason: |- <i class="conum" data-value="8"></i><b>(8)</b>
    At least one application namespace is missing the label
    &#39;example.com/owner&#39; or &#39;example.com/cost-centre&#39; (or the value is empty).
    Run the command from the instructions of this check to list the
    offending namespaces and label them, for example:
    oc label namespace &lt;name&gt; example.com/owner=&lt;team&gt; example.com/cost-centre=&lt;id&gt;
  instructions: |- <i class="conum" data-value="9"></i><b>(9)</b>
    List all application namespaces without complete ownership labels:
    oc get namespaces -o json | jq -r &#39;.items[]
      | select(.metadata.name | test(&#34;^(openshift.*|kube-.*|open-cluster-management.*|cert-manager.*|stackrox.*|rhacs-.*|default)$&#34;) | not)
      | select((.metadata.labels[&#34;example.com/owner&#34;] // &#34;&#34;) == &#34;&#34;
            or (.metadata.labels[&#34;example.com/cost-centre&#34;] // &#34;&#34;) == &#34;&#34;)
      | .metadata.name&#39;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td><strong>Optional</strong>: map the rule to your control framework.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The <code>title</code> of the rule.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The <code>severity</code> of the rule. Can be one of <code>info</code>, <code>low</code>, <code>medium</code>, <code>high</code> (default is <code>medium</code>).</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The <code>input</code> section defines the <strong>WHERE</strong> of the check. The resource <code>namespaces</code> contains the list of all namespaces.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The <code>expression</code> field reads like a sentence:
<div class="ulist">
<ul>
<li>
<p><code>filter(…​)</code> removes all platform namespaces. <code>matches()</code> uses RE2 syntax. Note the anchors <code>^</code> and <code>$</code>: without them <code>matches()</code> searches for a substring.</p>
</li>
<li>
<p><code>all(…​)</code> returns <code>true</code> only if the condition is true for every of the remaining namespaces.</p>
</li>
<li>
<p><code>has(ns.metadata.labels)</code> protects against namespaces without any label. On a real cluster this does not happen, since Kubernetes always sets <code>kubernetes.io/metadata.name</code>, but it costs nothing.</p>
</li>
<li>
<p>The inner <code>all()</code> iterates over the list of mandatory label keys. <code>key in map</code> checks whether the key exists and that the value is not empty.</p>
</li>
</ul>
</div></td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>Detailed description of the rule.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>Rationale: why are we checking this?</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td>The <code>failureReason</code> is added to the warnings of the ComplianceCheckResult if the check fails.</td>
</tr>
<tr>
<td><i class="conum" data-value="9"></i><b>9</b></td>
<td>The <code>instructions</code> are copied into the ComplianceCheckResult. Use it to tell the reader how to find the offending objects.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This is our first <strong>CustomRule</strong> object. We will define the other rules in the same way, then apply them all at once.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_2_the_default_deny_rule">Step 2: The Default-Deny Rule</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The second rule is more interesting because it combines <strong>two</strong> inputs:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the list of namespaces and</p>
</li>
<li>
<p>the list of all NetworkPolicies.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For every application namespace there must <code>exist</code> at least one NetworkPolicy that:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>lives in that namespace,</p>
</li>
<li>
<p>selects all pods (empty <code>podSelector</code>),</p>
</li>
<li>
<p>covers the policy type <code>Ingress</code> and</p>
</li>
<li>
<p>does not define any ingress rule, which means: nothing is allowed.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In short, every application namespace must have a <strong>deny-all</strong> NetworkPolicy for ingress.</p>
</div>
<div class="paragraph">
<p>Create the file <code>02-customrule-namespace-default-deny-ingress.yaml</code>:</p>
</div>
<div class="listingblock">
<div class="title">02-customrule-namespace-default-deny-ingress.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: compliance.openshift.io/v1alpha1
kind: CustomRule
metadata:
  name: namespace-default-deny-ingress
  namespace: openshift-compliance
  annotations:
    example.com/controls: &#34;Nist Rule 1.2.3.4&#34;
spec:
  id: namespace_default_deny_ingress
  title: Application namespaces have a default-deny ingress NetworkPolicy
  description: |-
    Every application namespace must contain a NetworkPolicy that selects
    all pods (empty podSelector), covers the policy type &#39;Ingress&#39; and
    defines no ingress rules.
    Additional allow policies are expected on top of it. Platform namespaces
    (openshift*, kube-*, default) are excluded.
  rationale: |-
    Without a default-deny baseline every pod accepts traffic from every
    other pod in the cluster.
  severity: high
  checkType: Platform
  scannerType: CEL
  inputs:
    - name: namespaces
      kubernetesInputSpec:
        apiVersion: v1
        resource: namespaces
    - name: networkpolicies <i class="conum" data-value="1"></i><b>(1)</b>
      kubernetesInputSpec:
        apiVersion: networking.k8s.io/v1 <i class="conum" data-value="2"></i><b>(2)</b>
        resource: networkpolicies
  expression: |-
    namespaces.items
      .filter(ns, !ns.metadata.name.matches(&#39;^(openshift.*|kube-.*|open-cluster-management.*|cert-manager.*|stackrox.*|rhacs-.*|default)$&#39;))
      .all(ns,
        networkpolicies.items.exists(np,
          np.metadata.namespace == ns.metadata.name &amp;&amp;
          (!has(np.spec.podSelector.matchLabels) || size(np.spec.podSelector.matchLabels) == 0) &amp;&amp;
          (!has(np.spec.podSelector.matchExpressions) || size(np.spec.podSelector.matchExpressions) == 0) &amp;&amp;
          (!has(np.spec.policyTypes) || &#39;Ingress&#39; in np.spec.policyTypes) &amp;&amp;
          (!has(np.spec.ingress) || size(np.spec.ingress) == 0)
        )
      )
  failureReason: |-
    At least one application namespace has no default-deny ingress
    NetworkPolicy (empty podSelector, policyType Ingress, no ingress rules).
    Run the command from the instructions of this check to list the
    offending namespaces and add a default-deny policy to each of them.
  instructions: |-
    Lists every application namespace that has no default-deny ingress policy.
    A policy counts as default-deny if it selects all pods, covers Ingress and
    allows nothing. Copy the lines below into a bash shell:

    for ns in $(oc get namespaces -o name | cut -d/ -f2 \
        | grep -Ev &#39;^(openshift.*|kube-.*|open-cluster-management.*|cert-manager.*|stackrox.*|rhacs-.*|default)$&#39;); do
      oc get networkpolicies -n &#34;$ns&#34; -o json | jq -e &#39;.items[] | select(
          (.spec.podSelector.matchLabels      // {} | length) == 0 and
          (.spec.podSelector.matchExpressions // [] | length) == 0 and
          (.spec.policyTypes // [&#34;Ingress&#34;] | index(&#34;Ingress&#34;)) and
          (.spec.ingress // [] | length) == 0
        )&#39; &gt; /dev/null || echo &#34;missing default-deny: $ns&#34;
    done</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>A second input. NetworkPolicies are namespace-scoped; since no <code>resourceNamespace</code> is set, the policies of <strong>all</strong> namespaces are fetched.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>For resources outside the core API group, group and version are written together, exactly like the <code>apiVersion</code> in a manifest.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Some details of the <code>expression</code> field are worth a second look:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>filter(…​)</code> removes all platform namespaces that <code>matches()</code></p>
</li>
<li>
<p><code>all(…​)</code> returns <code>true</code> only if the condition is true for every of the remaining namespaces.</p>
</li>
<li>
<p>a network policy object must exist that:</p>
<div class="ulist">
<ul>
<li>
<p>lives in that namespace,</p>
</li>
<li>
<p>has an empty <code>podSelector</code>,</p>
</li>
<li>
<p>has not <code>policyTypes</code> set to <code>Ingress</code>,</p>
</li>
<li>
<p>has no ingress rules,</p>
</li>
</ul>
</div>
</li>
<li>
<p>Additional allow policies (for example to let the OpenShift router in) are fine. We only require that the deny baseline exists.</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This is just an example that shows how to use two inputs in a CustomRule. If you enforce the baseline cluster-wide with a <code>BaselineAdminNetworkPolicy</code> or an <code>AdminNetworkPolicy</code> instead of per-namespace NetworkPolicies, this rule is not the right one for you. In that case write a rule that checks the (cluster-scoped) admin policy instead.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_3_the_cluster_admin_allow_list">Step 3: The cluster-admin Allow-List</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The third rule answers the classic auditor question <em>&#34;Who is cluster-admin?&#34;</em>.</p>
</div>
<div class="paragraph">
<p>The CIS OpenShift Benchmark (control 5.1.1) recommends to restrict the use of <code>cluster-admin</code>, but it cannot know <strong>who</strong> is allowed in your organisation. That is a perfect job for a <strong>CustomRule</strong>.</p>
</div>
<div class="paragraph">
<p>A common mistake is to look only at the ClusterRoleBinding that is called <code>cluster-admin</code>. Any ClusterRoleBinding can reference the ClusterRole <code>cluster-admin</code>, and OpenShift itself ships several of them. Therefore, the rule looks at <strong>all</strong> ClusterRoleBindings whose <code>roleRef</code> points to <code>cluster-admin</code>, and checks <strong>every</strong> subject of these bindings.</p>
</div>
<div class="paragraph">
<p>Before you write the <strong>allow-list</strong>, look at the current state of your cluster:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get clusterrolebindings -o json | jq -r &#39;.items[]
  | select(.roleRef.kind == &#34;ClusterRole&#34; and .roleRef.name == &#34;cluster-admin&#34;)
  | .metadata.name as $crb | .subjects[]?
  | &#34;\($crb)\t\(.kind)\t\(.namespace // &#34;-&#34;)\t\(.name)&#34;&#39; | column -t</code></pre>
</div>
</div>
<div class="paragraph">
<p>This selects all ClusterRoleBindings that reference the ClusterRole <code>cluster-admin</code> and lists the subjects of each binding. The output looks like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">cluster-admin                    Group           -                                   system:masters
cluster-admin-0                  ServiceAccount  openshift-gitops                    openshift-gitops-argocd-application-controller
cluster-admin-crb                Group           -                                   cluster-admin
cluster-admins                   Group           -                                   system:cluster-admins
cluster-admins                   User            -                                   system:admin
cluster-network-operator         ServiceAccount  openshift-network-operator          cluster-network-operator
cluster-storage-operator-role    ServiceAccount  openshift-cluster-storage-operator  cluster-storage-operator
cluster-version-operator         ServiceAccount  openshift-cluster-version           default
...</code></pre>
</div>
</div>
<div class="paragraph">
<p>You will find the platform-internal groups <code>system:masters</code> and <code>system:cluster-admins</code>, the user <code>system:admin</code> and a number of service accounts in <code>openshift-*</code> namespaces that belong to the platform operators. Everything else was added later by someone and deserves a closer look.</p>
</div>
<div class="paragraph">
<p>The allow-list — the subjects the rule treats as acceptable — has three parts:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;"/>
<col style="width: 75%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Subject kind</th>
<th class="tableblock halign-left valign-top">Allowed</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Group</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The platform groups <code>system:masters</code> and <code>system:cluster-admins</code>, plus the group of the platform team (here <code>cluster-admin</code>, for example synchronised from LDAP or Entra ID).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>User</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The platform user <code>system:admin</code> and one named break-glass account. Personal accounts are <strong>not</strong> allowed. The platform team gets its rights through the group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>ServiceAccount</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Every service account in a platform namespace (<code>openshift*</code>, <code>kube-*</code>), plus an explicit list of <code>namespace/name</code> pairs for tools such as a cluster-wide Argo CD instance.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following file is a full example of a CustomRule that checks the allow-list for <code>cluster-admin</code>. The callouts below walk through every part of the expression.</p>
</div>
<div class="listingblock">
<div class="title">03-customrule-cluster-admin-allow-list.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: compliance.openshift.io/v1alpha1
kind: CustomRule
metadata:
  name: cluster-admin-allow-list
  namespace: openshift-compliance
  annotations:
    example.com/controls: &#34;Nist Rule 1.2.3.4&#34;
spec:
  id: cluster_admin_allow_list
  title: Only approved identities are allowed to hold cluster-admin privileges
  description: |-
    Every subject of every ClusterRoleBinding that grants cluster-admin
    privileges must be on the organisation&#39;s allow-list. A binding grants
    cluster-admin privileges if it references the ClusterRole &#39;cluster-admin&#39;
    or any other ClusterRole with a wildcard rule (&#39;*&#39; API groups, &#39;*&#39;
    resources, &#39;*&#39; verbs), for example a renamed copy of cluster-admin.
    Allowed are: the platform-internal groups and users of OpenShift,
    service accounts in platform namespaces (openshift*, kube-*), an
    explicitly named break-glass account, explicitly listed service accounts
    and the group of platform administrators - but only if that group exists
    and every member of it is an approved administrator. Everything else, in
    particular personal user accounts, application service accounts and
    broad groups such as &#39;system:authenticated&#39;, fails the check.
  rationale: |-
    cluster-admin grants unrestricted access to every resource in the
    cluster. Privileged access must be limited to a small, documented and
    reviewed set of identities.
  severity: high
  checkType: Platform
  scannerType: CEL
  inputs:
    - name: crbs <i class="conum" data-value="1"></i><b>(1)</b>
      kubernetesInputSpec:
        apiVersion: rbac.authorization.k8s.io/v1
        resource: clusterrolebindings
    - name: clusterroles <i class="conum" data-value="2"></i><b>(2)</b>
      kubernetesInputSpec:
        apiVersion: rbac.authorization.k8s.io/v1
        resource: clusterroles
    - name: groups <i class="conum" data-value="3"></i><b>(3)</b>
      kubernetesInputSpec:
        apiVersion: user.openshift.io/v1
        resource: groups
  expression: |-
    // ---- allow-list: might be exported into a ConfigMap ---- <i class="conum" data-value="4"></i><b>(4)</b>
    // ---- every dynamic value is stored in a map ----
    [{
      &#39;platformGroups&#39;:         [&#39;system:masters&#39;, &#39;system:cluster-admins&#39;],
      &#39;adminGroups&#39;:            [&#39;cluster-admin&#39;],
      &#39;approvedAdmins&#39;:         [&#39;alice.admin@example.com&#39;, &#39;bob.admin@example.com&#39;],
      &#39;allowedUsers&#39;:           [&#39;system:admin&#39;, &#39;breakglass-admin&#39;],
      &#39;allowedServiceAccounts&#39;: [&#39;gitops-system/argocd-application-controller&#39;, &#39;rhacs-operator/rhacs-operator-controller-manager&#39;]
    }].all(cfg,
      crbs.items <i class="conum" data-value="5"></i><b>(5)</b>
        .filter(crb,
          crb.roleRef.kind == &#39;ClusterRole&#39; &amp;&amp;
          has(crb.subjects) &amp;&amp; crb.subjects != null &amp;&amp;
          (crb.roleRef.name == &#39;cluster-admin&#39; || <i class="conum" data-value="6"></i><b>(6)</b>
           clusterroles.items.exists(cr,
             cr.metadata.name == crb.roleRef.name &amp;&amp;
             has(cr.rules) &amp;&amp; cr.rules != null &amp;&amp;
             cr.rules.exists(r,
               has(r.apiGroups) &amp;&amp; &#39;*&#39; in r.apiGroups &amp;&amp;
               has(r.resources) &amp;&amp; &#39;*&#39; in r.resources &amp;&amp;
               &#39;*&#39; in r.verbs))))
        .all(crb, crb.subjects.all(s, <i class="conum" data-value="7"></i><b>(7)</b>
          // groups: built-in groups, or an admin group that exists and has only approved members
          (s.kind == &#39;Group&#39; &amp;&amp; ( <i class="conum" data-value="8"></i><b>(8)</b>
            s.name in cfg.platformGroups ||
            (s.name in cfg.adminGroups &amp;&amp;
             groups.items.exists(g, g.metadata.name == s.name) &amp;&amp;
             groups.items.filter(g, g.metadata.name == s.name).all(g,
               !has(g.users) || g.users == null ||
               g.users.all(u, u in cfg.approvedAdmins)))
          )) ||
          // users: allowed users, or service accounts of platform namespaces written as User
          (s.kind == &#39;User&#39; &amp;&amp; ( <i class="conum" data-value="9"></i><b>(9)</b>
            s.name in cfg.allowedUsers ||
            s.name.matches(&#39;^system:serviceaccount:(openshift[^:]*|kube-[^:]*):[^:]+$&#39;)
          )) ||
          // service accounts: platform namespaces, or explicitly listed namespace/name pairs
          (s.kind == &#39;ServiceAccount&#39; &amp;&amp; has(s.namespace) &amp;&amp; ( <i class="conum" data-value="10"></i><b>(10)</b>
            s.namespace.matches(&#39;^(openshift.*|kube-.*)$&#39;) ||
            (s.namespace + &#39;/&#39; + s.name) in cfg.allowedServiceAccounts
          ))
        ))
    )
  failureReason: |-
    At least one subject that holds cluster-admin privileges is not on the
    allow-list, or the platform administrator group contains a member that
    is not an approved administrator.
  instructions: |- <i class="conum" data-value="11"></i><b>(11)</b>
    List all subjects with cluster-admin privileges that are not on the
    allow-list:
    jq -rn \
      --slurpfile crbs &lt;(oc get clusterrolebindings -o json) \
      --slurpfile roles &lt;(oc get clusterroles -o json) \
      --slurpfile groups &lt;(oc get groups -o json) &#39;
      # ---- allow-list: edit here ----
      {
        platformGroups:         [&#34;system:masters&#34;, &#34;system:cluster-admins&#34;],
        adminGroups:            [&#34;cluster-admin&#34;],
        approvedAdmins:         [&#34;alice.admin@example.com&#34;, &#34;bob.admin@example.com&#34;],
        allowedUsers:           [&#34;system:admin&#34;, &#34;breakglass-admin&#34;],
        allowedServiceAccounts: [&#34;gitops-system/argocd-application-controller&#34;, &#34;rhacs-operator/rhacs-operator-controller-manager&#34;]
      } as $cfg
      | [$roles[0].items[]
          | select(.metadata.name == &#34;cluster-admin&#34; or any(.rules[]?;
              ((.apiGroups // []) | index(&#34;*&#34;)) and ((.resources // []) | index(&#34;*&#34;))
              and ((.verbs // []) | index(&#34;*&#34;))))
          | .metadata.name] as $adminRoles
      | $crbs[0].items[]
      | select(.roleRef.kind == &#34;ClusterRole&#34;
          and (.roleRef.name == &#34;cluster-admin&#34; or (.roleRef.name | IN($adminRoles[]))))
      | .metadata.name as $crb | .roleRef.name as $role | .subjects[]? | . as $s
      | select(
          ((.kind == &#34;Group&#34;) and ((.name | IN($cfg.platformGroups[]))
             or ((.name | IN($cfg.adminGroups[]))
                 and ([$groups[0].items[] | select(.metadata.name == $s.name)] as $g
                      | ($g | length) &gt; 0
                        and all($g[]; (.users // []) | all(IN($cfg.approvedAdmins[])))))))
          or ((.kind == &#34;User&#34;) and ((.name | IN($cfg.allowedUsers[]))
                or (.name | test(&#34;^system:serviceaccount:(openshift[^:]*|kube-[^:]*):[^:]+$&#34;))))
          or ((.kind == &#34;ServiceAccount&#34;) and (((.namespace // &#34;&#34;) | test(&#34;^(openshift.*|kube-.*)$&#34;))
                or ((.namespace // &#34;&#34;) + &#34;/&#34; + .name | IN($cfg.allowedServiceAccounts[]))))
          | not)
      | &#34;\($crb) -&gt; \($role): \(.kind) \(.namespace // &#34;-&#34;)/\(.name)&#34;
        + (if .kind == &#34;Group&#34; then
             ([$groups[0].items[] | select(.metadata.name == $s.name) | (.users // [])[]]
              | if length == 0 then &#34; (no Group object or no members)&#34;
                else &#34; (members: &#34; + join(&#34;, &#34;) + &#34;)&#34; end)
           else &#34;&#34; end)&#39;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The list of all ClusterRoleBindings.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The list of all ClusterRoles. It is used to find roles that are equivalent to <code>cluster-admin</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The list of all OpenShift <code>Group</code> objects. It is used to verify the members of the allowed group.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>A map for the alow list and any dynamic values. Easier to manage than a long list of strings.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Selecting the relevant ClusterRoleBindings: kind == ClusterRole, subject exists</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>Role reference name is cluster-admin or any other ClusterRole with a wildcard rule (&#39;<strong>&#39; API groups, &#39;</strong>&#39; resources, &#39;*&#39; verbs)</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>Subject is a Group OR a User OR a ServiceAccount</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td>Group is either a platform group OR an admin group that exists and has only approved admins</td>
</tr>
<tr>
<td><i class="conum" data-value="9"></i><b>9</b></td>
<td>User is either an allowed user OR a service account of a platform namespace written as User</td>
</tr>
<tr>
<td><i class="conum" data-value="10"></i><b>10</b></td>
<td>ServiceAccount is either a platform namespace OR an explicitly listed namespace/name pair (here: the Argo CD application controller)</td>
</tr>
<tr>
<td><i class="conum" data-value="11"></i><b>11</b></td>
<td>Pretty decent command to list the offending bindings.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Some details are important here, and they are the reason why I did not simply allow everything that starts with <code>system:</code>:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Broad system groups</strong>: <code>system:authenticated</code>, <code>system:unauthenticated</code> and <code>system:serviceaccounts:&lt;namespace&gt;</code> are system groups as well. Binding one of them to <code>cluster-admin</code> is about the worst thing you can do to a cluster. A prefix match on <code>system:</code> would happily accept them. Therefore the rule uses an explicit list of groups.</p>
</li>
<li>
<p><strong>Service accounts as User subjects</strong>: A service account can also appear as a subject of kind <code>User</code> with the name <code>system:serviceaccount:&lt;namespace&gt;:&lt;name&gt;</code>. The rule treats such subjects like service accounts and only accepts them if the namespace is a platform namespace.</p>
</li>
<li>
<p><strong>Exact namespace/name pairs</strong>: For service accounts outside the platform namespaces the rule compares <code>namespace/name</code>. A service account with the same name in another namespace does not pass.</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The rule deliberately ignores RoleBindings. A RoleBinding to <code>cluster-admin</code> only grants full access <strong>within one namespace</strong>. ClusterRoles that grant broad privileges without using <code><strong></strong></code><strong>/<code></code></strong>/<code>*</code> wildcards are also outside the scope of this example; extend the expression if you need to treat those as equivalent to <code>cluster-admin</code>.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_4_create_the_rules_and_check_their_status">Step 4: Create the Rules and Check Their Status</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Apply the three rules:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc apply -f 01-customrule-namespace-ownership-labels.yaml
oc apply -f 02-customrule-namespace-default-deny-ingress.yaml
oc apply -f 03-customrule-cluster-admin-allow-list.yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p>The operator validates the CEL expression immediately. Only rules in the state <code>Ready</code> can be used in a profile:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get customrules -n openshift-compliance</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">NAME                             STATUS   AGE
cluster-admin-allow-list         Ready    10s
namespace-default-deny-ingress   Ready    12s
namespace-ownership-labels       Ready    14s</code></pre>
</div>
</div>
<div class="paragraph">
<p>If the status is <code>Error</code>, the reason can be found in the status of the object:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get customrule namespace-ownership-labels -n openshift-compliance -o jsonpath=&#39;{.status.errorMessage}{&#34;\n&#34;}&#39;</code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Do not use the short name <code>cr</code>. In the Compliance Operator, <code>cr</code> stands for <code>complianceremediations</code>. I fell into that trap more than once.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_5_tailoredprofile_and_scansettingbinding">Step 5: TailoredProfile and ScanSettingBinding</h2>
<div class="sectionbody">
<div class="paragraph">
<p>CustomRules are never scanned directly. They must be bundled into a <code>TailoredProfile</code>, which is then bound to a <code>ScanSetting</code> (when to scan) via a <code>ScanSettingBinding</code> (which profile to scan).</p>
</div>
<div class="paragraph">
<p>Create the file <code>tailoredprofile.yaml</code>:</p>
</div>
<div class="listingblock">
<div class="title">tailoredprofile.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: platform-guardrails               <i class="conum" data-value="1"></i><b>(1)</b>
  namespace: openshift-compliance
spec:
  title: Platform guardrails
  description: Organisation-specific checks for namespaces and privileged access
  enableRules:
    - kind: CustomRule                    <i class="conum" data-value="2"></i><b>(2)</b>
      name: namespace-ownership-labels
      rationale: Asset inventory and accountability for every namespace
    - kind: CustomRule
      name: namespace-default-deny-ingress
      rationale: Network segmentation as the default for every namespace
    - kind: CustomRule
      name: cluster-admin-allow-list
      rationale: Privileged access limited to approved identities</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The name of the TailoredProfile becomes the name of the ComplianceScan and the prefix of all results.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The <code>kind</code> must be set to <code>CustomRule</code>. Without it, the operator looks for a regular <code>Rule</code> with that name.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
A TailoredProfile cannot mix CEL-based checks with the classic OpenSCAP-based <code>Rule</code> objects (such as the CIS rules). CustomRules may only be combined with other CEL rules. Keep your custom checks in their own profile, which is a good idea anyway.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Create the file <code>scansettingbinding.yaml</code>:</p>
</div>
<div class="listingblock">
<div class="title">scansettingbinding.yaml</div>
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: compliance.openshift.io/v1alpha1
kind: ScanSettingBinding
metadata:
  name: platform-guardrails
  namespace: openshift-compliance
profiles:
  - apiGroup: compliance.openshift.io/v1alpha1
    kind: TailoredProfile
    name: platform-guardrails
settingsRef:
  apiGroup: compliance.openshift.io/v1alpha1
  kind: ScanSetting
  name: default                           <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The <code>default</code> ScanSetting created by the operator. It runs the scan daily at 01:00 (<code>0 1 * * *</code>). Use your own ScanSetting if you need a different schedule.</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_6_check_the_results">Step 6: Check the Results</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Creating the binding starts the first scan immediately. Watch the ComplianceSuite until the phase is <code>DONE</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get compliancesuite platform-guardrails -n openshift-compliance</code></pre>
</div>
</div>
<div class="paragraph">
<p>This returns something like:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">NAME                  PHASE   RESULT
platform-guardrails   DONE    NON-COMPLIANT</code></pre>
</div>
</div>
<div class="paragraph">
<p>Why is it <strong>non-compliant</strong>? Let us look at the results.</p>
</div>
<div class="paragraph">
<p>To list the results of this scan, run:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get ccr -n openshift-compliance -l compliance.openshift.io/scan-name=platform-guardrails</code></pre>
</div>
</div>
<div class="paragraph">
<p>On a cluster that has been running for a while, the output will most likely look like this (example output):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">NAME                                                 STATUS   SEVERITY
platform-guardrails-cluster-admin-allow-list         FAIL     high
platform-guardrails-namespace-default-deny-ingress   FAIL     high
platform-guardrails-namespace-ownership-labels       FAIL     medium</code></pre>
</div>
</div>
<div class="paragraph">
<p>Do not be surprised: this is the actual state of the cluster, and exactly what an auditor wants to know. The failure reason and the instructions are stored in the result:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get ccr platform-guardrails-namespace-ownership-labels -n openshift-compliance \
  -o jsonpath=&#39;{.warnings}{&#34;\n&#34;}{.instructions}{&#34;\n&#34;}&#39;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Copy the command from the instructions to get the list of namespaces that must be fixed.</p>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_step_7_test_the_rules">Step 7: Test the Rules</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To be sure the rules do what they should, create objects that violate all three of them, verify that the checks fail, fix the findings and verify that the checks pass. On a lab cluster that is already compliant, that gives a clean before-and-after picture.</p>
</div>
<div class="paragraph">
<p>Create a test namespace without labels and without a NetworkPolicy, and bind <code>cluster-admin</code> to a personal account that is not on the allow-list:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc create namespace cel-demo
oc create clusterrolebinding cel-demo-admin --clusterrole=cluster-admin --user=alice</code></pre>
</div>
</div>
<div class="paragraph">
<p>Trigger a rescan so you do not have to wait until 01:00 — annotate the ComplianceScan:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc annotate compliancescans/platform-guardrails -n openshift-compliance compliance.openshift.io/rescan=</code></pre>
</div>
</div>
<div class="paragraph">
<p>Wait until the suite is <code>DONE</code> again and check the results: all three checks are <code>FAIL</code>. The helper commands from the instructions list the namespace <code>cel-demo</code> and the binding <code>cel-demo-admin: User -/alice</code>.</p>
</div>
<div class="paragraph">
<p>Now fix the findings. Remove the binding and label the namespace:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc delete clusterrolebinding cel-demo-admin
oc label namespace cel-demo example.com/owner=platform-team example.com/cost-centre=CC-4711

cat &lt;&lt;&#39;EOF&#39; | oc apply -f -
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-ingress
  namespace: cel-demo
spec:
  podSelector: {}
  policyTypes:
  - Ingress
EOF</code></pre>
</div>
</div>
<div class="paragraph">
<p>Rescan again:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc annotate compliancescans/platform-guardrails -n openshift-compliance compliance.openshift.io/rescan=</code></pre>
</div>
</div>
<div class="paragraph">
<p>As long as these were the only offenders, all three checks now report <code>PASS</code>. Finally, remove the test namespace:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc delete namespace cel-demo</code></pre>
</div>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_summary">Summary</h2>
<div class="sectionbody">
<div class="paragraph">
<p>With <code>CustomRule</code> and the CEL scanner, the Compliance Operator finally covers the &#34;last mile&#34; of compliance: the requirements that are specific to your organisation. The three rules in this article are quite huge YAML files, most of it documentation, they run on the same schedule as your CIS or PCI-DSS scans, and their results end up in the same place, with the same labels, metrics and alerts.</p>
</div>
<div class="paragraph">
<p>Namespace ownership, default-deny NetworkPolicies and the cluster-admin allow-list are just a starting point. Other good candidates are: mandatory TLS settings on Routes, allowed image registries, or an audit that no application team runs its own database. If you can express it with <code>oc get …​ -o json | jq</code>, you can most likely express it in CEL.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_thank_you">Thank You</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This article would not exist without <a href="https://www.linkedin.com/in/mthuring/" rel="noopener" target="_blank">Max Thüringer</a> and <a href="https://www.linkedin.com/in/steffen-l-b0a840249/" rel="noopener" target="_blank">Steffen Lützenkirchen</a>. After listening to the talk <strong>&#34;More than just Compliance&#34;</strong> at OpenShift User Conference in Vienna, I wanted to see how far the CEL scanner of the Compliance Operator can go.</p>
</div>
<div class="paragraph">
<p>Thank you, <a href="https://www.linkedin.com/in/mthuring/" rel="noopener" target="_blank">Max Thüringer</a> and <a href="https://www.linkedin.com/in/steffen-l-b0a840249/" rel="noopener" target="_blank">Steffen Lützenkirchen</a>, for sharing your ideas and for the inspiration.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.redhat.com/en/documentation/openshift_container_platform/4.20/html/security_and_compliance/compliance-operator" rel="noopener" target="_blank">Red Hat Documentation: Compliance Operator (incl. release notes)</a></p>
</li>
<li>
<p><a href="https://developers.redhat.com/articles/2025/12/02/automate-unique-compliance-checks-openshift-and-customrule" rel="noopener" target="_blank">Red Hat Developer: Automate unique compliance checks with OpenShift and CustomRule</a></p>
</li>
<li>
<p><a href="https://github.com/google/cel-spec" rel="noopener" target="_blank">CEL specification</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - Kubernetes Integration - Part 10</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-08-03-openbao-part-10-kubernetes-integration/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-08-03-openbao-part-10-kubernetes-integration/</guid><pubDate>Mon, 03 Aug 2026 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Integrating OpenBao with Kubernetes workloads using Agent Injector, CSI Provider, and External Secrets Operator on OpenShift</description><content:encoded><![CDATA[<div class="paragraph">
<p>With authentication and secrets engines configured, the next step is enabling applications to consume secrets. This article covers three integration patterns on OpenShift:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>the <strong>Agent Injector</strong> for sidecar injection</p>
</li>
<li>
<p>the <strong>CSI Provider</strong> for volume mounts</p>
</li>
<li>
<p>the <strong>External Secrets Operator (ESO)</strong> for syncing to native Kubernetes Secrets.</p>
</li>
</ol>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>There are three main patterns for Kubernetes workloads to consume OpenBao secrets:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 14.2857%;"/>
<col style="width: 28.5714%;"/>
<col style="width: 28.5714%;"/>
<col style="width: 28.5715%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Method</th>
<th class="tableblock halign-left valign-top">How It Works</th>
<th class="tableblock halign-left valign-top">Pros</th>
<th class="tableblock halign-left valign-top">Cons</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Agent Injector</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Sidecar injects secrets as files under <code>/vault/secrets/</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Automatic renewal, templates, dynamic secrets</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Extra container per pod</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">CSI Provider</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Mounts secrets as volumes (optional sync to a Secret)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No sidecar needed</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No continuous auto-renewal (refresh on pod restart)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">External Secrets Operator</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Syncs to native Kubernetes Secrets</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">GitOps-friendly, standard <code>secretKeyRef</code> / volumes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Additional operator + NetworkPolicy considerations on OpenShift</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
OpenBao keeps a Vault-compatible API. Agent Injector annotations still use the <code>vault.hashicorp.com/</code> prefix, and ESO uses its Vault provider. The CSI provider, however, uses <code>provider: openbao</code> and <code>baoAddress</code> / <code>baoCACertPath</code> parameters. Still, it should be easy to understand the differences and map everything to HashiCorp Vault.
</td>
</tr>
</tbody></table>
</div>
<div class="sect2">
<h3 id="_lab_assumptions">Lab assumptions</h3>
<div class="paragraph">
<p>These examples assume:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenBao is installed in namespace <code>openbao</code> with TLS (see the series articles on OpenShift deployment and TLS, and test case <a href="https://tests.stdin.at/tests/TC-OPENBAO-OCP-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-OCP-001</a>).</p>
</li>
<li>
<p>Kubernetes auth is enabled and configured (<a href="https://tests.stdin.at/tests/TC-OPENBAO-AUTH-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-AUTH-001</a> / <a href="/openshift-platform/security/secrets-management/openbao/2026-03-09-openbao-part-7-authentication-methods/" rel="noopener" target="_blank">Part 7</a>).</p>
</li>
<li>
<p>A KV v2 mount exists at <code>secret/</code> (<a href="/openshift-platform/security/secrets-management/openbao/2026-03-25-openbao-part-8-secrets-engines-kv/" rel="noopener" target="_blank">Part 8</a>).</p>
</li>
<li>
<p>Policy <code>myapp</code> allows <code>read</code> on <code>secret/data/myapp/*</code> (and metadata list as needed).</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Related <strong>Test Cases</strong> are:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><a href="https://tests.stdin.at/tests/TC-OPENBAO-KV-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-KV-001</a> — Enable and Use KV v2 Secrets Engine</p>
</li>
<li>
<p><a href="https://tests.stdin.at/tests/TC-OPENBAO-KV-003?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-KV-003</a> — KV Secret Rotation Pattern with CAS</p>
</li>
<li>
<p><a href="https://tests.stdin.at/tests/TC-OPENBAO-UC-003?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-UC-003</a> — Multi-Tenant Secret Isolation</p>
</li>
<li>
<p><a href="https://tests.stdin.at/tests/TC-OPENBAO-DB-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-DB-001</a> — Dynamic PostgreSQL Credentials</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>These and other test cases are available on <a href="https://tests.stdin.at/" rel="noopener" target="_blank">tests.stdin.at</a>.</p>
</div>
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Create the lab namespace and ServiceAccount. This namespace will be reused for all three patterns below:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc new-project myapp
oc create serviceaccount myapp-sa -n myapp</code></pre>
</div>
</div>
<div class="paragraph">
<p>Store sample secrets and bind the auth role to <strong>this</strong> namespace:</p>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
<div class="paragraph">
<p>OpenBao must be installed and you need proper access to the API.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Brief reminder:
export BAO_CACERT=&#34;$HOME/openbao-tests/openbao-ca.crt&#34;
export BAO_ADDR=&#39;https://127.0.0.1:8200&#39;
export BAO_TOKEN=$(jq -r &#39;.root_token&#39; openbao-init.json)
bao status</code></pre>
</div>
</div>
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Allow the myapp identity to read KV v2 data (and list metadata) under secret/myapp/
bao policy write myapp - &lt;&lt;&#39;EOF&#39;
path &#34;secret/data/myapp/*&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;]
}
path &#34;secret/metadata/myapp/*&#34; {
  capabilities = [&#34;list&#34;]
}
EOF

# Map ServiceAccount myapp-sa in namespace myapp to that policy via Kubernetes auth
bao write auth/kubernetes/role/myapp \
  bound_service_account_names=myapp-sa \
  bound_service_account_namespaces=myapp \
  policies=myapp \
  ttl=1h

# Seed sample secrets for Injector / CSI / ESO examples later in this article
bao kv put secret/myapp/config db_host=pg.example.com db_password=s3cret
bao kv put secret/myapp/api key=api-key-123</code></pre>
</div>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
If <code>cas_required</code> is enabled on the KV mount (<a href="https://tests.stdin.at/tests/TC-OPENBAO-KV-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-KV-002</a>), every write must include <code>-cas=&lt;current_version&gt;</code>. When updating values that ESO or CSI consume, rewrite <strong>all</strong> properties the consumer expects — a partial put replaces the whole version and drops missing keys.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_pattern_1_agent_injector">Pattern 1: Agent Injector</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The Agent Injector uses a mutating webhook to <strong>inject an init container</strong> and an optional sidecar that authenticates to OpenBao and renders secrets under <code>/vault/secrets/</code>.</p>
</div>
<div class="sect2">
<h3 id="_how_it_works">How It Works</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">1. Pod created with vault.hashicorp.com/* annotations
2. Mutating webhook intercepts admission
3. vault-agent-init (and optionally vault-agent sidecar) injected
4. Agent authenticates with the pod ServiceAccount JWT (Kubernetes auth)
5. Agent retrieves secrets and writes templated files
6. Application reads from /vault/secrets/
7. Sidecar renews tokens / leases and re-renders as needed</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_prerequisites">Prerequisites</h3>
<div class="paragraph">
<p>On the OpenShift Helm deployment used in this series, the injector is enabled with the chart (typically two replicas) as part of <a href="https://tests.stdin.at/tests/TC-OPENBAO-OCP-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-OCP-001</a>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">injector:
  enabled: true
  replicas: 2</code></pre>
</div>
</div>
<div class="paragraph">
<p>Verify it is running:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get pods -n openbao -l app.kubernetes.io/name=openbao-agent-injector

# Check webhook
oc get mutatingwebhookconfigurations | grep openbao</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_tls_trust_in_the_application_namespace">TLS trust in the application namespace</h3>
<div class="paragraph">
<p>With a TLS listener, the Agent must trust the OpenBao CA. Copy the CA into the app namespace and reference it from annotations (<code>tls-secret</code> / <code>ca-cert</code>):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc create secret generic openbao-ca -n myapp \
  --from-literal=ca.crt=&#34;$(oc get secret openbao-ca-secret -n openbao -o jsonpath=&#39;{.data.ca\.crt}&#39; | base64 -d)&#34; \
  --dry-run=client -o yaml | oc apply -f -</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_deploy_an_application_with_annotations">Deploy an application with annotations</h3>
<div class="paragraph">
<p>The Deployment below follows <a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-003?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-003</a> (OpenBao Agent Sidecar Injector). That test case validates the full path: mutating webhook injection, Kubernetes auth as ServiceAccount <code>myapp-sa</code>, OpenBao role <code>myapp</code>, TLS trust via the <code>openbao-ca</code> secret copied earlier, and rendered files under <code>/vault/secrets/</code>.</p>
</div>
<div class="paragraph">
<p>In practical terms, the annotations tell the Agent to:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>authenticate with role <code>myapp</code> (bound to <code>myapp-sa</code> in namespace <code>myapp</code>);</p>
</li>
<li>
<p>fetch KV v2 paths <code>secret/data/myapp/config</code> and <code>secret/data/myapp/api</code>;</p>
</li>
<li>
<p>write templated output to <code>/vault/secrets/config.txt</code> and <code>/vault/secrets/api-key</code>.</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">cat &lt;&lt;EOF | oc apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  namespace: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
      annotations:
        vault.hashicorp.com/agent-inject: &#34;true&#34; <i class="conum" data-value="1"></i><b>(1)</b>
        vault.hashicorp.com/role: &#34;myapp&#34; <i class="conum" data-value="2"></i><b>(2)</b>
        vault.hashicorp.com/tls-secret: &#34;openbao-ca&#34; <i class="conum" data-value="3"></i><b>(3)</b>
        vault.hashicorp.com/ca-cert: &#34;/vault/tls/ca.crt&#34;
        vault.hashicorp.com/agent-inject-secret-config.txt: &#34;secret/data/myapp/config&#34; <i class="conum" data-value="4"></i><b>(4)</b>
        vault.hashicorp.com/agent-inject-template-config.txt: |
          {{- with secret &#34;secret/data/myapp/config&#34; -}}
          DB_HOST={{ .Data.data.db_host }}
          DB_PASSWORD={{ .Data.data.db_password }}
          {{- end }}
        vault.hashicorp.com/agent-inject-secret-api-key: &#34;secret/data/myapp/api&#34;
        vault.hashicorp.com/agent-inject-template-api-key: |
          {{- with secret &#34;secret/data/myapp/api&#34; -}}
          {{ .Data.data.key }}
          {{- end }}
    spec:
      serviceAccountName: myapp-sa <i class="conum" data-value="5"></i><b>(5)</b>
      securityContext:
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containers:
        - name: app
          image: curlimages/curl:latest
          command: [&#34;sleep&#34;, &#34;infinity&#34;]
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop: [&#34;ALL&#34;]
            runAsNonRoot: true
            seccompProfile:
              type: RuntimeDefault
EOF</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Enable injection (API-compatible <code>vault.hashicorp.com</code> annotations).</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Kubernetes auth role name in OpenBao.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Secret in the app namespace that holds the OpenBao CA.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>KV v2 path includes the <code>/data/</code> segment for the Agent template.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Must match <code>bound_service_account_names</code> / <code>namespaces</code> on the role.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_verify_injection">Verify injection</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get pods -n myapp
# Expect READY 2/2 (app + vault-agent) when the sidecar is enabled

oc get pods -n myapp -o jsonpath=&#39;{.items[0].spec.containers[*].name}{&#34;\n&#34;}&#39;
# Expected: app vault-agent

oc get pods -n myapp -o jsonpath=&#39;{.items[0].spec.initContainers[*].name}{&#34;\n&#34;}&#39;
# Expected: vault-agent-init

oc exec -it deploy/myapp -c app -n myapp -- cat /vault/secrets/config.txt
# Expected: DB_HOST=pg.example.com
#           DB_PASSWORD=s3cret

oc exec -it deploy/myapp -c app -n myapp -- cat /vault/secrets/api-key
# Expected: api-key-123</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_common_annotations">Common annotations</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 40%;"/>
<col style="width: 60%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Annotation</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/agent-inject</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enable/disable injection (<code>&#34;true&#34;</code> / <code>&#34;false&#34;</code>)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/role</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">OpenBao Kubernetes auth role</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/tls-secret</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Secret containing the CA used to verify OpenBao TLS</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/ca-cert</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Path to the CA file inside the Agent (for example <code>/vault/tls/ca.crt</code>)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/agent-inject-secret-&lt;name&gt;</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Secret path; creates <code>/vault/secrets/&lt;name&gt;</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/agent-inject-template-&lt;name&gt;</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Consul Template syntax for rendering the file</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/agent-inject-status</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Set to <code>&#34;update&#34;</code> to force re-injection</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/agent-pre-populate-only</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>&#34;true&#34;</code> = init container only, no sidecar</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/agent-revoke-on-shutdown</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>&#34;true&#34;</code> = revoke the token when the pod terminates</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault.hashicorp.com/tls-skip-verify</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Skip TLS verification (lab only — prefer a real CA)</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_init_container_only_mode">Init-container-only mode</h3>
<div class="paragraph">
<p>By default the injector adds both <code>vault-agent-init</code> and a long-running <code>vault-agent</code> sidecar. Set <code>agent-pre-populate-only: &#34;true&#34;</code> when the application only needs secrets <strong>during the init phase</strong> (for example: static KV, config files, API keys). The init container still authenticates, renders files under <code>/vault/secrets/</code>, then exits; the sidecar is omitted, so the pod stays <code>1/1</code> Ready and uses less CPU and memory.</p>
</div>
<div class="paragraph">
<p>Trade-off: there is <strong>no</strong> continuous lease renewal or re-render. If OpenBao rotates a secret or a dynamic credential expires, the application will not see the update until the pod restarts.</p>
</div>
<div class="paragraph">
<p>Minimal annotations for this mode:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">annotations:
  vault.hashicorp.com/agent-inject: &#34;true&#34; <i class="conum" data-value="1"></i><b>(1)</b>
  vault.hashicorp.com/agent-pre-populate-only: &#34;true&#34; <i class="conum" data-value="2"></i><b>(2)</b>
  vault.hashicorp.com/role: &#34;myapp&#34; <i class="conum" data-value="3"></i><b>(3)</b>
  vault.hashicorp.com/tls-secret: &#34;openbao-ca&#34; <i class="conum" data-value="4"></i><b>(4)</b>
  vault.hashicorp.com/ca-cert: &#34;/vault/tls/ca.crt&#34;
  vault.hashicorp.com/agent-inject-secret-config.txt: &#34;secret/data/myapp/config&#34; <i class="conum" data-value="5"></i><b>(5)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Enable the mutating webhook for this pod.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Init container only — skip the sidecar.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Kubernetes auth role (must match SA name/namespace bindings).</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>CA Secret in the app namespace so the Agent trusts OpenBao TLS.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>KV v2 path to render as <code>/vault/secrets/config.txt</code> (add further <code>agent-inject-secret-*</code> / template annotations as needed).</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock tip">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
For dynamic database credentials with lease renewal, prefer the full sidecar mode, see <a href="https://tests.stdin.at/tests/TC-OPENBAO-UC-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-UC-002</a> (Agent sidecar + PostgreSQL role).
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_pattern_2_csi_provider">Pattern 2: CSI Provider</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The Secrets Store CSI Driver mounts secrets as files without an application sidecar. On OpenShift the lab flow is: install the driver (OperatorHub/Software Catalog preferred), manage <code>ClusterCSIDriver</code>, grant the provider SCC, enable the OpenBao CSI DaemonSet on the existing Helm release, then create a <code>SecretProviderClass</code>.</p>
</div>
<div class="paragraph">
<p>This section aligns with <a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-002</a> and the <a href="https://openbao.org/docs/platform/k8s/csi/" rel="noopener" target="_blank">OpenBao CSI documentation</a>.</p>
</div>
<div class="sect2">
<h3 id="_installing_the_secrets_store_csi_driver">Installing the Secrets Store CSI Driver</h3>
<div class="paragraph">
<p>Prefer the OpenShift Operator:</p>
</div>
<div class="paragraph">
<p>Install <strong>Secrets Store CSI Driver for Red Hat OpenShift</strong> from OperatorHub. Search for &#34;Secrets Store CSI Driver for Red Hat OpenShift&#34; and install the operator with the default settings.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part10_CSIStorageOperator.png?width=840px" alt="OperatorHub/Software Catalog — Secrets Store CSI Driver for Red Hat OpenShift"/>
</div>
</div>
<div class="paragraph">
<p>On OpenShift, each CSI driver is switched on with a cluster-scoped <code>ClusterCSIDriver</code> whose <code>metadata.name</code> must match the driver identifier — here it is <code>secrets-store.csi.k8s.io</code>.</p>
</div>
<div class="paragraph">
<p>Create that object next:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: operator.openshift.io/v1
kind: ClusterCSIDriver
metadata:
  name: secrets-store.csi.k8s.io <i class="conum" data-value="1"></i><b>(1)</b>
spec:
  managementState: Managed</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Must equal the Secrets Store CSI driver name</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_openbao_csi_provider_on_openshift">OpenBao CSI provider on OpenShift</h3>
<div class="paragraph">
<p>The provider uses <code>hostPath</code> and needs the privileged SCC:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc adm policy add-scc-to-user privileged -z openbao-csi-provider -n openbao</code></pre>
</div>
</div>
<div class="paragraph">
<p>Enable CSI on the existing OpenBao Helm release (chart <strong>0.18.0+</strong>), mounting the OpenBao CA into the DaemonSet — same steps (Step 4) as <a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-002</a>:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If this was done already, you can skip this step. The important part here is to enable the CSI part in OpenBao.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">helm upgrade --install openbao openbao/openbao -n openbao --reuse-values \
  --set csi.enabled=true \
  --set csi.daemonSet.securityContext.container.privileged=true \
  --set &#39;csi.volumes[0].name=openbao-ca&#39; \
  --set &#39;csi.volumes[0].secret.secretName=openbao-ca-secret&#39; \
  --set &#39;csi.volumeMounts[0].name=openbao-ca&#39; \
  --set &#39;csi.volumeMounts[0].mountPath=/openbao/tls&#39; \
  --set &#39;csi.volumeMounts[0].readOnly=true&#39; \
  --set &#39;csi.agent.extraArgs[0]=-ca-path=/openbao/tls/ca.crt&#39;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Verify:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get ds -n openbao openbao-csi-provider
# Desired/Ready should match the node count</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_creating_a_secretproviderclass">Creating a SecretProviderClass</h3>
<div class="paragraph">
<p>A <code>SecretProviderClass</code> tells the Secrets Store CSI driver <strong>which provider</strong> to call and <strong>which secrets to mount</strong>. The CSI node plugin talks to the OpenBao CSI provider DaemonSet over gRPC; that provider then authenticates to OpenBao (Kubernetes auth role <code>myapp</code> in our test case) and fetches the listed objects.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Unlike the Agent Injector annotations and ESO’s Vault provider, the CSI parameters are OpenBao-specific. The CA file path must match the volume mounted into the provider DaemonSet in the Helm step above (<code>/openbao/tls/ca.crt</code>), so TLS verification succeeds.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
  name: openbao-secrets
  namespace: myapp
spec:
  provider: openbao <i class="conum" data-value="1"></i><b>(1)</b>
  parameters:
    baoAddress: &#34;https://openbao.openbao.svc:8200&#34; <i class="conum" data-value="2"></i><b>(2)</b>
    baoCACertPath: &#34;/openbao/tls/ca.crt&#34; <i class="conum" data-value="3"></i><b>(3)</b>
    roleName: &#34;myapp&#34; <i class="conum" data-value="4"></i><b>(4)</b>
    objects: |
      - objectName: &#34;db_password&#34;
        secretPath: &#34;secret/data/myapp/config&#34;
        secretKey: &#34;db_password&#34;
      - objectName: &#34;api_key&#34;
        secretPath: &#34;secret/data/myapp/api&#34;
        secretKey: &#34;key&#34;
  secretObjects: <i class="conum" data-value="5"></i><b>(5)</b>
    - secretName: myapp-synced
      type: Opaque
      data:
        - objectName: db_password
          key: db_password
        - objectName: api_key
          key: api_key</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>OpenBao CSI provider name — do not use <code>vault</code> here.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>In-cluster Service DNS and HTTPS listener; avoid the public Route for node-local mounts.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>CA path <strong>inside the CSI provider DaemonSet</strong> (from the Helm <code>csi.volumeMounts</code>), not a path in the app pod.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Kubernetes auth role; the mounting pod’s ServiceAccount must match the role bindings.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Optional: also sync mounted files into a native Secret (<code>myapp-synced</code>) for <code>secretKeyRef</code> / env vars.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_using_csi_in_a_pod">Using CSI in a Pod</h3>
<div class="paragraph">
<p>The application pod does <strong>not</strong> talk to OpenBao itself. It mounts an ephemeral CSI volume that references the <code>SecretProviderClass</code>. On start, kubelet asks the Secrets Store CSI driver; the driver calls the OpenBao provider, which logs in with the pod’s ServiceAccount JWT and writes the secret objects into the volume (and, if configured, into the synced Secret).</p>
</div>
<div class="paragraph">
<p>Use the same ServiceAccount (<code>myapp-sa</code>) that the OpenBao role allows. Unlike the Agent Injector, there is no sidecar — the pod stays a single container, and secret files appear under the mount path you choose (here <code>/mnt/secrets</code>).</p>
</div>
<div class="paragraph">
<p>This time a simple Pod …​ because I am too lazy to create a Deployment.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  namespace: myapp
spec:
  serviceAccountName: myapp-sa <i class="conum" data-value="1"></i><b>(1)</b>
  securityContext:
    runAsNonRoot: true
    seccompProfile:
      type: RuntimeDefault
  containers:
    - name: app
      image: curlimages/curl:latest
      command: [&#34;sleep&#34;, &#34;infinity&#34;]
      securityContext:
        allowPrivilegeEscalation: false
        capabilities:
          drop: [&#34;ALL&#34;]
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      volumeMounts:
        - name: secrets
          mountPath: /mnt/secrets <i class="conum" data-value="2"></i><b>(2)</b>
          readOnly: true
      env:
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: myapp-synced <i class="conum" data-value="3"></i><b>(3)</b>
              key: db_password
  volumes:
    - name: secrets
      csi:
        driver: secrets-store.csi.k8s.io <i class="conum" data-value="4"></i><b>(4)</b>
        readOnly: true
        volumeAttributes:
          secretProviderClass: openbao-secrets <i class="conum" data-value="5"></i><b>(5)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Must match <code>bound_service_account_names</code> / <code>namespaces</code> on role <code>myapp</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Files such as <code>db_password</code> and <code>api_key</code> appear here (<code>objectName</code> from the SecretProviderClass).</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Optional env consumption via the synced Secret from <code>secretObjects</code> — only works if that block was defined.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Driver registered by the <code>ClusterCSIDriver</code> earlier in this section.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Links this volume to the <code>SecretProviderClass</code> in the same namespace.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Verify:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc exec -it myapp-pod -n myapp -- ls -la /mnt/secrets/
oc exec -it myapp-pod -n myapp -- cat /mnt/secrets/db_password</code></pre>
</div>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_pattern_3_external_secrets_operator_eso">Pattern 3: External Secrets Operator (ESO)</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The External Secrets Operator (ESO) synchronises secrets from OpenBao into native Kubernetes Secrets. It is a controller that talks to an external secrets backend (OpenBao here) and creates a native Secret in the namespace for the application to consume. The OpenShift lab path is <a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-001</a>.</p>
</div>
<div class="sect2">
<h3 id="_installing_external_secrets_operator">Installing External Secrets Operator</h3>
<div class="paragraph">
<p>On OpenShift, install <strong>External Secrets Operator for Red Hat OpenShift</strong> from OperatorHub/Software Catalog. After the Operator is installed, create an <code>ExternalSecretsConfig</code> named <code>cluster</code>. This is a cluster-scoped object and will start the controller.</p>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
The default NetworkPolicies for the Red Hat ESO operand deny egress. Without an allow rule to OpenBao on TCP/8200, SecretStore login fails with <code>context deadline exceeded</code>.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: operator.openshift.io/v1alpha1
kind: ExternalSecretsConfig
metadata:
  name: cluster
spec:
  controllerConfig:
    networkPolicies:
      - name: allow-openbao-egress
        componentName: ExternalSecretsCoreController
        egress:
          - ports:
              - protocol: TCP
                port: 8200
            to:
              - namespaceSelector:
                  matchLabels:
                    kubernetes.io/metadata.name: openbao</code></pre>
</div>
</div>
<div class="paragraph">
<p>Verify the deployment:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get pods -n external-secrets</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_creating_a_secretstore">Creating a SecretStore</h3>
<div class="paragraph">
<p>A <code>SecretStore</code> is a <strong>namespaced</strong> object that defines the connection to OpenBao: it tells ESO how to reach OpenBao and how to authenticate. It does not create application Secrets by itself — that is the job of an <code>ExternalSecret</code> in the next step.</p>
</div>
<div class="paragraph">
<p>Because the lab uses TLS, first fetch the CA certificate from the OpenBao CA Secret and use it for the <strong>SecretStore</strong>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Base64 CA PEM (one line) for caBundle
oc get secret openbao-ca-secret -n openbao -o jsonpath=&#39;{.data.ca\.crt}{&#34;\n&#34;}&#39;</code></pre>
</div>
</div>
<div class="paragraph">
<p>ESO has no separate “OpenBao” provider. Use the <strong>Vault</strong> provider against OpenBao’s compatible API, with Kubernetes auth and the same <code>myapp</code> / <code>myapp-sa</code> bindings as Injector and CSI:</p>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
Replace the <code>&lt;BASE64_CA_PEM&gt;</code> with the base64 encoded CA certificate.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: external-secrets.io/v1
kind: SecretStore
metadata:
  name: openbao-backend
  namespace: myapp
spec:
  provider:
    vault: <i class="conum" data-value="1"></i><b>(1)</b>
      server: &#34;https://openbao.openbao.svc:8200&#34; <i class="conum" data-value="2"></i><b>(2)</b>
      path: &#34;secret&#34; <i class="conum" data-value="3"></i><b>(3)</b>
      version: &#34;v2&#34;
      caBundle: &#34;&lt;BASE64_CA_PEM&gt;&#34; <i class="conum" data-value="4"></i><b>(4)</b>
      auth:
        kubernetes:
          mountPath: &#34;kubernetes&#34;
          role: &#34;myapp&#34; <i class="conum" data-value="5"></i><b>(5)</b>
          serviceAccountRef:
            name: myapp-sa</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Vault provider → OpenBao’s compatible HTTP API (there is no <code>openbao:</code> block in ESO yet).</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>In-cluster Service over HTTPS; the ESO controller must be allowed to reach it (NetworkPolicy above).</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>KV mount path <strong>without trailing slash</strong>; version.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Paste the base64 value from <code>openbao-ca-secret</code> (do not wrap or re-encode).</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Role and SA must match OpenBao’s Kubernetes auth bindings for namespace <code>myapp</code>.</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get secretstore openbao-backend -n myapp
# STATUS should indicate Ready / Valid</code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
If the store stays Not Ready, check NetworkPolicy egress to OpenBao, the <code>caBundle</code>, and that role <code>myapp</code> still allows <code>myapp-sa</code> in <code>myapp</code>.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
For cluster-wide access, use a <code>ClusterSecretStore</code> with a ServiceAccount that OpenBao trusts (role + policy bound to that SA/namespace).
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_creating_an_externalsecret">Creating an ExternalSecret</h3>
<div class="paragraph">
<p>An <code>ExternalSecret</code> maps remote OpenBao keys onto a <strong>native</strong> Kubernetes Secret. ESO periodically authenticates via the <code>SecretStore</code>, reads the listed properties, and writes (or updates) the target Secret. Applications then use ordinary <code>secretKeyRef</code> or volume mounts — they never call OpenBao directly. This keeps applications secret-agnostic so developers can keep using ordinary Kubernetes Secret consumption.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
  name: myapp-secrets
  namespace: myapp
spec:
  refreshInterval: &#34;5m&#34; <i class="conum" data-value="1"></i><b>(1)</b>
  secretStoreRef:
    name: openbao-backend
    kind: SecretStore
  target:
    name: myapp-secrets <i class="conum" data-value="2"></i><b>(2)</b>
    creationPolicy: Owner
    template:
      type: Opaque
  data:
    - secretKey: db_host <i class="conum" data-value="3"></i><b>(3)</b>
      remoteRef:
        key: myapp/config <i class="conum" data-value="4"></i><b>(4)</b>
        property: db_host
    - secretKey: db_password
      remoteRef:
        key: myapp/config
        property: db_password
    - secretKey: api_key
      remoteRef:
        key: myapp/api
        property: key</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>How often ESO re-reads OpenBao; use <code>force-sync</code> (below) for an immediate refresh in the lab.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Name of the Kubernetes Secret that ESO creates or owns in this namespace.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Key name <strong>inside</strong> the Kubernetes Secret (what the app will reference).</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Path relative to the store’s <code>path: secret</code> — <strong>without</strong> the KV v2 <code>/data/</code> segment.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
For KV v2, ESO’s <code>remoteRef.key</code> is typically <code>myapp/config</code>, while Agent/CSI templates use <code>secret/data/myapp/config</code>. Mixing the two path styles is a common source of sync errors.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Verify:</p>
</div>
<div class="paragraph">
<p>The first command will show the status of the sync process. The second command will fetch the actual generated secret and show the keys and values.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get ExternalSecret myapp-secrets -n myapp
# STATUS should be SecretSynced

oc get secret myapp-secrets -n myapp -o jsonpath=&#39;{.data}&#39; | \
  jq &#39;to_entries[] | {key: .key, value: (.value | @base64d)}&#39;
# Should show db_host, db_password, api_key</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_fetching_all_keys_from_a_specific_path">Fetching all keys from a specific path</h3>
<div class="paragraph">
<p>When every field under one OpenBao secret should become a Kubernetes Secret key, use <code>dataFrom.extract</code> instead of listing each <code>property</code>. Here all keys from <code>secret/myapp/config</code> (for example <code>db_host</code>, <code>db_password</code>) are copied into <code>myapp-all-config</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
  name: myapp-all-config
  namespace: myapp
spec:
  refreshInterval: 1h
  secretStoreRef:
    name: openbao-backend
    kind: SecretStore
  target:
    name: myapp-all-config
  dataFrom:
    - extract:
        key: myapp/config</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_using_the_generated_secret">Using the generated Secret</h3>
<div class="paragraph">
<p>Once the ExternalSecret is synced, treat <code>myapp-secrets</code> like any other Opaque Secret: environment variables via <code>secretKeyRef</code>, or files via a <code>secret</code> volume. No Injector annotations or CSI <code>SecretProviderClass</code> are required on the workload.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-eso
  namespace: myapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp-eso
  template:
    metadata:
      labels:
        app: myapp-eso
    spec:
      containers:
        - name: app
          image: registry.access.redhat.com/ubi9/ubi-minimal:latest
          command: [&#34;sleep&#34;, &#34;infinity&#34;] <i class="conum" data-value="1"></i><b>(1)</b>
          env:
            - name: DB_HOST
              valueFrom:
                secretKeyRef:
                  name: myapp-secrets <i class="conum" data-value="2"></i><b>(2)</b>
                  key: db_host
            - name: DB_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: myapp-secrets
                  key: db_password
          volumeMounts:
            - name: config
              mountPath: /etc/config
              readOnly: true
      volumes:
        - name: config
          secret:
            secretName: myapp-secrets <i class="conum" data-value="3"></i><b>(3)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Keeps the lab Pod running so <code>oc exec</code> verification works; replace with the real application entrypoint in production.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Keys match <code>secretKey</code> values from the ExternalSecret <code>data</code> list.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Same Secret mounted as files under <code>/etc/config</code> (one file per key).</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Verify:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Environment variables from secretKeyRef
oc exec -n myapp deploy/myapp-eso -- printenv DB_HOST DB_PASSWORD
# Expect the decoded values from myapp-secrets

# Files from the secret volume (one file per key)
oc exec -n myapp deploy/myapp-eso -- ls -l /etc/config
# Expect db_host, db_password, api_key</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_refresh_after_an_openbao_update">Refresh after an OpenBao update</h3>
<div class="paragraph">
<p>KV v2 writes replace the <strong>entire</strong> version. When you rotate a password, rewrite every property the ExternalSecret still expects, or those keys disappear from the synced Secret. If <code>cas_required</code> is enabled, include <code>-cas=&lt;current_version&gt;</code> (see <a href="https://tests.stdin.at/tests/TC-OPENBAO-KV-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-KV-002</a>).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Rewrite all fields the ExternalSecret reads (KV v2 put replaces the version)
bao kv put --cas=&lt;latest_version&gt; secret/myapp/config \
  db_host=pg.example.com \
  db_password=newP@ssw0rd

# Force an immediate sync (do not wait for refreshInterval)
oc annotate externalsecret myapp-secrets -n myapp force-sync=$(date +%s) --overwrite</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_verifying_externalsecret_status">Verifying ExternalSecret status</h3>
<div class="paragraph">
<p>Confirm both the ExternalSecret condition and the materialised Secret contents:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get externalsecret -n myapp
# Expect SecretSynced / Ready

oc get secret myapp-secrets -n myapp -o jsonpath=&#39;{.data}&#39; | \
  jq &#39;to_entries[] | {key: .key, value: (.value | @base64d)}&#39;</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_comparing_integration_methods">Comparing integration methods</h2>
<div class="sectionbody">
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;"/>
<col style="width: 25%;"/>
<col style="width: 25%;"/>
<col style="width: 25%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Feature</th>
<th class="tableblock halign-left valign-top">Agent Injector</th>
<th class="tableblock halign-left valign-top">CSI Provider</th>
<th class="tableblock halign-left valign-top">ESO</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Auto-renewal</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No (pod lifecycle)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes (refresh interval / force-sync)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Sidecar needed</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">GitOps-friendly</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Annotations on workloads</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">SecretProviderClass + pod volume</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes (ExternalSecret CRs)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Standard K8s Secret</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No (files; optional app logic)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Optional via <code>secretObjects</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Dynamic secrets</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Limited</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Limited</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Template support</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes (Agent templates)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes (ESO templates)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">OpenShift extras</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Injector CA secret</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ClusterCSIDriver, SCC, Helm CSI</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">ExternalSecretsConfig + NetworkPolicy</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect1">
<h2 id="_best_practices">Best practices</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_choose_the_right_pattern">Choose the right pattern</h3>
<div class="ulist">
<ul>
<li>
<p><strong>Agent Injector</strong>: auto-renewal, dynamic secrets, or Consul Template-style files (<a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-003?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-003</a>, <a href="https://tests.stdin.at/tests/TC-OPENBAO-UC-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-UC-002</a>).</p>
</li>
<li>
<p><strong>CSI Provider</strong>: simple file mounts or synced Secrets without a sidecar (<a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-002</a>).</p>
</li>
<li>
<p><strong>ESO</strong>: GitOps and native <code>Secret</code> consumption (<a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-001</a>); combine with Sealed Secrets migration patterns in <a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-004?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-004</a> if you are moving off Bitnami Sealed Secrets.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_security_considerations">Security considerations</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Bind roles to a single namespace and SA
bao write auth/kubernetes/role/myapp \
  bound_service_account_names=myapp-sa \
  bound_service_account_namespaces=myapp \
  policies=myapp \
  ttl=1h

# Prefer short TTLs for dynamic database roles
bao write database/roles/myapp-readonly \
  default_ttl=1h \
  max_ttl=4h</code></pre>
</div>
</div>
<div class="paragraph">
<p>Always trust OpenBao TLS with a real CA (<code>caBundle</code>, <code>baoCACertPath</code>, or <code>tls-secret</code>) instead of <code>tls-skip-verify</code> outside throwaway labs.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This article covered three patterns for integrating OpenBao with Kubernetes and OpenShift:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Agent Injector</strong>: dynamic secrets and auto-renewal via annotated pods</p>
</li>
<li>
<p><strong>CSI Provider</strong>: volume mounts (and optional synced Secrets) with the OpenBao CSI provider</p>
</li>
<li>
<p><strong>External Secrets Operator</strong>: GitOps-friendly native Secrets, including OpenShift NetworkPolicy and TLS details</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Choose the pattern that fits each workload, or combine them. Step-by-step validation lives in the OpenBao plan on <a href="https://tests.stdin.at/?product=openbao" rel="noopener" target="_blank">tests.stdin.at</a>: <a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-001 — ESO</a>, <a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-002 — CSI</a>, <a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-003?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-003 — Injector</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org/docs/platform/k8s/injector" rel="noopener" target="_blank">Agent Injector documentation</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/platform/k8s/csi" rel="noopener" target="_blank">CSI Provider documentation</a></p>
</li>
<li>
<p><a href="https://external-secrets.io/latest/provider/hashicorp-vault/" rel="noopener" target="_blank">External Secrets Operator — Vault provider</a></p>
</li>
<li>
<p><a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-001?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-001 — ESO</a></p>
</li>
<li>
<p><a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-002?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-002 — CSI</a></p>
</li>
<li>
<p><a href="https://tests.stdin.at/tests/TC-OPENBAO-INT-003?product=openbao" rel="noopener" target="_blank">TC-OPENBAO-INT-003 — Injector</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>RBAC Overview — an OpenShift Console plugin</title><link>https://blog.stderr.at/openshift-platform/security/rbac/2026-06-10-rbac-overview-console-plugin/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/rbac/2026-06-10-rbac-overview-console-plugin/</guid><pubDate>Wed, 10 Jun 2026 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><category>Day-2</category><description>Install the RBAC Overview console plugin to inspect OpenShift cluster admins, namespace access, subjects, who-can queries and SCC authorisations in the UI.</description><content:encoded><![CDATA[<div class="paragraph">
<p>Answering the question <strong>&#34;who can do what on this cluster?&#34;</strong> usually means juggling oc commands, YAML dumps, and several console pages. RoleBindings live in namespaces, ClusterRoleBindings are cluster-scoped, OpenShift adds Users and Groups on top of Kubernetes subjects, and SecurityContextConstraints have their own authorisation model. For a quick audit before a change window, that is a lot of clicking and I always struggled to find a quick and reliable way to get and overview. For example, I always wanted to see immediately which users have cluster-admin rights or which service accounts are on the privileged SCC.</p>
</div>
<div class="paragraph">
<p>The <strong>RBAC Overview</strong> is a dynamic <strong>OpenShift Console plugin</strong> that pulls these views into one place. This article walks through what it does, how to install or test it, and how I use the tabs in practice. This open source plugin is available on <a href="https://github.com/tjungbauer/openshift-console-rbac-overview" rel="noopener" target="_blank">GitHub</a></p>
</div>
<div class="sect1">
<h2 id="_why_another_rbac_view">Why another RBAC view?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The console already lists RoleBindings, ClusterRoleBindings, Users, and Groups. That is sufficient when you know exactly which resource you need. It is less helpful when you start from a question:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Who has cluster-admin outside the usual system groups?</p>
</li>
<li>
<p>What can user alice do in the namespace openshift-gitops?</p>
</li>
<li>
<p>Which groups may get pods in the namespace default?</p>
</li>
<li>
<p>Which service accounts are on the privileged SCC?</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The RBAC Overview plugins tries to fix these questions. Each tab uses the Kubernetes and OpenShift authorization APIs (<code>SelfSubjectReview</code>, <code>ResourceAccessReview</code>, <code>SubjectAccessReview</code>, and list permissions) rather than re-implementing policy evaluation in the browser.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_what_you_get">What you get</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Navigation: The plugin hooks into the <strong>Administrator perspective → User Management → RBAC Overview</strong> (entry appears above <strong>Users</strong>).</p>
</div>
<div class="paragraph">
<p>As direct URL you can use: <code>&lt;cluster-url&gt;/rbac-overview</code>.</p>
</div>
<div class="paragraph">
<p>The following tabs are available:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;"/>
<col style="width: 75%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Tab</th>
<th class="tableblock halign-left valign-top">Question it answers</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Who can</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Who may perform a certain action or whether one subject is allowed to do certain actions. It basically mirrors the <code>oc adm policy who-can</code> command and presents the results in a more user-friendly way.
The tab also includes a <strong>Show my access</strong> button for the logged-in user, which shows what the logged in user can do on the cluster.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Cluster admins</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Cluster-wide and namespace-scoped bindings to sensitive roles (<code>cluster-admin</code>, <code>admin</code>, or roles you configure). This helps to see which users have elevated rights and which namespaces are affected.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Namespace access</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">All bindings that affect one namespace — local RoleBindings and applicable ClusterRoleBindings.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Subjects</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Pick a user, group, or service account and inspect its bindings. This helps to inspect a certain subject and see which roles are bound to it.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Role access</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Pick a ClusterRole and list every ClusterRoleBinding and RoleBinding that references it — the inverse of the Subjects tab when you start from a role name instead of a user or group.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>SCC access</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">All SCCs with key fields, direct <code>users</code> / <code>groups</code> / <code>serviceAccounts</code> on each SCC, and RBAC grants to <code>use securitycontextconstraints</code>. This helps to see which users, groups, and service accounts are on which SCCs and which RBAC grants are in place.</p></td>
</tr>
</tbody>
</table>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_architecture_in_brief">Architecture in brief</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The plugin follows the usual dynamic plugin pattern:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Webpack builds static assets (<code>plugin-manifest.json</code>, JavaScript bundles, locales).</p>
</li>
<li>
<p>A container image serves those files over <strong>HTTPS on port 9443</strong> (required by the <code>ConsolePlugin</code> API).</p>
</li>
<li>
<p>Helm installs Deployment, Service, ConsolePlugin, ConfigMap (<code>plugin-config.json</code>), and optionally a Job that enables the plugin on the console. (Plugins must be enabled by the console operator.)</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>The runtime image uses <a href="https://hummingbird-project.io/" rel="noopener" target="_blank">Project Hummingbird</a> (<code>registry.access.redhat.com/hi/nginx</code>). I tried this as they are expected to be super-small distroless images, with the goal to have zero CVEs …​ and the size of the image is really only 19MB.</p>
</div>
<div class="paragraph">
<p>The nginx that is used in this image is serving <code>dist/</code> with a serving certificate injected by OpenShift. There is no application logic in the container beyond static files.</p>
</div>
<div class="paragraph">
<p>Configuration for <strong>sensitive roles</strong> on the Cluster admins tab is delivered via <code>plugin-config.json</code> (Helm values → ConfigMap).
Default entries include <code>cluster-admin</code> and <code>admin</code>; you can add names or label ClusterRoles with <code>rbac-overview.io/elevated: &#34;true&#34;</code>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p>OpenShift Container Platform or OKD <strong>4.10+</strong> (dynamic console plugins)</p>
</li>
<li>
<p>For cluster install: Helm 3, <code>oc</code>, Podman or Docker, and permission to push your image registry</p>
</li>
<li>
<p>For local development: Node.js 22+, npm, and <code>oc login</code> with a <strong>bearer token</strong> (not certificate-only kubeconfig)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The plugin is tested against recent 4.20+ consoles. Match the console SDK generation to your cluster (the repository currently targets <code>@openshift-console/dynamic-plugin-sdk@4.21-latest</code>).</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_install_on_a_cluster">Install on a cluster</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_install_with_helm">Install with Helm</h3>
<div class="paragraph">
<p>Log in to the cluster, then install the chart. The published and public plugin image is <code>quay.io/tjungbau/openshift-console-rbac-overview:1.0.5</code> (chart version <strong>1.0.5</strong>).</p>
</div>
<div class="paragraph">
<p>From the <a href="https://github.com/tjungbauer/openshift-console-rbac-overview" rel="noopener" target="_blank">repository</a>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc login https://&lt;api-url&gt;:6443 -u &lt;user&gt; -p &#39;&lt;password&gt;&#39;

git clone https://github.com/tjungbauer/openshift-console-rbac-overview.git
cd openshift-console-rbac-overview

helm upgrade --install rbac-overview ./chart/rbac-overview \
  --namespace rbac-overview \
  --create-namespace \
  --set namespace.create=false \
  --set image.tag=1.0.5 \
  --set image.pullPolicy=Always \
  --wait</code></pre>
</div>
</div>
<div class="paragraph">
<p>Or add the published Helm repository (no clone required):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">helm repo add rbac-overview https://tjungbauer.github.io/openshift-console-rbac-overview
helm repo update

helm upgrade --install rbac-overview rbac-overview/rbac-overview \
  --namespace rbac-overview \
  --create-namespace \
  --set namespace.create=false \
  --set image.tag=1.0.5 \
  --wait</code></pre>
</div>
</div>
<div class="paragraph">
<p>The chart defaults to <code>quay.io/tjungbau/openshift-console-rbac-overview</code>; set <code>image.tag</code> only when you need a specific release.</p>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Do not combine <code>helm --create-namespace</code> with <code>--set namespace.create=true</code>. Helm 4 reports an ownership error on the Namespace object. Use <code>--create-namespace</code> and <code>namespace.create=false</code> as shown above. I will clean this up in the future.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_build_your_own_image">Build your own image</h3>
<div class="paragraph">
<p>If you prefer to create your own image, for example in an air-gapped environment, you are free to do so. The runtime image is a thin nginx layer on top of webpack output — there is no <code>npm</code> step inside the container. This helps keep the image small and avoids unnecessary dependencies.</p>
</div>
<div class="paragraph">
<p>From the repository root:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">npm install
npm run build    # writes dist/ (plugin-manifest.json, bundles, locales)

podman build --platform=linux/amd64 \ <i class="conum" data-value="1"></i><b>(1)</b>
  -t &lt;your-registry-repository&gt;/:&lt;tag&gt; .

podman login &lt;your-registry-repository&gt;    # if your repository is private

podman push &lt;your-registry-repository&gt;/:&lt;tag&gt;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Use your own registry, repository and version tag.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Then point Helm at your image:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">helm upgrade --install rbac-overview ./chart/rbac-overview \
  --namespace rbac-overview \
  --create-namespace \
  --set namespace.create=false \
  --set image.repository=&lt;your-registry-repository&gt; \ <i class="conum" data-value="1"></i><b>(1)</b>
  --set image.tag=&lt;tag&gt; \ <i class="conum" data-value="2"></i><b>(2)</b>
  --set image.pullPolicy=Always \
  --wait</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Use your own registry and repository.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Use your own version tag.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The repository also ships <code>scripts/build-install.sh</code>, which runs <code>npm run build</code>, builds and pushes the image, installs the chart, and runs verification checks in one pass:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">chmod +x scripts/build-install.sh
QUAY_USER=&lt;your-quay-user&gt; ./scripts/build-install.sh</code></pre>
</div>
</div>
<div class="paragraph">
<p>Override <code>VERSION</code> or <code>PLATFORM</code> when the tag should differ from <code>package.json</code> or when you build on Apple Silicon for a <code>linux/amd64</code> cluster.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The script was created due to my own lazyness and it has quay.io hardcoded.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>After install, confirm the plugin is enabled:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get console.operator cluster -o jsonpath=&#39;{.spec.plugins}{&#34;\n&#34;}&#39;
oc -n rbac-overview get deploy,consoleplugin</code></pre>
</div>
</div>
<div class="paragraph">
<p>Open the console, switch to <strong>Administrator</strong>, and reload <strong>User Management → RBAC Overview</strong>.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_local_development">Local development</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you like to test the plugin locally first, you can do so by running the following commands - no image build required:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># terminal 1
npm install
npm run start

# terminal 2
oc login ...           # must provide a token: oc whoami --show-token
npm run start-console  # console on http://localhost:9000</code></pre>
</div>
</div>
<div class="paragraph">
<p>Open <a href="http://localhost:9000/rbac-overview" rel="noopener" target="_blank">http://localhost:9000/rbac-overview</a>. The console loads the plugin from <code>localhost:9001</code> while API calls use your <code>oc</code> session.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
On Apple Silicon, set <code>CONSOLE_IMAGE_PLATFORM=linux/amd64</code> before <code>npm run start-console</code>.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_using_the_plugin">Using the plugin</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_who_can">Who can</h3>
<div class="paragraph">
<p>The default tab mirrors <code>oc adm policy who-can</code> for namespaced and cluster-scoped resources.</p>
</div>
<div class="paragraph">
<p><strong>Query mode</strong> offers:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Who can</strong> — list subjects allowed to perform the action</p>
</li>
<li>
<p><strong>Can subject</strong> — check one user, group, or service account</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Set <strong>Scope</strong>, <strong>Verb</strong>, <strong>Resource</strong>, optional <strong>API group</strong>, <strong>Subresource</strong>, <strong>Resource name</strong>, and for namespaced queries a real <strong>Namespace</strong>.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/RBAC/images/rbac-overview-who-can-results.png?width=900px" alt="Who can results for get pods in default"/>
</div>
</div>
<div class="paragraph">
<p>The button <strong>Show my access</strong> lists groups, visible namespaces, and role bindings for the logged-in user. This becomes handy when someone asks <strong>what can I actually see on this cluster?</strong></p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/RBAC/images/rbac-overview-my-access.png?width=900px" alt="Show my access panel"/>
</div>
</div>
<div class="paragraph">
<p>From <strong>My access</strong> you can jump to <strong>Can subject</strong> with your user pre-filled, or open the <strong>Subjects</strong> tab on yourself.</p>
</div>
</div>
<div class="sect2">
<h3 id="_cluster_admins">Cluster admins</h3>
<div class="paragraph">
<p>This tab highlights bindings to roles you treat as <strong>elevated</strong> (configured in plugin-config.json or via the rbac-overview.io/elevated label on ClusterRoles).</p>
</div>
<div class="paragraph">
<p>Sub tabs:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Cluster-wide admins</strong> — ClusterRoleBindings to sensitive ClusterRoles.</p>
</li>
<li>
<p><strong>Namespace elevated</strong> — RoleBindings in any namespace that reference sensitive roles.</p>
</li>
</ul>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/RBAC/images/rbac-overview-cluster-admins.png?width=900px" alt="Cluster-wide sensitive bindings"/>
</div>
</div>
<div class="paragraph">
<p>Use <strong>View rules</strong> on a row to expand policy rules below the table.</p>
</div>
</div>
<div class="sect2">
<h3 id="_namespace_access">Namespace access</h3>
<div class="paragraph">
<p>Select a namespace, then browse:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>In namespace</strong> — RoleBindings defined in that namespace.</p>
</li>
<li>
<p><strong>Cluster-wide</strong> — ClusterRoleBindings whose ClusterRoles apply there.</p>
</li>
</ul>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/RBAC/images/rbac-overview-namespace-access.png?width=900px" alt="Namespace access for openshift-gitops"/>
</div>
</div>
<div class="paragraph">
<p>The default filter shows <strong>User</strong> and <strong>Group</strong> subjects; add <strong>ServiceAccount</strong> when you care about workload identities.</p>
</div>
</div>
<div class="sect2">
<h3 id="_subjects">Subjects</h3>
<div class="paragraph">
<p>If you are interested to query a specific subject (user, group etc.) you can use this tab. The list merges:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>subjects found in RoleBindings and ClusterRoleBindings across the cluster, and</p>
</li>
<li>
<p>Users, Groups, and ServiceAccounts returned by the OpenShift user API (where your account may list them).</p>
</li>
</ul>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/RBAC/images/rbac-overview-subjects.png?width=900px" alt="Subjects tab with user and group filter"/>
</div>
</div>
<div class="paragraph">
<p>Select an entry to see binding details on the right, open linked resources, or continue in <strong>Who can → Can subject</strong>.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The error message that appears in the screenshot for the selected user is due to the fact that there are no bindings for this user. This is normal and expected.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_role_access">Role access</h3>
<div class="paragraph">
<p>The <strong>Subjects</strong> tab answers <strong>who has what bound to them?</strong> <strong>Role access</strong> flips the question: <strong>who is bound to this ClusterRole?</strong> That is useful when you audit a built-in or custom ClusterRole (<code>view</code>, <code>edit</code>, <code>cluster-admin</code>, or a role you ship with an operator) and need every ClusterRoleBinding and RoleBinding that references it in one table.</p>
</div>
<div class="paragraph">
<p>Pick a <strong>ClusterRole</strong> from the dropdown. The table lists matching bindings with scope, namespace (for namespaced RoleBindings), role kind, subjects, and <strong>View rules</strong> to expand the ClusterRole policy inline.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/RBAC/images/rbac-overview-role-access.png?width=900px" alt="Role access for ClusterRole cluster-admin"/>
</div>
</div>
<div class="paragraph">
<p>The screenshot shows <code>cluster-admin</code> with 30 bindings — a mix of human users, the <code>cluster-admins</code> group, and OpenShift system groups such as <code>system:openshift:operator:kube-apiserver-operator</code>.</p>
</div>
</div>
<div class="sect2">
<h3 id="_scc_access">SCC access</h3>
<div class="paragraph">
<p>To get a quick overview about SCC and who is on which SCC was always tricky.</p>
</div>
<div class="paragraph">
<p>OpenShift SCCs authorise subjects in two ways:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>direct fields on the SCC object</p>
</li>
<li>
<p>RBAC to <code>use securitycontextconstraints</code>.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>This tab shows every SCC and their configuration.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/RBAC/images/rbac-overview-scc-access.png?width=900px" alt="All security context constraints"/>
</div>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>All SCCs</strong> — every SCC you can list, with priority, privileged/host settings, run-as-user and SELinux strategy, volumes, and direct subject count.</p>
</li>
<li>
<p><strong>Direct authorizations</strong> — users, groups, and service accounts listed on each SCC.</p>
</li>
<li>
<p><strong>RBAC use grants</strong> — ClusterRoleBindings that grant <code>use</code> on SCC resources.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>This tab does not replace a full SCC compliance review, but it saves time when you are tracing why a pod was allowed a privileged context.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_limitations">Limitations</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><strong>Who can</strong> requires the same elevated create permissions as <code>oc adm policy who-can</code>.</p>
</li>
<li>
<p>Large clusters: tables paginate, but initial binding scans can take a moment on first tab open.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_summary">Summary</h2>
<div class="sectionbody">
<div class="paragraph">
<p>RBAC Overview does not replace <code>oc</code> or your GitOps RBAC manifests. It gives operators and auditors a single console entry point for the questions that come up every week — who is admin, what does this namespace grant, what is bound to this service account, who can touch this verb/resource, and which identities sit on sensitive SCCs.</p>
</div>
<div class="paragraph">
<p>The plugin was created with the help of AI (I always want to be open about that), especially the initial layout, some styling elements like dropdowns and buttons and the README …​ which I never want to write.</p>
</div>
<div class="paragraph">
<p>If you try it, feedback and issues are welcome on the <a href="https://github.com/tjungbauer/openshift-console-rbac-overview" rel="noopener" target="_blank">repository</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://github.com/tjungbauer/openshift-console-rbac-overview" rel="noopener" target="_blank">openshift-console-rbac-overview on GitHub</a></p>
</li>
<li>
<p><a href="https://quay.io/repository/tjungbau/openshift-console-rbac-overview?tab=tags" rel="noopener" target="_blank">openshift-console-rbac-overview on Quay</a></p>
</li>
<li>
<p><a href="https://github.com/openshift/console/tree/main/frontend/packages/console-dynamic-plugin-sdk" rel="noopener" target="_blank">OpenShift Console dynamic plugin SDK</a></p>
</li>
<li>
<p><a href="https://docs.openshift.com/container-platform/latest/web_console/dynamic-plugins-overview.html" rel="noopener" target="_blank">OpenShift dynamic plugins documentation</a></p>
</li>
<li>
<p><a href="https://hummingbird-project.io/" rel="noopener" target="_blank">Project Hummingbird</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>Creating an auditd rule to monitor Ansible Automation Platform static secrets</title><link>https://blog.stderr.at/ansible/2026/06/creating-an-auditd-rule-to-monitor-ansible-automation-platform-static-secrets/</link><guid isPermaLink="true">https://blog.stderr.at/ansible/2026/06/creating-an-auditd-rule-to-monitor-ansible-automation-platform-static-secrets/</guid><pubDate>Tue, 09 Jun 2026 00:00:00 +0200</pubDate><dc:creator>Articles by Toni Schmidbauer</dc:creator><category>Ansible</category><category>Security</category><description>How to create a Linux auditd rule to log events if an AAP static secret is accessed.</description><content:encoded><![CDATA[<div class="paragraph">
<p>Ansible Automation Platform (AAP) comes with an elaborate credential
management solution. All credentials within AAP are stored encrypted
in a PostgreSQL database. But the keys used for encrypting database
fields are currently stored on the machine(s) running AAP. In this
blog post, we show we created an auditd rule to get at least some kind
of monitoring if those keys are accessed.</p>
</div>
<div class="sect1">
<h2 id="_ansible_automation_platform_local_secret_key">Ansible Automation Platform local SECRET_KEY</h2>
<div class="sectionbody">
<div class="paragraph">
<p>AAP comes with a
<a href="https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.7/secure-con_controller_how_credentials_work">credential
management solution</a>. Credentials are used to</p>
</div>
<div class="ulist">
<ul>
<li>
<p>access remote machines</p>
</li>
<li>
<p>provide configuration data for automation, like API keys</p>
</li>
<li>
<p>connect AAP to source code repositories and inventories</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>and much more. You can even integrate external credential management
solutions like <a href="https://www.hashicorp.com/products/vault">HashiCorp
Vault</a> or <a href="https://openbao.org/">OpenBao</a>.</p>
</div>
<div class="paragraph">
<p>All credentials stored within AAP are saved as encrypted database
fields in a PostgreSQL database. There is a main key and AAP creates
for every encrypted database field a derived AES-256
encryption key. For more details see the
<a href="https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.7/secure-con_controller_secret_handling#controller-secret-handling-operational-use">documentation</a>.</p>
</div>
<div class="paragraph">
<p>But there is one caveat: the main secret key is stored on the local
file system. There is currently no supported option to integrate
something like a HSM (High Security Module) for storing the main
secret securely.</p>
</div>
<div class="paragraph">
<p>To mitigate this issue we deployed a Linux audit rule that monitors
read/write and attribute changes to the main secret.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configuring_linux_auditd">Configuring Linux auditd</h2>
<div class="sectionbody">
<div class="paragraph">
<p>We use the containerized version of AAP 2.6. In the containerized
version of AAP those secrets are stored as <em>podman</em> secrets as the
user running the AAP containers.</p>
</div>
<div class="paragraph">
<p>To list AAP podman secrets execute</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-terminal hljs" data-lang="terminal">$ podman secret list
ID                         NAME                        DRIVER      CREATED      UPDATED
02a2eb397dc5cedefde6ae411  hub_resource_server         file        2 hours ago  2 hours ago
0dd84dc7b808917c4efb6ea9f  controller_channels         file        2 hours ago  2 hours ago
85fb73ff57729250c019976ed  hub_database_fields         file        2 hours ago  2 hours ago
c482ff7c07f908e443d327293  controller_postgres         file        2 hours ago  2 hours ago
e6750121a8997cce8185072bf  gateway_admin_password      file        2 hours ago  2 hours ago
2731b2d03806f88f35809de66  eda_admin_password          file        2 hours ago  2 hours ago
31ca44577b4c5b61dd3f0a0b6  eda_secret_key              file        2 hours ago  2 hours ago
856473626bad9ff37b1b979d4  eda_resource_server         file        2 hours ago  2 hours ago
b20ec0897fc2b6533544c4441  gateway_redis_url           file        2 hours ago  2 hours ago
1dfdd812847ed4c1c01b194e2  gateway_db_password         file        2 hours ago  2 hours ago
32d04575881dd781be192ef49  eda_db_password             file        2 hours ago  2 hours ago
5102f69350717c15177b80821  hub_secret_key              file        2 hours ago  2 hours ago
d1faf92922182604cfa746318  controller_resource_server  file        2 hours ago  2 hours ago
d29f0d8c2fc709655dd918f2c  postgresql_admin_password   file        2 hours ago  2 hours ago
1b3ee24261bdff50d2c70e3f0  gateway_secret_key          file        2 hours ago  2 hours ago
ae6c9e78e91dea180d22db6ee  hub_settings                file        2 hours ago  2 hours ago
b348d89bfb7d3b18f33a67d07  controller_secret_key       file        2 hours ago  2 hours ago <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>the controller secret key</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>If we want to know where those secrets are stored we can execute</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-terminal hljs" data-lang="terminal">$ podman secret inspect controller_secret_key
[
    {
        &#34;ID&#34;: &#34;b348d89bfb7d3b18f33a67d07&#34;,
        &#34;CreatedAt&#34;: &#34;2026-06-09T10:57:28.278138715Z&#34;,
        &#34;UpdatedAt&#34;: &#34;2026-06-09T10:57:28.278138715Z&#34;,
        &#34;Spec&#34;: {
            &#34;Name&#34;: &#34;controller_secret_key&#34;,
            &#34;Driver&#34;: {
                &#34;Name&#34;: &#34;file&#34;,
                &#34;Options&#34;: {
                    &#34;path&#34;: &#34;/home/admin/.local/share/containers/storage/secrets/filedriver&#34;
                }
            },
            &#34;Labels&#34;: {}
        }
    }
]</code></pre>
</div>
</div>
<div class="paragraph">
<p>Let’s see what’s in the filedriver directory:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-terminal hljs" data-lang="terminal">$ ls /home/admin/.local/share/containers/storage/secrets/filedriver
secretsdata.json  secretsdata.lock<i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>we are mainly interested in the <em>secretsdata.json</em> file</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>So the <em>secretsdata.json</em> file stores all podman secrets that are
using the <em>filedriver</em>. For more information see the section
<a href="https://docs.podman.io/en/latest/markdown/podman-secret-create.1.html#secret-drivers">Secret
Drivers</a> in the podman-secrets-create(1) manpage.</p>
</div>
<div class="paragraph">
<p>Let’s create a Linux auditd rule to monitor access to this file. As we
are using Red Hat Enterprise Linux 10 a more detailed introduction to
the Linux audit system is available
<a href="https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/risk_reduction_and_recovery_operations/auditing-the-system">here</a>.</p>
</div>
<div class="paragraph">
<p>We created the file <em>/etc/audit/rules.d/aap_secrets.rules</em> with the following content:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-terminal hljs" data-lang="terminal">-w /home/admin/.local/share/containers/storage/secrets/filedriver/secretsdata.json -p rwa -k aap_secrets <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>-p rwa means monitor read/write/attribute changes, -k tells the audit system log events with an additional key &#34;aap_secrets&#34;</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>To activate the rule we need to load the audit rule via:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-terminal hljs" data-lang="terminal"># auditctl -R /etc/audit/rules.d/aap_secrets.rules</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can list loaded audit rules via</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-terminal hljs" data-lang="terminal"># auditctl -l
-w /home/admin/.local/share/containers/storage/secrets/filedriver/secretsdata.json -p rwa -k aap_secrets</code></pre>
</div>
</div>
<div class="paragraph">
<p>As a test we can cat the secrets file and check if auditd logged an event:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-terminal hljs" data-lang="terminal"># cat /home/admin/.local/share/containers/storage/secrets/filedriver/secretsdata.json
...
# grep aap_secrets  /var/log/audit/audit.log
type=SYSCALL msg=audit(1781009319.993:204): arch=c000003e syscall=257 success=yes exit=3 a0=ffffff9c a1=7ffc5276b65c a2=0 a3=0 items=1 ppid=6186 pid=6695 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts2 ses=3 comm=&#34;cat&#34; exe=&#34;/usr/bin/cat&#34; subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=&#34;aap_secrets&#34;ARCH=x86_64 SYSCALL=openat AUID=&#34;admin&#34; UID=&#34;root&#34; GID=&#34;root&#34; EUID=&#34;root&#34; SUID=&#34;root&#34; FSUID=&#34;root&#34; EGID=&#34;root&#34; SGID=&#34;root&#34; FSGID=&#34;root&#34; <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>We can see that the <em>cat</em> command (comm=cat) was used by the root user to display the file contents</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_summary">Summary</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this blog post we demonstrated how to configure the Linux audit
system to log events if the AAP database secret key is accessed. The
audit subsystem can also monitor system calls, for a detailed
introduction see
<a href="https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/risk_reduction_and_recovery_operations/auditing-the-system#audit-system-architecture">Audit system architecture</a>.</p>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - Secrets Engines PKI - Part 9</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-03-26-openbao-part-9-secrets-engines-pki/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-03-26-openbao-part-9-secrets-engines-pki/</guid><pubDate>Thu, 26 Mar 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Deep dive into OpenBao secrets engines: PKI for certificates</description><content:encoded><![CDATA[<div class="paragraph">
<p>Secrets engines are one of the most important concepts in OpenBao. <a href="/openshift-platform/security/secrets-management/openbao/2026-03-25-openbao-part-8-secrets-engines-kv/">Part 8</a> covered the KV secrets engine; this article covers the <strong>PKI</strong> secrets engine and its integration with <strong>cert-manager</strong> on Kubernetes and OpenShift.</p>
</div>
<div class="sect1">
<h2 id="_quick_navigation">Quick Navigation</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Navigate directly to the main sections of this article:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="#sect-pki">PKI secrets engine</a></p>
</li>
<li>
<p><a href="#sect-cert-manager">Integration with cert-manager</a></p>
</li>
</ul>
</div>
<hr/>
</div>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="/openshift-platform/security/secrets-management/openbao/2026-03-25-openbao-part-8-secrets-engines-kv/">Part 8</a> of this series explained the basics of secrets engines and the KV secrets engine. This article focuses on the PKI secrets engine and on integrating OpenBao with <strong>cert-manager</strong>.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
As a reminder: to <strong>log in</strong> to the OpenBao CLI, use the following (assuming HTTPS and a CA certificate available locally):
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">export BAO_ADDR=&#39;https://127.0.0.1:8200&#39;
export BAO_CACERT=&#34;$PWD/openbao-ca.crt&#34;
bao login</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sect-pki">PKI Secrets Engine</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The PKI engine dynamically generates X.509 certificates, acting as a <strong>Certificate Authority (CA)</strong>. You can obtain a certificate without manually generating a private key and CSR on the client: OpenBao provisions the key material and signed certificate according to the role.</p>
</div>
<div class="paragraph">
<p>The time to live (TTL) of each generated certificate can be kept short to reduce reliance on revocation. It is possible to store the certificates in memory during the startup of an application and discard them when the application shuts down. This way, a certificate is only valid during the application runtime, is kept in memory and is never written to disk.</p>
</div>
<div class="sect2">
<h3 id="_setting_up_pki_secrets_engine_root_ca">Setting Up PKI Secrets Engine (Root CA)</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Before we can use the PKI secrets engine, we need to enable and configure it. To enable it, we can simply use the following command:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao secrets enable -path=pki pki</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will enable the PKI secrets engine at the path <strong>pki/</strong>. If the path parameter is not provided, the engine will use the name of the engine as path.</p>
</div>
<div class="paragraph">
<p>The default value of the TTL is 30 days. To increase the maximum lease time for certificates issued under this mount, use <strong><code>-max-lease-ttl=87600h</code></strong> (or another duration).</p>
</div>
</li>
</ol>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<em>Note that individual roles can restrict this value to be shorter on a per-certificate basis. This just configures the global maximum for this secrets engine.</em> Source: <a href="https://openbao.org/docs/secrets/pki/setup/" rel="noopener" target="_blank">PKI secrets engine - setup and usage</a>
</td>
</tr>
</tbody></table>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Next we need to provide a CA certificate and a private key. OpenBao can either generate its own self-signed root certificate, or can use an existing one. Using an existing one is recommended for production environments. This is managed outside of OpenBao and OpenBao is provided with a signed intermediate CA.</p>
<div class="paragraph">
<p>We can simply generate a self-signed root certificate by using the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao write pki/root/generate/internal \
  common_name=&#34;Example Root CA&#34; \ <i class="conum" data-value="1"></i><b>(1)</b>
  issuer_name=&#34;root-ca&#34; \ <i class="conum" data-value="2"></i><b>(2)</b>
  ttl=8760h \ <i class="conum" data-value="3"></i><b>(3)</b>
  key_bits=4096 \ <i class="conum" data-value="4"></i><b>(4)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Common name of the root certificate</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Issuer name of the root certificate</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Time to live of the root certificate, here 8760 hours (365 days)</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Key bits of the root certificate, here 4096 bits (default is 2048 bits)
<div class="paragraph">
<p>The response will look something like:</p>
</div>
<div class="listingblock nocopy">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Key              Value
---              -----
certificate      -----BEGIN CERTIFICATE-----...
expiration       1536807433
issuing_ca       -----BEGIN CERTIFICATE-----...
serial_number    7c:f1:fb:2c:6e:4d:99:0e:82:1b:08:0a:81:ed:61:3e:1d:fa:f5:29</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The certificate key is stored in OpenBao. The returned certificates are purely informational.
</td>
</tr>
</tbody></table>
</div></td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Set URL configuration</p>
<div class="paragraph">
<p>The location of the Certificate Revocation List (CRL) and the issuing certificate are stored in the configuration of the PKI secrets engine and must be updated manually.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Configure CA and CRL URLs
bao write pki/config/urls \
  issuing_certificates=&#34;https://openbao.example.com/v1/pki/ca&#34; \
  crl_distribution_points=&#34;https://openbao.example.com/v1/pki/crl&#34;</code></pre>
</div>
</div>
</li>
<li>
<p>Configure a Role</p>
<div class="paragraph">
<p>Now we need to define a role for the certificates. Roles define the allowed domains and the maximum time to live for the certificates. The following example creates a role for server certificates. It allows us to issue certificates for the domains <code>example.com</code> and <code>internal.example.com</code> with a maximum time to live of 720 hours (30 days) and a key size of 2048 bits.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao write pki/roles/server-cert \
  allowed_domains=&#34;example.com,internal.example.com&#34; \ <i class="conum" data-value="1"></i><b>(1)</b>
  allow_subdomains=true \ <i class="conum" data-value="2"></i><b>(2)</b>
  max_ttl=720h \
  key_bits=2048 \ <i class="conum" data-value="3"></i><b>(3)</b>
  key_type=rsa \ <i class="conum" data-value="4"></i><b>(4)</b>
  require_cn=false \
  allow_any_name=false</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Allowed domains</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Allow subdomains</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Key size</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Key type, typically rsa or ec (elliptic curve)</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Issuing Certificates</p>
<div class="paragraph">
<p>OpenBao is now ready to issue certificates. We will use the <code>issue</code> endpoint to request a new certificate.
The following example requests a new certificate for the domain <code>myapp.example.com</code> and the subdomain <code>myapp.internal.example.com</code> with a maximum time to live of 168 hours (7 days) and a key size of 2048 bits.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao write pki/issue/server-cert \
  common_name=&#34;myapp.example.com&#34; \
  alt_names=&#34;myapp.internal.example.com&#34; \
  ttl=168h \</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will return the full certificate chain including the root CA certificate and the key.
For better readability, the output was shortened to show the certificate only:</p>
</div>
<div class="listingblock nocopy">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Key                 Value
---                 -----
certificate         -----BEGIN CERTIFICATE-----
MIIE7zCCAtegAwIBAgIUH0eTVpXCP7iu0Y75dWAvjktbyxcwDQYJKoZIhvcNAQEL
BQAwGjEYMBYGA1UEAxMPRXhhbXBsZSBSb290IENBMB4XDTI2MDMyMjA1MjEyNVoX
DTI2MDMyOTA1MjE1NFowHDEaMBgGA1UEAxMRbXlhcHAuZXhhbXBsZS5jb20wggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDliY0K3qb8TwNBXOHdfBygs5+Y
Pwh83vtS0Nph6ZsPdI9JTuvI6AbzEz6M283aY7OeJ3m3G2fRwt7ZdgsAcyt+jnL8
Izx/MS/4ztsdZJ/wxs3M42/iFehSofqihgorY1+SGaTdveCFg9H7Egjn1eJFnGB/
iqANzxg5NohE4gf8zpAKDjl4CIPDSmNJX2xQ+3wXJgx1eKeVOeB0jFnMSYskS0hD
qwM+QyYRKodc/akI6Xu7OqWQLMW7qmNS+6TBHsGOopve9EP6ym65Jss6de4X9zIP
BYeWQ0gvG18i22eJrkISRWlO2uw+Fbho0tBhqfRfjsVpxrUrTKwIgxg+F0+5AgMB
AAGjggEpMIIBJTAOBgNVHQ8BAf8EBAMCA6gwHQYDVR0lBBYwFAYIKwYBBQUHAwEG
CCsGAQUFBwMCMB0GA1UdDgQWBBRbFm9oqRl//tc+Z0ert4DKp9KjkDAfBgNVHSME
GDAWgBSL03nIIcEY+IAz/1g2q5NBbufx9DBBBggrBgEFBQcBAQQ1MDMwMQYIKwYB
BQUHMAKGJWh0dHBzOi8vb3BlbmJhby5leGFtcGxlLmNvbS92MS9wa2kvY2EwOAYD
VR0RBDEwL4IRbXlhcHAuZXhhbXBsZS5jb22CGm15YXBwLmludGVybmFsLmV4YW1w
bGUuY29tMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHBzOi8vb3BlbmJhby5leGFtcGxl
LmNvbS92MS9wa2kvY3JsMA0GCSqGSIb3DQEBCwUAA4ICAQBUoLwWgpTaodRKpL3c
zp/yPgHNagZA8SQRLqKttywbHzfPNUSsC56XqfZnOHaq/gobNKrmirUAHPnXRUjO
Jd2+wXBO9aKqAhiy5is2ueNRo+C8IdPQpFNQ+5MW+G4FXJqSkvDUlT47mAoRkKUJ
nsjoV/xzHYKgw/YF7QZtmL8moM9W9Bhg3dB6KEaUvscpNn/9USfPquVLXOuQ/8Bs
6zQGijJUhb5gpRgGjmJhs0Oo/MkABxBUq2jFmvGWP0NklcJO7smtetx/RSrtyFZ0
X7zgMlD1yUy4DaHX13LhszAfercTFNodV/mAfEaJUrW+U9I97MzVg8QJvn9/AsaM
mWjfKHczhd9AzupOlogX8L3cdZxx9hkdD4NcR8tRb4QR5sOqzoBN7NfNpQ699b0F
kxESrHIysqBcx4dYjXLFsUqzRGm2sGZ4j1N8w1OZY/s0kfsG7RXpXJjwtQ2RwPo1
iSjbJ/VLjji2pz5BtVRtHiXnkoVtSD8QBpjCYqyHekXUArJCVkaDPzkB2MWNZXpk
2koi2fYa0U4x4ITqDsKeMpLvGAl2vqkp20lphXXqRwaAdNuEFd69YZ6qXzw/6GdI
TC/Ki7zApSvO0kJvMs9NILcHgDjpndCA/sMpG9iv4wFMpgYet9wc+dzPMXnHcj4o
PGbyb/WJomcxQMDuV1x1S1X2iA==
-----END CERTIFICATE-----
expiration          1774761714
issuing_ca          -----BEGIN CERTIFICATE-----
MIIFJTCCAw2gAwIBAgIUJde0eccC1TpbufxVsUBhZhq9hWwwDQYJKoZIhvcNAQEL
BQAwGjEYMBYGA1UEAxMPRXhhbXBsZSBSb290IENBMB4XDTI2MDMyMjA0NDI1OVoX
DTI2MDQyMzA0NDMyOVowGjEYMBYGA1UEAxMPRXhhbXBsZSBSb290IENBMIICIjAN
BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA1XGanJKZZYySc9+WCXuGp9MLMo/O
MCRAR0u+BQbmxaSBcFLsxfNdkB8Jcunx7RnaGZIJwYXNIy+tNejqwQfiah7pTwJq
SYnXcYqZAETJUFvdYygjs4MCeaebvogmBQcZRzxJNNPzUblYpVOhmSGLvZZ7Vs5F
zY9wsKUEc3c3fMhwbxe/n/KQzvT/VzXSrLOw54LTsG7GNnUIhkuKwNqkhXuVItDy
ps+3z7RG/hOAWN9vktqLybi/E/uTmUqpsMrHSg7EMjqJ2jP8FMyH9EARLRL9gUG3
XFFNhFzjjDKjFrMsTUyVr+9tp4ucCZaakP9ZhjN9R/6FCXXR1K/XTVhTgYkawPHd
+PJaXn2T7NOie+tChiZx5Sii2XZtDm7WMFfwb4xhOBV67pWCSWSjkKl/xIDSrdRj
qLtzVfP/wiSL4sL9fy7Pya2OBtF2d/bdXXQ54JbbRlw3eRP+y+ej63UD+OP602EE
bbzrGB+B7ozwnfCmNNBnF23GgVYtJPWfDvgjXicprvbgjpmQAjeFohA8IIC322w5
sFsYuDL46KEs/KREoHjQNo1pxHKnmITU5GIMmWWoPyidTZuNNc4qWM6cH5RAbJup
IBaJWcWAr4eZ8p7pZd1dMkWEld4tieLdoJv2ENK77rDhwrq8kz66Xw9/xDJ/Nuio
sw5sd3py6Ayz+ekCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
MAMBAf8wHQYDVR0OBBYEFIvTecghwRj4gDP/WDark0Fu5/H0MB8GA1UdIwQYMBaA
FIvTecghwRj4gDP/WDark0Fu5/H0MA0GCSqGSIb3DQEBCwUAA4ICAQAJuRiReD46
H85vhc1wzg7JUy6k+q5aUA9iKOupGyYBtkvzniQzhouZGEP47AcWkbPNGqo/3yl+
SCUItkBfPjunBmzcAhhZqyxJJ1q/SgY21DBf3W7WB0yzPx+saCwEi74rf44HbslY
Gp9W9pv0NFDT1+lQGerp978ErGQZh2M8rrGFwhcHmx71/umZ9ju6xyaGRaoHba+Y
8bxhR11j/Zx/UGRQBpjdAe2+VuAHDGpHjd9ieQ45YgoyJYkjBbecXJFttcVnShwu
7rxu8HNV3fMjoa4M6TDaY4z8KDgzHChzQSRB085TJIZzcG+/4zpJredzLe+jEq0P
RAuFEx4FjpRqYQu08HUmepO0Vd8a2ut7WyIBOC5b+pM+55LaGDfDF6rt8H7g6G84
w/RYFP/w/elxp3T1cFgDXsuZ60mfK6SX5ZbH3ZGPN0+xF/VahncUWKSfxSaSjzRI
Eml/Aac22kgtbbtxf8Bn4tgtY30sxqQRVnldHKi02FxS+DNg3SZB1hIpw6myyUo0
XH/ZtyumDLkcCvKzz/KvQGDOWDBmaPfPOPfMgiFXryB+YFMfy75Bhm0+aE+GM8fP
sextO8kawYI62aCHiOClkm2qIBiFtbsNG2HMTL4HKaNDOh9vxesPD5EteVzxTvg4
Oyk8YPB4kGtloH569v2Fj2U24D6KRyqxvQ==
-----END CERTIFICATE-----
not_before          1774156885</code></pre>
</div>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>That is it. We have just created our first certificate.</p>
</div>
</div>
<div class="sect2">
<h3 id="_setting_up_an_intermediate_ca">Setting Up an Intermediate CA</h3>
<div class="paragraph">
<p>The test above demonstrated the usage of the PKI secrets engine to issue a certificate. However, the certificate was issued by the root CA. This is not practical or recommended for production environments. Instead, we should use an intermediate CA. The setup is very similar to the root CA, but with a few key differences: Instead of directly signing with the root CA, we will create a CSR (Certificate Signing Request) and sign it with the root CA. This can then be used to issue certificates with the intermediate CA.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>First we enable the PKI secrets engine for the intermediate CA and tune it a little bit.</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Enable PKI engine for intermediate CA
bao secrets enable -path=pki_int pki

# Configure maximum lease time
bao secrets tune -max-lease-ttl=43800h pki_int</code></pre>
</div>
</div>
<div class="paragraph">
<p>We set the maximum TTL of the intermediate CA to 43800 hours (5 years). It should be equal to or less than the root CA.</p>
</div>
</li>
<li>
<p>Generate a CSR (Certificate Signing Request)</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Generate intermediate CSR
bao write -format=json pki_int/intermediate/generate/internal \
  common_name=&#34;Example Intermediate CA&#34; \
  issuer_name=&#34;intermediate-ca&#34; \
  key_bits=4096 \
  | jq -r &#39;.data.csr&#39; &gt; pki_int.csr</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will create the CSR and store it at <code>pki_int.csr</code>, which can be signed by the root CA and then used to issue certificates with the intermediate CA. As an example, the following CSR is generated:</p>
</div>
<div class="listingblock nocopy">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">-----BEGIN CERTIFICATE REQUEST-----
MIIEZzCCAk8CAQAwIjEgMB4GA1UEAxMXRXhhbXBsZSBJbnRlcm1lZGlhdGUgQ0Ew
ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/dLEhNgiBeMiCIwrAq9S8
9m7SjqH59JaYPTBEpdAKCs1gsEBNROOaI+zftVaVJEGw/yi1gFRijTbjvBAbwAbc
YDV5VYLXqaoetkSE2hhIbsX92xwwch++J3BkGrgLt5y6uK0gLfODLp0hbxTdGhO0
RvIBKa2X1ctSLgEscgAr8PrlIfDlzahcxDgxpQQsN/1CASW2X5i/DEj160rbODzG
v10FEsVEcOLaJEee9qQ9yvwySiPLfH7KjEFV8qlQd/uY4gnGE8WW6nHhZEW+0Lsj
h1iO0Y4GA2Yw60FtTxsGAQlTCE3xCZTajInwc0XgDIYBtj/PEJhQUNU7mamchqng
jg+MJb9jzoqYmTw7dLvxTFTobu8s8y+7mjKQYevg7+FRNWQ467PmxGqaD++HQEw9
Ef1kaQ1Aw0L5ZuTZ2QaEzbJe2Rka5slHAja6rHxX2rNk6YkdbE2MfCUPqSVpqHBp
I+ptF8b73EgjgKINpWRXKvqH4QX2f6zUpVbr+5AikbS9TmPLQRqHHKtO0uDFEQzn
38w9PntU/N29BrYhzkeCzdGNFZTcL+Yijnp7fKrHl+iYasIUQD+MGWR3sUqaOODc
JmKvfl8H9UNulV4I7JXn0MBUUIT3uhTtsJ4Q62xr9pltZH5ijgR8Zqrl/q2kh+jf
pCoA7CpUKZXSiSou0zG3lwIDAQABoAAwDQYJKoZIhvcNAQELBQADggIBAGBAEsLK
QdeEejkFxP06xmEKypvGcy4GGw2g/ODp9lZQeNyaObwiABDjdJfj7CBgFGsPcMbq
DAFq/Kt/f+BmQwRulQf6ers9OIC8+4HAgHF9olgYJSn+lsrNXT9M4m02orIAodey
+xFxIcuUCHygQiXMIzb4QLzyvzW0/CqdsCysfbgHNN8P5deOR2/PseirYZKYFRQI
/ZxQrjB2Uj9gBND1Q5ew97Gm+mVvhqnb1T/Y1aIS+iEdRXADjxIvdweOPBXj3pDY
h8P+NgrP49pAKEvPuRFgfWMrkMrg4dQYPtVElcjN5XFMBXY2wZDketTu0rqroSlk
tcEhcwHdFFi+ILq6UHBDtMhZBkFtJG/82FgjcnR1G+1UOwKGSFOJ0HGiZpYGOXtc
hJM07eSZ0JzFCrg+2/geHM5c8X33yShe+4DRc3fi2KpsQbOAvvtH7Kb6AYwNu953
yBoOSpzI3Q9XjiFaAl1U8JDIr5DRfHGkUt1ozg4nf3ZHjPQC/NQNTq4XNEnjWgnJ
kiC+Ss4YZ6QnfvQU3aIwU97WKG6PIb5x9v+5mBwQe6AgDn2T1mmfyumsFfu/7aTB
87BUt3lWesvuW67JvE95LKs8NukNTW8FETR/x3Kn8TSYMulvXJsv7yb8g+Mm8k5w
f+LiteH/fEMVMYsoIdNL6MYJhiZNxStFDC2V
-----END CERTIFICATE REQUEST-----</code></pre>
</div>
</div>
</li>
<li>
<p>Sign the CSR with the root CA</p>
<div class="paragraph">
<p>The CSR must now be signed using the root CA that was generated previously. Use:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao write -format=json pki/root/sign-intermediate \
  csr=@pki_int.csr \ <i class="conum" data-value="1"></i><b>(1)</b>
  format=pem_bundle \
  ttl=43800h \
  | jq -r &#39;.data.certificate&#39; &gt; cert_bundle.pem <i class="conum" data-value="2"></i><b>(2)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The CSR file created in the previous step</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The signed certificate is stored in the file <code>cert_bundle.pem</code>
<div class="paragraph">
<p>This will sign the CSR with the root CA and store the signed certificate at <code>cert_bundle.pem</code>.</p>
</div></td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Configure the set-signed certificate</p>
<div class="paragraph">
<p>We need to configure the intermediate CA with the signed certificate, so we can issue new certificates:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao write pki_int/intermediate/set-signed \
  certificate=@cert_bundle.pem</code></pre>
</div>
</div>
</li>
<li>
<p>Creating Certificate Roles</p>
<div class="paragraph">
<p>Before we can issue certificates, we need to create roles. The following defines a role for server certificates and a role for client certificates, including allowed domains, maximum TTL, and key type.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Create a role for issuing server certificates
bao write pki_int/roles/server-cert \
  allowed_domains=&#34;example.com,internal.example.com&#34; \ <i class="conum" data-value="1"></i><b>(1)</b>
  allow_subdomains=true \ <i class="conum" data-value="2"></i><b>(2)</b>
  max_ttl=720h \
  key_bits=2048 \ <i class="conum" data-value="3"></i><b>(3)</b>
  key_type=rsa \
  require_cn=false \
  allow_any_name=false

# Create a role for client certificates
bao write pki_int/roles/client-cert \
  allowed_domains=&#34;example.com&#34; \ <i class="conum" data-value="1"></i><b>(1)</b>
  allow_subdomains=true \
  max_ttl=168h \
  key_usage=&#34;DigitalSignature,KeyEncipherment&#34; \
  ext_key_usage=&#34;ClientAuth&#34;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The allowed domains, comma separated list</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Allow subdomains, true or false</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The key bits, 2048 or 4096
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Check out the official documentation for more details of possible options: <a href="https://openbao.org/docs/" rel="noopener" target="_blank">https://openbao.org/docs/</a>
</td>
</tr>
</tbody></table>
</div></td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Issuing Certificates</p>
<div class="paragraph">
<p>Finally we can issue certificates. The example below issues a server certificate via the intermediate mount (and the article’s role setup supports a separate client role if you need mutual TLS).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Issue a server certificate
bao write pki_int/issue/server-cert \
  common_name=&#34;myapp.example.com&#34; \ <i class="conum" data-value="1"></i><b>(1)</b>
  alt_names=&#34;myapp.internal.example.com&#34; \ <i class="conum" data-value="2"></i><b>(2)</b>
  ttl=168h</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The common name, the subdomain under example.com is allowed.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The alternative names
<div class="paragraph">
<p>This will print a large amount of detail. Typical fields include:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>certificate</code></p>
</li>
<li>
<p><code>issuing_ca</code></p>
</li>
<li>
<p><code>private_key</code></p>
</li>
<li>
<p><code>serial_number</code></p>
</li>
</ul>
</div></td>
</tr>
</tbody></table>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>The output contains the full chain (intermediate and root CA), the leaf certificate, and the private key, which you can use to configure TLS in an application.</p>
</div>
<div class="paragraph">
<p>+
TIP: It can also be printed out in JSON format which is easier to process later.</p>
</div>
<div class="paragraph">
<p>+
The following example creates the JSON file with all the components.</p>
</div>
<div class="paragraph">
<p>+</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao write -format=json pki_int/issue/server-cert \
  common_name=&#34;api.example.com&#34; \
  ttl=168h &gt; api-cert.json</code></pre>
</div>
</div>
<div class="paragraph">
<p>+
This can then be extracted to the individual components using the <code>jq</code> command.</p>
</div>
<div class="paragraph">
<p>+</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">cat /tmp/api-cert.json | jq -r &#39;.data.certificate&#39;
cat /tmp/api-cert.json | jq -r &#39;.data.private_key&#39;
cat /tmp/api-cert.json | jq -r &#39;.data.ca_chain[]&#39;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="pki-policies">PKI Policies</h3>
<div class="paragraph">
<p>Every OpenBao request is checked against the token’s policies; without an explicit allow, paths are <strong>denied</strong>.
PKI is split into several API paths (<code>issue</code>, <code>sign</code>, <code>ca</code>, <code>crl</code>, …), so you grant only what each client needs.</p>
</div>
<div class="paragraph">
<p>For example: operators using <code>pki_int/issue/…​</code> need the <strong>issue</strong> path; cert-manager sending a CSR needs the <strong>sign</strong> path; workloads or validators that fetch trust material need <strong>read</strong> on the CA (and often the CRL) paths etc.</p>
</div>
<div class="paragraph">
<p>The example below is a single policy you can attach to a role or token; split into narrower policies in production if different actors should not share the same privileges.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">set -e

cat &lt;&lt;&#39;EOF&#39; | bao policy write pki-int-workload -
# Allow issuing certificates with the server-cert role (CLI / API issue endpoint)
path &#34;pki_int/issue/server-cert&#34; {
  capabilities = [&#34;create&#34;, &#34;update&#34;]
}

# Allow cert-manager (Vault issuer) to sign CSRs via the sign endpoint for the same role
path &#34;pki_int/sign/server-cert&#34; {
  capabilities = [&#34;create&#34;, &#34;update&#34;]
}

# Allow reading CA certificate
path &#34;pki_int/ca/pem&#34; {
  capabilities = [&#34;read&#34;]
}

# Allow reading CRL
path &#34;pki_int/crl/pem&#34; {
  capabilities = [&#34;read&#34;]
}
EOF

bao policy read pki-int-workload</code></pre>
</div>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sect-cert-manager">Integration with cert-manager</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://cert-manager.io/" rel="noopener" target="_blank">cert-manager</a> requests TLS certificates inside Kubernetes and stores them in Secrets.
It includes a <strong>Vault</strong> issuer that talks to HashiCorp Vault’s HTTP API; OpenBao exposes the same API for PKI and auth, so you can point that issuer at OpenBao instead of Vault.</p>
</div>
<div class="paragraph">
<p>cert-manager generates a private key and a CSR in the cluster, then calls the PKI <strong>sign</strong> endpoint for your role (not the <strong>issue</strong> endpoint you used from the CLI earlier).
The path in the issuer must therefore follow <code>mount/sign/role-name</code>, for example <code>pki_int/sign/server-cert</code>, matching the intermediate mount and role from this article.</p>
</div>
<div class="paragraph">
<p>Before the <code>ClusterIssuer</code> can log in to OpenBao, you need <strong>Kubernetes auth</strong> enabled, a <strong>policy</strong> that allows signing on <code>pki_int</code> (see <a href="#pki-policies">PKI policies</a>), and a <strong>role</strong> that binds the cert-manager controller’s service account to that policy.
<a href="/openshift-platform/security/secrets-management/openbao/2026-03-09-openbao-part-7-authentication-methods/">Part 7 of this series</a> walks through Kubernetes authentication in detail; the commands below are a minimal summary for cert-manager.</p>
</div>
<div class="sect2">
<h3 id="_enable_the_kubernetes_auth_method">Enable the Kubernetes auth method</h3>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Skip this step if <code>kubernetes</code> is already listed under <code>bao auth list</code>.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao auth enable --description=&#34;Kubernetes/OpenShift service account auth&#34; kubernetes</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_configure_the_kubernetes_auth_method">Configure the Kubernetes auth method</h3>
<div class="paragraph">
<p>OpenBao’s server validates incoming service-account JWTs by calling the Kubernetes TokenReview API.
If OpenBao runs <strong>inside</strong> the cluster (the setup assumed here), configure <code>auth/kubernetes</code> with:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong><code>kubernetes_host</code></strong> — API URL reachable from the OpenBao pods (typically <code><a class="bare" href="https://kubernetes.default.svc:443">https://kubernetes.default.svc:443</a></code>).</p>
</li>
<li>
<p><strong><code>kubernetes_ca_cert</code></strong> — PEM of the cluster CA that signs the API server certificate (same material as in the service-account token Secret).</p>
</li>
<li>
<p><strong><code>token_reviewer_jwt</code></strong> — long-lived JWT for a dedicated service account that may create TokenReview objects (via <code>system:auth-delegator</code>).</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>If OpenBao runs <strong>outside</strong> the cluster, use your public API URL for <code>kubernetes_host</code> (for example <code>$(oc whoami --show-server)</code>), the same CA and reviewer JWT extracted from the cluster, and ensure the OpenBao process can reach that URL on the network.</p>
</div>
<div class="sect3">
<h4 id="_in_cluster_example_reviewer_service_account_and_secret">In-cluster example: reviewer service account and Secret</h4>
<div class="paragraph">
<p>Create a service account in the OpenBao namespace (here openbao), bind <strong>system:auth-delegator</strong>, and request a <strong>long-lived token</strong> Secret (required from Kubernetes 1.24 onward unless you use another token source).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: openbao-kube-auth
  namespace: openbao <i class="conum" data-value="1"></i><b>(1)</b>
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: openbao-kube-auth-delegator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:auth-delegator <i class="conum" data-value="2"></i><b>(2)</b>
subjects:
  - kind: ServiceAccount
    name: openbao-kube-auth
    namespace: openbao
---
apiVersion: v1
kind: Secret
metadata:
  name: openbao-kube-auth-token
  namespace: openbao
  annotations:
    kubernetes.io/service-account.name: openbao-kube-auth
type: kubernetes.io/service-account-token <i class="conum" data-value="3"></i><b>(3)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The namespace of the OpenBao service account</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The name of the ClusterRole that binds the service account to the system:auth-delegator role</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The type of the Secret, which is a long-lived token Secret</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Save the YAML manifest to a file (for example openbao-kube-auth.yaml), apply it, then wait until the Secret contains a token (the control plane fills <code>data.token</code>—often within a few seconds).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc apply -n openbao -f openbao-kube-auth.yaml

until oc get secret openbao-kube-auth-token -n openbao -o jsonpath=&#39;{.data.token}&#39; | grep -q .
do
  sleep 2
done</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
You can manage the reviewer service account, <code>ClusterRoleBinding</code>, and token Secret through GitOps so the configuration stays reproducible.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect3">
<h4 id="_configure_authkubernetesconfig">Configure auth/kubernetes/config</h4>
<div class="paragraph">
<p>Dump the reviewer JWT and CA to files and configure the Kubernetes auth backend.
Use the <strong>in-cluster</strong> API URL so OpenBao pods reach the Kubernetes API without relying on the external load balancer.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">TMP=$(mktemp -d) <i class="conum" data-value="1"></i><b>(1)</b>
trap &#39;rm -rf &#34;$TMP&#34;&#39; EXIT

oc get secret openbao-kube-auth-token -n openbao -o jsonpath=&#39;{.data.token}&#39; | base64 -d &gt; &#34;$TMP/reviewer.jwt&#34; <i class="conum" data-value="2"></i><b>(2)</b>
oc get secret openbao-kube-auth-token -n openbao -o jsonpath=&#39;{.data.ca\.crt}&#39; | base64 -d &gt; &#34;$TMP/k8s-ca.crt&#34; <i class="conum" data-value="3"></i><b>(3)</b>

bao write auth/kubernetes/config \ <i class="conum" data-value="4"></i><b>(4)</b>
  kubernetes_host=&#34;https://kubernetes.default.svc:443&#34; \
  kubernetes_ca_cert=@&#34;$TMP/k8s-ca.crt&#34; \
  token_reviewer_jwt=@&#34;$TMP/reviewer.jwt&#34;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Create a temporary directory to store the reviewer JWT and CA and remove it after the script exits</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Get the reviewer JWT from the Secret</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Get the CA from the Secret</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Write the configuration to the auth/kubernetes/config path using the internal API URL of the Kubernetes cluster.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock tip">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
On plain Kubernetes, replace <code>oc</code> with <code>kubectl</code> and the same Secret paths.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If logins fail after cluster upgrades or with projected service-account tokens, check whether you must set <code>issuer</code> or related options; see <a href="https://openbao.org/docs/auth/kubernetes/" rel="noopener" target="_blank">OpenBao Kubernetes auth</a> and <a href="/openshift-platform/security/secrets-management/openbao/2026-03-09-openbao-part-7-authentication-methods/">Part 7</a>.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>To inspect the stored Kubernetes auth backend configuration:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao read auth/kubernetes/config</code></pre>
</div>
</div>
<div class="paragraph">
<p>You should see <code>kubernetes_host</code> and <code>kubernetes_ca_cert</code>; <code>token_reviewer_jwt</code> is often omitted or redacted on read.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_policy_and_role_for_cert_manager">Policy and role for cert-manager</h3>
<div class="paragraph">
<p>Attach a policy (here <code>cert-manager-pki</code>) that matches the PKI paths cert-manager uses—aligned with <a href="#pki-policies">PKI policies</a>—then map the controller’s service account to that policy.</p>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Adjust <code>bound_service_account_names</code> and <code>bound_service_account_namespaces</code> if your cert-manager installation does not use the <code>cert-manager</code> service account in the <code>cert-manager</code> namespace.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao policy write cert-manager-pki - &lt;&lt;&#39;EOF&#39;
path &#34;pki_int/sign/server-cert&#34; {
  capabilities = [&#34;create&#34;, &#34;update&#34;]
}

path &#34;pki_int/ca/pem&#34; {
  capabilities = [&#34;read&#34;]
}

path &#34;pki_int/crl/pem&#34; {
  capabilities = [&#34;read&#34;]
}

path &#34;auth/token/renew-self&#34; {
  capabilities = [&#34;update&#34;]
}
EOF

bao write auth/kubernetes/role/cert-manager \
  bound_service_account_names=cert-manager \
  bound_service_account_namespaces=cert-manager \
  policies=cert-manager-pki \
  ttl=1h \
  max_ttl=24h</code></pre>
</div>
</div>
<div class="sect3">
<h4 id="_verify_with_a_kubernetes_login_optional">Verify with a Kubernetes login (optional)</h4>
<div class="paragraph">
<p>After the cert-manager auth role exists, prove that OpenBao accepts the same service-account identity cert-manager will use.
Request a short-lived projected token for that service account, then log in to the <strong>Kubernetes</strong> auth method:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">JWT=$(oc create token cert-manager -n cert-manager --duration=15m)

bao write -format=json auth/kubernetes/login role=cert-manager jwt=&#34;$JWT&#34; \
  | jq -r &#39;.auth.client_token&#39;</code></pre>
</div>
</div>
<div class="paragraph">
<p>A printed <strong>client token</strong> means TokenReview and role binding succeeded.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_configure_the_clusterissuer_for_cert_manager">Configure the (Cluster)Issuer for cert-manager</h3>
<div class="paragraph">
<p>To integrate cert-manager with OpenBao we need to configure either a ClusterIssuer (cluster-wide) or an Issuer (namespace-scoped). The setup is very similar.</p>
</div>
<div class="paragraph">
<p>The ClusterIssuer manifest below must use the same OpenBao role name in <code>spec.vault.auth.kubernetes.role</code> (here <code>cert-manager</code>).</p>
</div>
<div class="paragraph">
<p>The server URL in the issuer must be reachable <strong>from the cert-manager pods</strong> (in-cluster Service DNS is typical), for example <a class="bare" href="https://openbao.openbao.svc:8200">https://openbao.openbao.svc:8200</a>.</p>
</div>
<div class="paragraph">
<p>The following is an example of a ClusterIssuer manifest.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
  name: openbao-cluster-issuer
spec:
  vault:
    path: pki_int/sign/server-cert <i class="conum" data-value="1"></i><b>(1)</b>
    server: https://openbao.openbao.svc:8200 <i class="conum" data-value="2"></i><b>(2)</b>
    caBundle: LS0tLS1CRUdJTi... <i class="conum" data-value="3"></i><b>(3)</b>
    auth:
      kubernetes:
        role: cert-manager
        mountPath: /v1/auth/kubernetes <i class="conum" data-value="4"></i><b>(4)</b>
        serviceAccountRef:
          name: cert-manager <i class="conum" data-value="5"></i><b>(5)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>PKI sign path for the OpenBao role (mount/sign/role-name).</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>OpenBao Service URL as seen from cert-manager pods.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td><strong>Required</strong> for private / self-signed OpenBao TLS: single-line base64 of the PEM CA (see the command block below). Omit only if the server uses a public CA trusted by default in the cert-manager image.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Kubernetes auth mount path in OpenBao (default is <code>/v1/auth/kubernetes</code>).</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Name of the cert-manager controller service account only. Do <strong>not</strong> add <code>namespace</code> under <code>serviceAccountRef</code>; it is not part of the cert-manager API.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>If OpenBao’s HTTPS certificate is not signed by a CA already trusted inside the cert-manager pods, you must supply trust material; otherwise TLS verification fails with <code>x509: certificate signed by unknown authority</code>.</p>
</div>
<div class="paragraph">
<p>Use <strong><code>caBundle</code></strong> (base64-encoded PEM of the CA that signed OpenBao’s server certificate) or <strong><code>caBundleSecretRef</code></strong> pointing to a Secret in the <code>cert-manager</code> namespace.</p>
</div>
<div class="paragraph">
<p>Fetch the certificate OpenBao is using:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get secret openbao-server-tls -n openbao -o jsonpath=&#39;{.data.ca\.crt}{&#34;\n&#34;}&#39;</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This secret was created in a previous article, when we were setting up the OpenBao server.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The returned string must be added to the <strong>ClusterIssuer</strong> manifest as the value of the <code>caBundle</code> field.</p>
</div>
<div class="paragraph">
<p>Alternatively, copy the CA PEM into a Secret in the <strong>cert-manager</strong> namespace and reference it (no giant line in the issuer):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml"># spec.vault fragment — use instead of caBundle if you prefer
    caBundleSecretRef:
      name: openbao-ca
      key: ca.crt</code></pre>
</div>
</div>
<div class="paragraph">
<p>However, this requires that the Secret exists in the appropriate namespace. For ClusterIssuer, the Secret must be in the <code>cert-manager</code> namespace.</p>
</div>
<div class="paragraph">
<p>Once the ClusterIssuer is created and is ready, we can issue a certificate.</p>
</div>
</div>
<div class="sect2">
<h3 id="_issue_a_certificate">Issue a Certificate</h3>
<div class="paragraph">
<p>With the ClusterIssuer in place, create a Certificate in the workload namespace (here myapp, this namespace must exist).
cert-manager will create a TLS Secret (myapp-tls below) containing <code>tls.crt</code> and <code>tls.key</code>, and renew the cert before it expires according to <code>renewBefore</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: myapp-tls
  namespace: myapp <i class="conum" data-value="1"></i><b>(1)</b>
spec:
  secretName: myapp-tls <i class="conum" data-value="2"></i><b>(2)</b>
  issuerRef: <i class="conum" data-value="3"></i><b>(3)</b>
    name: openbao-cluster-issuer
    kind: ClusterIssuer
  commonName: myapp.example.com <i class="conum" data-value="4"></i><b>(4)</b>
  dnsNames:
    - myapp.example.com
  duration: 168h <i class="conum" data-value="5"></i><b>(5)</b>
  renewBefore: 48h <i class="conum" data-value="6"></i><b>(6)</b>
  privateKey:
    rotationPolicy: Always <i class="conum" data-value="7"></i><b>(7)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The namespace of the workload</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The name of the TLS Secret</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The issuer of the certificate</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The common name of the certificate</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The duration of the certificate</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The duration before the certificate is renewed</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>Explicit rotation policy: <code>Always</code> matches cert-manager ≥ v1.18 default (new key each renewal). Set <code>Never</code> only if you rely on a stable key across renewals.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
The values you set in <code>commonName</code> and <code>dnsNames</code> must be <strong>allowed by the OpenBao PKI role</strong> (<code>allowed_domains</code>, <code>allow_subdomains</code>, <code>allow_bare_domains</code>, and related settings).
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock tip">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
If the Certificate never reaches <code>Ready=True</code>, check <code>kubectl describe certificate</code> / <code>kubectl describe certificaterequest</code> (or the same with <code>oc describe</code> on OpenShift) in that namespace, the cert-manager controller logs, and the OpenBao audit log for <code>403</code> policy denials or CSR rejection messages from the PKI engine.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>When everything is working, a Secret named <code>myapp-tls</code> is created in the <code>myapp</code> namespace containing <code>tls.crt</code> and <code>tls.key</code>.</p>
</div>
<div class="listingblock nocopy">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc describe secret/myapp-tls -n myapp

[source,bash]
----
Name:         myapp-tls
Namespace:    myapp
[...output omitted...]
Type:  kubernetes.io/tls

Data
====
tls.key:  1679 bytes
ca.crt:   1846 bytes
tls.crt:  3631 bytes</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This part showed how to turn OpenBao into a <strong>usable CA</strong> for cluster workloads and how to <strong>automate TLS</strong> with cert-manager.</p>
</div>
<div class="paragraph">
<p>You should now be able to:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Enable the PKI engine, set CA and CRL URLs, define roles, and issue certificates via the <code>issue</code> API (CLI or automation).</p>
</li>
<li>
<p>Stand up an intermediate CA signed by the root, and keep day-to-day issuance on the intermediate mount (<code>pki_int</code>).</p>
</li>
<li>
<p>Express least-privilege with policies that separate <code>issue</code> from <code>sign</code>, and allow CA/CRL reads where validators or clients need them.</p>
</li>
<li>
<p>Wire cert-manager to OpenBao’s Vault-compatible API: Kubernetes auth in-cluster (reviewer JWT and CA), a ClusterIssuer with <code>caBundle</code> (or <code>caBundleSecretRef</code>) for private OpenBao TLS, <code>serviceAccountRef.name</code> only (no <code>namespace</code> field), and a Certificate with an explicit <code>privateKey.rotationPolicy</code> for cert-manager ≥ v1.18.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org/docs/secrets/pki" rel="noopener" target="_blank">PKI Secrets Engine</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - Secrets Engines KV - Part 8</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-03-25-openbao-part-8-secrets-engines-kv/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-03-25-openbao-part-8-secrets-engines-kv/</guid><pubDate>Wed, 25 Mar 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Deep dive into OpenBao secrets engines: KV for static secrets</description><content:encoded><![CDATA[<div class="paragraph">
<p>Secrets engines are the heart of OpenBao’s functionality. They store, generate, or encrypt data. This article covers the most commonly used secrets engine: KV for static secrets. It will demonstrate how to use the KV secrets engine to store and retrieve secrets. Upcoming articles will cover the PKI secrets engine and the integration with <strong>cert-manager</strong>.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Secrets engines are components which store, generate, or encrypt data. Some engines simply store and read data, others connect to other services and other engines provide encryption as a service.</p>
</div>
<div class="paragraph">
<p>They are enabled at a path in OpenBao (as everything is done as a path in OpenBao). This means each secrets engine defines its very own path including properties.</p>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
The path is case-sensitive. For example, the KV secrets engine enabled at kv/ and KV/ are treated as two distinct instances of KV secrets engine.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The management of the secret engines is done via the CLI or API or, if enabled, the UI. Engines can be enabled, disabled, moved or tuned.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Enable - enables a secrets engine at the given path.</p>
</li>
<li>
<p>Disable - disables an existing secrets engine. All existing secrets are revoked and the data is deleted.</p>
</li>
<li>
<p>Move - moves the path for an existing secrets engine.</p>
</li>
<li>
<p>Tune - tunes global configuration for the secrets engine such as the TTLs.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_list_of_secrets_engines">List of Secrets Engines</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To list all enabled secrets engines, we can use the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao secrets list</code></pre>
</div>
</div>
<div class="paragraph">
<p>Which will output something like:</p>
</div>
<div class="listingblock nocopy">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Path          Type         Accessor              Description
----          ----         --------              -----------
cubbyhole/    cubbyhole    cubbyhole_f8b1e784    per-token private secret storage
identity/     identity     identity_76940581     identity store
secret/       kv           kv_ccb47c73           n/a
sys/          system       system_cb0d64b7       system endpoints used for control, policy and debugging</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
As a reminder: To login to the OpenBao CLI, we can use the following command (assuming that you are using HTTPS and have the CA certificate ready):
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">export BAO_ADDR=&#39;https://127.0.0.1:8200&#39;
export BAO_CACERT=&#34;$PWD/openbao-ca.crt&#34;
bao login</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="sect-kv">KV (Key-Value) Secrets Engine</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The <strong>KV</strong> secrets engine is probably the most commonly used engine. It is a generic key-value store.
When you work with KV secrets engine you will note very soon that there are two versions of the engine: <strong>KV v1</strong> and <strong>KV v2</strong>.</p>
</div>
<div class="sect2">
<h3 id="_kv_version_1">KV Version 1</h3>
<div class="paragraph">
<p>KV v1 is the older version of the KV secrets engine. It does not support versioning and only stores the recently written value for a key. Requests to this engine will be more performant because the storage requests will be fewer and no locking is required. The storage as such will be much smaller, since it does not need to retain any history.</p>
</div>
</div>
<div class="sect2">
<h3 id="_kv_version_2">KV Version 2</h3>
<div class="paragraph">
<p>KV v2 on the other hand supports versioning of secrets. When a version is deleted, the underlying data is not removed, instead you must destroy it intentionally. Storing the history of secrets will increase the required storage space. However, I would recommend using KV v2 in most cases as the benefit of versioning is too great to ignore.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The following example will use KV v2.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_kv_version_1_vs_version_2">KV Version 1 vs Version 2</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;"/>
<col style="width: 40%;"/>
<col style="width: 40%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Feature</th>
<th class="tableblock halign-left valign-top">Version 1</th>
<th class="tableblock halign-left valign-top">Version 2</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Versioning</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes (up to 10 versions by default)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Check-and-Set</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes (prevents concurrent writes)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Soft delete</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes (recoverable)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Metadata</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">No</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Yes (custom metadata)</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
KV v1 can be upgraded to KV v2 by using the following command as described in the documentation: <a href="https://openbao.org/docs/secrets/kv/kv-v2/#upgrading-from-version-1" rel="noopener" target="_blank">Upgrading from version 1</a>
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_enabling_kv_engine">Enabling KV Engine</h3>
<div class="paragraph">
<p>Let’s enable the KV v2 engine at the path <strong>secret/</strong> and give it the description &#34;Application secrets&#34;.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This path was used in <a href="/openshift-platform/security/secrets-management/openbao/2026-03-09-openbao-part-7-authentication-methods/">Part 7 of this series</a> already. So you might have to remove or rename the engine first if you have already enabled it.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao secrets enable \
  -path=secret \ <i class="conum" data-value="1"></i><b>(1)</b>
  -version=2 \ <i class="conum" data-value="2"></i><b>(2)</b>
  -description=&#34;Application secrets&#34; \
  kv <i class="conum" data-value="3"></i><b>(3)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Path where the secrets will be stored</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Version of the engine in case of KV</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Name of the engine</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_storing_secrets">Storing Secrets</h3>
<div class="paragraph">
<p>With the enabled engine, we can now store secrets at the path:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Put a secret (KV v2)
bao kv put secret/myapp/database \ <i class="conum" data-value="1"></i><b>(1)</b>
  username=&#34;dbadmin&#34; \ <i class="conum" data-value="2"></i><b>(2)</b>
  password=&#34;supersecret123&#34; \
  host=&#34;db.example.com&#34; \
  port=&#34;5432&#34;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Path where the secret will be stored</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Secret data</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Which will output something like:</p>
</div>
<div class="listingblock nocopy">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">======= Secret Path =======
secret/data/myapp/database <i class="conum" data-value="1"></i><b>(1)</b>

======= Metadata =======
Key                Value
---                -----
created_time       2026-03-13T05:56:52.670296216Z
custom_metadata    &lt;nil&gt;
deletion_time      n/a
destroyed          false
version            1 <i class="conum" data-value="2"></i><b>(2)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Path where the secret will be stored</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Version of the secret</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_reading_secrets">Reading Secrets</h3>
<div class="paragraph">
<p>To read the secret, we can use one of the following commands:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Read a secret
bao kv get secret/myapp/database</code></pre>
</div>
</div>
<div class="paragraph">
<p>Which will output something like:</p>
</div>
<div class="listingblock nocopy">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">======= Secret Path =======
secret/data/myapp/database <i class="conum" data-value="1"></i><b>(1)</b>

[... more metadata ...]

====== Data ====== <i class="conum" data-value="2"></i><b>(2)</b>
Key         Value
---         -----
host        db.example.com
password    supersecret123
port        5432
username    dbadmin</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Path where the secret will be stored</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Secret data</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>As an alternative, we can use the following command to get the secret as JSON:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Get as JSON
bao kv get -format=json secret/myapp/database</code></pre>
</div>
</div>
<div class="paragraph">
<p>We can also read a specific existing version of the secret by using the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Read specific version
bao kv get -version=2 secret/myapp/database</code></pre>
</div>
</div>
<div class="paragraph">
<p>Or simply, a specific field:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Get specific field
bao kv get -field=password secret/myapp/database</code></pre>
</div>
</div>
<div class="paragraph">
<p>If the UI is enabled, the same can be achieved via the browser:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part8_secretsengine_kv.png" alt="OpenBao Secret Retrieval"/>
</div>
<div class="title">Figure 1. OpenBao Secret Retrieval</div>
</div>
</div>
<div class="sect2">
<h3 id="_managing_versions">Managing Versions</h3>
<div class="paragraph">
<p>KV v2 keeps a version history. This is a big advantage over KV v1. To try version management, ensure the secret has at least two versions. Create a second version by writing to the same path again (e.g. with updated values):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao kv put secret/myapp/database username=dbadmin password=newpassword456 port=5432 <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Updating an existing secret with a new password, which will create a new version in KV v2.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Now you can list versions, soft-delete, undelete, or destroy a specific version:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
I will only paste the output of the first command. The rest will be similar …​ you’ll get the idea.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># List all versions and metadata
bao kv metadata get secret/myapp/database</code></pre>
</div>
</div>
<div class="paragraph">
<p>Which will output something like:</p>
</div>
<div class="listingblock nocopy">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">====== Version 1 ====== <i class="conum" data-value="1"></i><b>(1)</b>
Key              Value
---              -----
created_time     2026-03-13T05:56:52.670296216Z
deletion_time    n/a
destroyed        false

====== Version 2 ====== <i class="conum" data-value="2"></i><b>(2)</b>
Key              Value
---              -----
created_time     2026-03-13T06:13:18.539285992Z
deletion_time    n/a
destroyed        false</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Version 1</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Version 2</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Specific versions can now be (soft-) deleted, permanently destroyed etc.</p>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
The last command of the list will completely delete all versions and metadata for a given path aka the secret is gone.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Delete specific version (soft delete)
bao kv delete -versions=2 secret/myapp/database

# Undelete a version
bao kv undelete -versions=2 secret/myapp/database

# Permanently destroy a version
bao kv destroy -versions=2 secret/myapp/database

# Delete all versions and metadata
bao kv metadata delete secret/myapp/database</code></pre>
</div>
</div>
<div class="admonitionblock tip">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
When you define a secret you can set the maximum number of versions to keep using the flag <strong>-max-versions=5</strong>. This is the number of versions that will be kept in the history.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_custom_metadata">Custom Metadata</h3>
<div class="paragraph">
<p>A secret’s key metadata can contain multiple custom metadata that can be used to describe the secret. The data will be stored as key-value pairs. Imagine them like labels in Kubernetes.</p>
</div>
<div class="paragraph">
<p>Let’s extend our secret with some custom metadata:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Add custom metadata to a secret
bao kv metadata put \
  -custom-metadata=&#34;owner=team-a&#34; \ <i class="conum" data-value="1"></i><b>(1)</b>
  -custom-metadata=&#34;environment=production&#34; \ <i class="conum" data-value="2"></i><b>(2)</b>
  secret/myapp/database</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>First custom metadata to set an owner label</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Second custom metadata to set an environment label</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_policies_for_kv_v2">Policies for KV v2</h3>
<div class="paragraph">
<p>OpenBao policies control which authenticated clients may access which paths and with what actions. For the KV v2 secrets engine, any read or write via the API is checked against the token’s policies; without a policy granting the right capabilities, requests return 403. This section shows example policy rules you can attach to roles (e.g. Kubernetes auth roles) or tokens so that applications and users have the minimum access they need.</p>
</div>
<div class="paragraph">
<p>KV v2 exposes two logical path trees under the mount path (here <code>secret/</code>):</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong><code>secret/data/&lt;path&gt;</code></strong> — Secret values. Use capabilities such as <code>read</code>, <code>create</code>, <code>update</code>, and <code>delete</code> for reading and writing secret data.</p>
</li>
<li>
<p><strong><code>secret/metadata/&lt;path&gt;</code></strong> — Version and metadata. Use <code>list</code> to enumerate keys, and <code>read</code>/<code>delete</code> for version metadata and destroying versions.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The following example grants read-only access to all secrets under <code>myapp/</code>, plus full read/write (including create, update, delete) for the single path <code>myapp/database</code>. Replace <code>myapp</code> with your application or team prefix as needed.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-hcl hljs" data-lang="hcl"># Note: KV v2 uses /data/ for values and /metadata/ for metadata

# Read secret values under myapp/
path &#34;secret/data/myapp/*&#34; {
  capabilities = [&#34;read&#34;]
}

# List secret keys under myapp/ (required for listing, e.g. bao kv list secret/myapp)
path &#34;secret/metadata/myapp/*&#34; {
  capabilities = [&#34;list&#34;]
}

# Full access to a specific secret (create, read, update, delete)
path &#34;secret/data/myapp/database&#34; {
  capabilities = [&#34;create&#34;, &#34;read&#34;, &#34;update&#34;, &#34;delete&#34;]
}

# Read and delete version metadata for this secret (e.g. destroy version)
path &#34;secret/metadata/myapp/database&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;, &#34;delete&#34;]
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>After writing the policy to OpenBao (e.g. <code>bao policy write myapp-kv policy.hcl</code>), attach it to the appropriate auth method role or token so that clients receive a token with this policy. For token renewal, ensure the role or token also has <code>update</code> on <code>auth/token/renew-self</code> if you use renewable tokens.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<a href="/openshift-platform/security/secrets-management/openbao/2026-03-09-openbao-part-7-authentication-methods/">Part 7</a> of this series (Authentication Methods) explains the authentication methods and policies in more detail.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This part focused on the <strong>KV</strong> secrets engine: enabling a mount, storing and reading secrets, version lifecycle (list, soft delete, destroy), custom metadata, and <strong>policies</strong> that distinguish KV v2’s <code>data/</code> and <code>metadata/</code> paths.</p>
</div>
<div class="paragraph">
<p>Key takeaways:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Prefer <strong>KV v2</strong> when you need <strong>versioning</strong>, <strong>check-and-set</strong>, <strong>soft delete</strong>, and richer <strong>metadata</strong>; use KV v1 only when you explicitly want the simpler, lower-overhead path.</p>
</li>
<li>
<p>Grant <strong><code>secret/data/…​</code></strong> for secret values and <strong><code>secret/metadata/…​</code></strong> for listing and version operations—policies must match how the CLI and API resolve KV v2 paths.</p>
</li>
<li>
<p>Attach policies to <strong>tokens or auth roles</strong> (for example Kubernetes auth) so applications receive <strong>least-privilege</strong> access; include <strong><code>auth/token/renew-self</code></strong> if tokens should be renewable.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The <strong>PKI</strong> secrets engine and integration with <strong>cert-manager</strong> are covered in the next article in this series.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org/docs/secrets/kv/kv-v2" rel="noopener" target="_blank">KV Secrets Engine v2</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - Authentication Methods - Part 7</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-03-09-openbao-part-7-authentication-methods/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-03-09-openbao-part-7-authentication-methods/</guid><pubDate>Mon, 09 Mar 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Configuring authentication methods in OpenBao including Kubernetes auth, OIDC, LDAP, and AppRole for secure access control</description><content:encoded><![CDATA[<div class="paragraph">
<p>With OpenBao deployed and running, the next critical step is configuring authentication. Ultimately, you want to limit access to only authorised people. This article covers two common authentication methods: Kubernetes for pods and LDAP for enterprise directories (in a simplified example). There are many more methods, but we cannot cover them all in this article.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Authentication in OpenBao verifies the identity of clients before granting access to secrets. OpenBao supports multiple authentication methods, each suited for different use cases. Among others it supports:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;"/>
<col style="width: 40%;"/>
<col style="width: 40%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Method</th>
<th class="tableblock halign-left valign-top">Best For</th>
<th class="tableblock halign-left valign-top">Key Features</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Kubernetes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Pods running in K8s/OpenShift</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Service account tokens, automatic</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">OIDC</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Human users, SSO</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">OpenShift OAuth, Keycloak, Azure AD</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">LDAP</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enterprise directories</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Active Directory, OpenLDAP</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">AppRole</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">CI/CD, automation</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Role ID + Secret ID</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Token</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Direct access, bootstrap</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Simple but less secure</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The full documentation of the authentication methods and the list of available methods (for example Radius) can be found here: <a href="https://openbao.org/docs/auth/" rel="noopener" target="_blank">OpenBao Authentication Methods</a>.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_authentication_workflow">Authentication Workflow</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The authentication workflow in OpenBao from a user perspective is as follows:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>A client wants to authenticate to OpenBao and provides credentials.</p>
</li>
<li>
<p>OpenBao validates the credentials against the authentication method. For example: LDAP</p>
</li>
<li>
<p>If the authentication method (e.g. LDAP) is successful, it will return the required information about the client.</p>
</li>
<li>
<p>OpenBao maps this result to policies that are mapped to the authentication method.</p>
</li>
<li>
<p>OpenBao generates a token that is associated with the policies and returns it to the client.</p>
</li>
<li>
<p>The client can then use this token for further operations.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_prerequisites_for_authentication_methods">Prerequisites for Authentication Methods</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before configuring authentication:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenBao is deployed and unsealed (Parts 2-6)</p>
</li>
<li>
<p>You have admin access to OpenBao (root token)</p>
</li>
<li>
<p>Access to the required authentication backend:</p>
<div class="ulist">
<ul>
<li>
<p>For Kubernetes auth: Access to the OpenShift cluster</p>
</li>
<li>
<p>For LDAP: Access to the LDAP server</p>
</li>
<li>
<p>etc.</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>Set up your environment:</p>
</div>
<div class="paragraph">
<p>You can set up your environment by using either the <strong>CLI</strong> or the <strong>UI</strong>.</p>
</div>
<div class="sect2">
<h3 id="_using_the_cli">Using the CLI</h3>
<div class="paragraph">
<p>You can use the CLI to interact with OpenBao. In this example we will forward the port locally to the OpenBao server and set the environment variable <code>BAO_ADDR</code> to the local address. With <strong>boa login</strong> and the root token you can authenticate against OpenBao with full access.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Port forward (if needed)
oc port-forward svc/openbao 8200:8200 -n openbao &amp;

# Set environment
export BAO_ADDR=&#39;http://127.0.0.1:8200&#39;
# You may need the SSL CA too.
# export BAO_CACERT=&#34;$PWD/openbao-ca.crt&#34;

# Login with root token
bao login

# List all authentication methods
bao auth list</code></pre>
</div>
</div>
<div class="paragraph">
<p>The last command returns a list of the available authentication methods. Currently there is only one authentication method enabled: <strong>token</strong>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Path     Type     Accessor                 Description                      Version
----     ----     --------                 -----------                      -------
token/   token    auth_token_1020fa7b      token based credentials          n/a</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_using_the_ui">Using the UI</h3>
<div class="paragraph">
<p>The UI, if enabled, is accessible via the OpenShift Route (if running on OpenShift and if it was created in <a href="/openshift-platform/security/secrets-management/openbao/2026-02-13-openbao-part-3-openshift-deployment/">Part 3</a>). The password/token is the <strong>root token</strong> from the initialisation.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part7_openbao_ui_login_form.png" alt="OpenBao UI Login Form"/>
</div>
<div class="title">Figure 1. OpenBao UI Login Form</div>
</div>
<div class="paragraph">
<p>The UI has the advantage that it offers more visibility into the configuration and possibilities.
For example, at the beginning there is one authentication method <strong>token</strong> enabled. This is required for the root token authentication.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part7_openbao_ui_authentication_methods.png?width=840px" alt="OpenBao UI Authentication Methods"/>
</div>
<div class="title">Figure 2. OpenBao UI Authentication Methods</div>
</div>
<div class="paragraph">
<p>We can enable the other authentication methods by clicking on the <strong>Enable new method</strong> link to see what options are available.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part7_openbao_ui_configuring_new_authentication_methods.png" alt="OpenBao UI Configuring New Authentication Method"/>
</div>
<div class="title">Figure 3. OpenBao UI Configuring New Authentication Method</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_understanding_policies">Understanding Policies</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before you can actually use an authentication method, it is important to understand what <strong>policies</strong> do. A policy is a way to declaratively define what (which paths) authenticated users can access or not. All paths are <strong>denied by default</strong>. A policy is mapped to an authentication method. For example, when we look at LDAP, we could configure something like this:</p>
</div>
<div class="paragraph">
<p><em>Every member of group &#34;dev&#34; is mapped to a policy named &#34;dev-policy&#34;. The policy then allows the user to read the secrets under the path &#34;secret/data/dev/*&#34;.</em></p>
</div>
<div class="sect2">
<h3 id="_basic_policy_structure">Basic Policy Structure</h3>
<div class="paragraph">
<p>A policy is a set of <strong>path rules</strong>. Each rule says: “for this path (or path prefix), the bearer of this policy may use these <strong>capabilities</strong>.” Paths are tied to OpenBao’s internal API: for example, secrets in the KV v2 engine live under <code>secret/data/&lt;mount-path&gt;/&lt;key&gt;</code>, so a path like <code>secret/data/myapp/*</code> means “any key under the <code>myapp</code> prefix in the KV v2 store mounted at <code>secret/</code>.”</p>
</div>
<div class="paragraph">
<p>The example below does two things that are typical for an application policy:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Secrets access:</strong> It allows <strong>read</strong> and <strong>list</strong> on <code>secret/data/myapp/*</code>.</p>
<div class="ulist">
<ul>
<li>
<p><strong>read</strong> lets the client fetch the value of a secret at a path (e.g. <code>secret/data/myapp/database</code>).</p>
</li>
<li>
<p><strong>list</strong> is required to list keys under a path (e.g. to discover <code>myapp/database</code>, <code>myapp/api-key</code>); without it, the client would need to know every path in advance.</p>
</li>
</ul>
</div>
</li>
<li>
<p><strong>Token renewal:</strong> It allows <strong>update</strong> on <code>auth/token/renew-self</code>. Tokens often have a limited lifetime; this path lets the holder extend their own token without needing the root token or extra permissions. Including it avoids applications losing access when the token expires.</p>
</li>
</ol>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Policies can be written in JSON or HCL.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-hcl hljs" data-lang="hcl"># Example policy: myapp-read-policy.hcl
# Allow reading secrets from specific path (KV v2 engine at mount &#34;secret/&#34;)
path &#34;secret/data/myapp/*&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;]
}

# Allow renewing own token so the app can extend its token before expiry
path &#34;auth/token/renew-self&#34; {
  capabilities = [&#34;update&#34;]
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>The path <code>secret/data/myapp/*</code> assumes you have a KV v2 secrets engine mounted at <code>secret/</code> and will store application secrets under keys like <code>myapp/database</code>, <code>myapp/api-key</code>, etc. Adjust the mount path and prefix to match your setup.</p>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
The use of globs (*) may result in surprising or unexpected behaviour. Use them with caution.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_policy_capabilities">Policy Capabilities</h3>
<div class="paragraph">
<p>Each path defined in a policy must have at least one capability. This provides control over the allowed or denied operations a user may perform. There are several capabilities available:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>create</code> - Create new data at the given path</p>
</li>
<li>
<p><code>read</code> - Read data</p>
</li>
<li>
<p><code>update</code> - Update existing data</p>
</li>
<li>
<p><code>patch</code> - Patch existing data (Partial update)</p>
</li>
<li>
<p><code>delete</code> - Delete data</p>
</li>
<li>
<p><code>list</code> - List keys at a path</p>
</li>
<li>
<p><code>scan</code> - Scan or browse the path for keys</p>
</li>
<li>
<p><code>sudo</code> - Allows access to paths that are <strong>root-protected</strong>.</p>
</li>
<li>
<p><code>deny</code> - Explicitly deny (overrides other grants)</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_default_policies">Default Policies</h3>
<div class="paragraph">
<p>When OpenBao is deployed the first time, there are no additional authentication methods enabled, except for <strong>token</strong>. This is required for the root access itself. To allow the administrator to access using the root token, there is one default policy called <strong>root</strong>. This policy is somewhat of a catch-all policy; it allows the administrator to access everything.</p>
</div>
<div class="paragraph">
<p>In addition to the root policy, there is one other default policy called <strong>default</strong>. This policy is used for all authenticated users. It allows them, for example, to look up their own properties and to renew or revoke their own token.</p>
</div>
<div class="paragraph">
<p>Let’s look at the default policies in the CLI:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
A quick reminder of how to log in to OpenBao using the CLI when running it against Kubernetes: first open a port-forward, set the variable <code>BAO_ADDR</code> to the local address; if you use HTTPS you may need to set the SSL CA certificate, then log in with the root token.
</td>
</tr>
</tbody></table>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>You need to have the CA certificate in the current directory, which you might fetch with:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get secret openbao-ca-secret -n openbao -o jsonpath=&#39;{.data.ca\.crt}&#39; | base64 -d &gt; openbao-ca.crt</code></pre>
</div>
</div>
</li>
<li>
<p>Port forward, set the environment variables and login with the root token:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Port forward (if needed)
oc port-forward svc/openbao 8200:8200 -n openbao &amp;

# Set environment
export BAO_ADDR=&#39;https://127.0.0.1:8200&#39;

# You may need the SSL CA too.
export BAO_CACERT=&#34;$PWD/openbao-ca.crt&#34;

# Login with root token
bao login</code></pre>
</div>
</div>
</li>
<li>
<p>Now to list and fetch the current policies you can use the following commands:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># List policies
bao policy list
# Returns something like this:
#default
#root

# Read a policy
bao policy read default</code></pre>
</div>
</div>
</li>
<li>
<p>The second command returns the policy content:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Allow tokens to look up their own properties
path &#34;auth/token/lookup-self&#34; {
    capabilities = [&#34;read&#34;]
}

# Allow tokens to renew themselves
path &#34;auth/token/renew-self&#34; {
    capabilities = [&#34;update&#34;]
}

# Allow tokens to revoke themselves
path &#34;auth/token/revoke-self&#34; {
    capabilities = [&#34;update&#34;]
}

# Allow a token to look up its own capabilities on a path
path &#34;sys/capabilities-self&#34; {

[...]</code></pre>
</div>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>Again you will see the same policies in the UI. You can also manage them or create new ones using the UI.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part7_openbao_ui_list_policies.png" alt="OpenBao UI List Policies"/>
</div>
<div class="title">Figure 4. OpenBao UI Listing Policies</div>
</div>
</div>
<div class="sect2">
<h3 id="_creating_policies_using_the_cli">Creating Policies using the CLI</h3>
<div class="paragraph">
<p>Creating a policy, for example using the CLI, is straightforward. You can create a policy from a file or inline. The syntax is either JSON or HCL.
The example below creates a policy called &#34;myapp-read&#34; from a file called &#34;myapp-read-policy.hcl&#34;. The policy allows reading and listing secrets under the path &#34;secret/data/myapp/*&#34;.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Create a policy from file
bao policy write myapp-read myapp-read-policy.hcl

# Or inline
bao policy write myapp-read - &lt;&lt;EOF
path &#34;secret/data/myapp/*&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;]
}
EOF

# List policies
bao policy list

# Read a policy
bao policy read myapp-read</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_kubernetes_authentication_method">Kubernetes Authentication Method</h2>
<div class="sectionbody">
<div class="paragraph">
<p>As we work a lot with OpenShift/Kubernetes, this method of authentication will be the first to try.
The Kubernetes auth method can be used to authenticate against OpenBao using Kubernetes Service Account tokens.
It is essential for pods to access secrets.</p>
</div>
<div class="paragraph">
<p>Let us try a simple example.</p>
</div>
<div class="sect2">
<h3 id="_step_1_enable_kubernetes_auth">Step 1: Enable Kubernetes Auth</h3>
<div class="paragraph">
<p>Assuming you are still logged into OpenBao, you can enable the kubernetes auth method with the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao auth enable --description=&#34;Authentication method for Kubernetes/OpenShift cluster&#34; kubernetes</code></pre>
</div>
</div>
<div class="paragraph">
<p>This simply enabled the authentication method and set a description. However, we need to configure it further.</p>
</div>
</div>
<div class="sect2">
<h3 id="_step_2_configure_kubernetes_auth">Step 2: Configure Kubernetes Auth</h3>
<div class="paragraph">
<p>To configure the kubernetes auth method, you need to get the Kubernetes API server address. You can get it with the following command (assuming you are logged into the OpenShift cluster):</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The command <code>oc</code> can be replaced by <code>kubectl</code> if you are not using an OpenShift cluster.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Get the Kubernetes API server address
KUBERNETES_HOST=$(oc whoami --show-server) <i class="conum" data-value="1"></i><b>(1)</b>

# Configure the auth method
bao write auth/kubernetes/config \ <i class="conum" data-value="2"></i><b>(2)</b>
  kubernetes_host=&#34;$KUBERNETES_HOST&#34;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Get the Kubernetes API server address. This will use something like <a class="bare" href="https://api.cluster.example.com:6443">https://api.cluster.example.com:6443</a></td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Configure the auth method with the Kubernetes API server address.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
When running inside Kubernetes, OpenBao automatically uses the pod’s service account to communicate with the Kubernetes API.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_step_3_create_a_policy_for_the_application">Step 3: Create a Policy for the Application</h3>
<div class="paragraph">
<p>Now we need to associate a policy to the authentication method. We could also assign the default policy but we want to provide access to the path <strong>secret/data/expense/database</strong> and <strong>secret/metadata/expense/config</strong> for the application.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Create policy for an example application
bao policy write expense-app - &lt;&lt;EOF
# Read database credentials
path &#34;secret/data/expense/database&#34; {
  capabilities = [&#34;read&#34;]
}

# Read application config
path &#34;secret/data/expense/config&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;]
}

# Allow token renewal
path &#34;auth/token/renew-self&#34; {
  capabilities = [&#34;update&#34;]
}
EOF</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_step_4_create_a_kubernetes_auth_role">Step 4: Create a Kubernetes Auth Role</h3>
<div class="paragraph">
<p>As the next step we map the policy to the authentication method. We will further limit the access to the namespace <strong>expense</strong> and the service account <strong>expense-app</strong>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Create a role that maps Kubernetes service accounts to OpenBao policies
bao write auth/kubernetes/role/expense-app \
  bound_service_account_names=expense-app \ <i class="conum" data-value="1"></i><b>(1)</b>
  bound_service_account_namespaces=expense \ <i class="conum" data-value="2"></i><b>(2)</b>
  policies=expense-app \ <i class="conum" data-value="3"></i><b>(3)</b>
  ttl=1h \ <i class="conum" data-value="4"></i><b>(4)</b>
  max_ttl=24h <i class="conum" data-value="5"></i><b>(5)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td><code>bound_service_account_names</code>: K8s service account name(s)</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td><code>bound_service_account_namespaces</code>: K8s namespace(s)</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td><code>policies</code>: OpenBao policies to attach</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td><code>ttl</code>: Token time-to-live</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td><code>max_ttl</code>: Maximum token lifetime</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
All of the configuration above, created using the CLI, can also be done using the UI of OpenBao.
</td>
</tr>
</tbody></table>
</div>
<div class="sect3">
<h4 id="_ensure_the_kv_v2_secrets_engine_is_mounted_at_secret">Ensure the KV v2 secrets engine is mounted at <code>secret/</code></h4>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
We will discuss secret engines in more detail in the next part of the guide.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The policy and demo commands in this guide use the path <code>secret/data/expense/database</code>, which assumes a KV v2 secrets engine mounted at <code>secret/</code>. To check and enable it:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Check existing mounts:</strong> List enabled secrets engines and look for <code>secret/</code> with type <code>kv</code> (version 2):</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># List all secrets engine mounts (requires a token with read on sys/mounts)
bao secrets list</code></pre>
</div>
</div>
<div class="paragraph">
<p>Look for an entry like <code>secret/</code> with type <code>kv</code> or <code>kv-v2</code>. If you see <code>secret/</code> and it is KV v2, you can skip to Step 5.</p>
</div>
</li>
<li>
<p><strong>Enable KV v2 at <code>secret/</code> if missing:</strong> If <code>secret/</code> is not listed, or you want to use a fresh mount, enable the KV v2 engine at the path <code>secret</code>:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Enable KV v2 secrets engine at path &#34;secret&#34; (requires root or policy with sys/mounts capability)
bao secrets enable -path=secret -version=2 kv</code></pre>
</div>
</div>
<div class="paragraph">
<p>If <code>secret/</code> already exists as KV v1, you cannot change it in place to v2; use a different path (e.g. <code>secretv2/</code>) and update the policy and demo paths accordingly (<code>secretv2/data/expense/database</code>, etc.).</p>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_step_5_store_the_database_secret_in_openbao_one_time">Step 5: Store the database secret in OpenBao (one-time)</h3>
<div class="paragraph">
<p>Before the application can read it, store the database password (and any other keys) at the path the policy allows. Run this once from a machine that has OpenBao access (e.g. <code>bao</code> CLI and a token).</p>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
You must use a token that has <strong>create</strong> and <strong>update</strong> capability on the KV path. The <code>expense-app</code> policy is read-only (for the application). Use the <strong>root token</strong> from OpenBao initialisation, or log in with <code>bao login</code> and use a token that has a policy granting <code>create</code> and <code>update</code> on <code>secret/data/expense/*</code>. If you use a read-only token (e.g. one that only has the expense-app policy), you will get a 403 &#34;preflight capability check returned 403&#34;.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Store the database secret at secret/data/expense/database (KV v2 path)
bao kv put secret/expense/database password=&#34;my-super-secret-db-password&#34; username=&#34;expense_db_user&#34;</code></pre>
</div>
</div>
<div class="paragraph">
<p>This creates (or overwrites) the secret at <code>secret/data/expense/database</code>. The policy grants the <code>expense-app</code> role <strong>read</strong> on this path only; the application cannot create or update it.</p>
</div>
</div>
<div class="sect2">
<h3 id="_step_6_create_the_expense_namespace_and_demo_application">Step 6: Create the expense namespace and demo application</h3>
<div class="paragraph">
<p>Apply the following manifests to create the namespace, service account, optional long-lived token (Kubernetes 1.24+), and a demo deployment that authenticates to OpenBao and fetches the database secret. Adjust the OpenBao URL if your OpenBao is in another namespace or uses HTTPS (e.g. <code><a class="bare" href="https://openbao.openbao.svc:8200">https://openbao.openbao.svc:8200</a></code>).</p>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Remember: We have created a policy that allows the service account with the name <strong>expense-app</strong> in the namespace <strong>expense</strong> to read the secret at <strong>secret/data/expense/database</strong>. If you want to use different paths or namespaces, you need to adjust the policy accordingly.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml"># full-demo-expense-app.yaml
# 1. Namespace
apiVersion: v1
kind: Namespace <i class="conum" data-value="1"></i><b>(1)</b>
metadata:
  name: expense
---
# 2. Service account used by the demo app to authenticate to OpenBao
apiVersion: v1
kind: ServiceAccount <i class="conum" data-value="2"></i><b>(2)</b>
metadata:
  name: expense-app
  namespace: expense
---
# 3. Long-lived token for Kubernetes 1.24+ (optional; allows pods to use the SA token)
apiVersion: v1
kind: Secret <i class="conum" data-value="3"></i><b>(3)</b>
metadata:
  name: expense-app-token
  namespace: expense
  annotations:
    kubernetes.io/service-account.name: expense-app
type: kubernetes.io/service-account-token
---
# 4. Demo deployment: authenticates to OpenBao and fetches secret/data/expense/database
apiVersion: apps/v1
kind: Deployment
metadata:
  name: expense-demo
  namespace: expense
  labels:
    app: expense-demo
spec:
  replicas: 1
  selector:
    matchLabels:
      app: expense-demo
  template:
    metadata:
      labels:
        app: expense-demo
    spec:
      serviceAccountName: expense-app
      containers:
        - name: demo
          image: registry.access.redhat.com/ubi9/ubi-minimal:latest
          command:
            - /bin/sh
            - -c
            - |
              echo &#34;=== Installing curl ===&#34;
              microdnf install -y curl 2&gt;/dev/null || true
              echo &#34;=== Fetching database secret from OpenBao ===&#34;

              JWT=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)

              OPENBAO_URL=&#34;${OPENBAO_URL:-http://openbao.openbao:8200}&#34;

              RESP=$(curl -s -k -X POST -H &#34;Content-Type: application/json&#34; \ <i class="conum" data-value="4"></i><b>(4)</b>
                -d &#34;{\&#34;jwt\&#34;: \&#34;$JWT\&#34;, \&#34;role\&#34;: \&#34;expense-app\&#34;}&#34; \
                &#34;$OPENBAO_URL/v1/auth/kubernetes/login&#34;)

              TOKEN=$(echo &#34;$RESP&#34; | sed -n &#39;s/.*&#34;client_token&#34;:&#34;\([^&#34;]*\)&#34;.*/\1/p&#39;)
              if [ -z &#34;$TOKEN&#34; ]; then
                echo &#34;ERROR: Failed to get OpenBao token. Check OpenBao URL ($OPENBAO_URL), role expense-app, and network.&#34;
                echo &#34;Response: $RESP&#34;
                exit 1
              fi

              echo &#34;OpenBao token obtained. Reading secret/data/expense/database ...&#34;
              SECRET=$(curl -s -k -H &#34;X-Vault-Token: $TOKEN&#34; &#34;$OPENBAO_URL/v1/secret/data/expense/database&#34;) <i class="conum" data-value="5"></i><b>(5)</b>
              echo &#34;$SECRET&#34;

              PASSWORD=$(echo &#34;$SECRET&#34; | sed -n &#39;s/.*&#34;password&#34;:&#34;\([^&#34;]*\)&#34;.*/\1/p&#39;)
              echo &#34;Database password (data.data.password): ${PASSWORD:-&lt;not set&gt;}&#34;
              echo &#34;=== Demo complete. Pod stays running; exec in to run more curl commands. ===&#34;
              exec sleep infinity
          env:
            # Override if OpenBao is in another namespace or uses HTTPS
            - name: OPENBAO_URL
              value: &#34;https://openbao.openbao:8200&#34;
          resources:
            requests:
              memory: &#34;64Mi&#34;
              cpu: &#34;10m&#34;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Create the namespace</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Create the service account</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Create the secret (long-lived token for Kubernetes 1.24+)</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Authenticate to OpenBao and get a client token (using the Kubernetes JWT)</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Fetch the database secret</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
The examples above use <strong>curl -k</strong> to bypass certificate verification. For production, you should adjust this and mount the CA certificate in the pod (see the note earlier in this section on using the <code>openbao-ca</code> Secret).
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Apply the manifests and wait for the pod to be ready:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc apply -f full-demo-expense-app.yaml

# Wait for the demo pod to be running
oc -n expense rollout status deployment/expense-demo

# View the log: you should see the OpenBao token response and the fetched secret (including the password)
oc -n expense logs -l app=expense-demo -f</code></pre>
</div>
</div>
<div class="paragraph">
<p>The log output shows the application authenticating with the Kubernetes JWT, receiving an OpenBao token, and reading the secret at <code>secret/data/expense/database</code>. The field <code>data.data.password</code> is the database password you stored in Step 5.</p>
</div>
</div>
<div class="sect2">
<h3 id="_step_7_test_kubernetes_authentication_manually">Step 7: Test Kubernetes authentication manually</h3>
<div class="paragraph">
<p>From any pod that uses the same service account (e.g. the demo pod above), you can run the same steps by hand:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># From within a pod using the service account (e.g. oc exec -it deployment/expense-demo -n expense -- /bin/sh)
JWT=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)

# 1. Authenticate to OpenBao and get a client token (sed works on UBI minimal; use jq -r .auth.client_token if jq is available)
LOGIN=$(curl -s -k --request POST \
  --data &#34;{\&#34;jwt\&#34;: \&#34;$JWT\&#34;, \&#34;role\&#34;: \&#34;expense-app\&#34;}&#34; \
  https://openbao.openbao:8200/v1/auth/kubernetes/login)
TOKEN=$(echo &#34;$LOGIN&#34; | sed -n &#39;s/.*&#34;client_token&#34;:&#34;\([^&#34;]*\)&#34;.*/\1/p&#39;)

# 2. Fetch the database secret (same path the policy allows)
curl -s -k -H &#34;X-Vault-Token: $TOKEN&#34; https://openbao.openbao:8200/v1/secret/data/expense/database</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_summary_kubernetes_auth_method">Summary: Kubernetes auth method</h3>
<div class="paragraph">
<p>A lot of steps were involved to configure the Kubernetes auth method. Let us summarize them:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>In OpenBao:</strong> Enabled the Kubernetes auth method, configured it with the cluster API server address, created the <code>expense-app</code> policy (read on <code>secret/data/expense/database</code> and <code>secret/data/expense/config</code>, update on <code>auth/token/renew-self</code>), and created the <code>expense-app</code> role that binds the Kubernetes service account <code>expense-app</code> in namespace <code>expense</code> to that policy.</p>
</li>
<li>
<p><strong>Secrets engine:</strong> Ensured the KV v2 engine is mounted at <code>secret/</code> and stored the database secret at <code>secret/expense/database</code> (one-time, using the root token).</p>
</li>
<li>
<p><strong>In the cluster:</strong> Created the <code>expense</code> namespace, the <code>expense-app</code> service account, an optional long-lived token Secret (for Kubernetes 1.24+), and the <code>expense-demo</code> deployment that uses that service account to authenticate to OpenBao and fetch the secret. For HTTPS, created the <code>openbao-ca</code> Secret in <code>expense</code> with the OpenBao server CA.</p>
</li>
<li>
<p><strong>Verification:</strong> Applied the manifests, confirmed the demo pod starts and logs show a successful login and the fetched secret (including the database password). Optionally ran the same login and read steps manually via <code>oc exec</code> into the pod.</p>
</li>
</ul>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_ldap_authentication_method">LDAP Authentication Method</h2>
<div class="sectionbody">
<div class="paragraph">
<p>LDAP auth integrates with enterprise directories like Active Directory.</p>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
This is a very simplified example. As a prerequisite you need to have an LDAP server and a service account with the necessary permissions to read the users and groups. This is not part of this guide.
</td>
</tr>
</tbody></table>
</div>
<div class="sect2">
<h3 id="_step_1_enable_ldap_auth">Step 1: Enable LDAP Auth</h3>
<div class="paragraph">
<p>To enable LDAP authentication, you need to use the following command:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao auth enable ldap</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_step_2_configure_ldap_active_directory_example">Step 2: Configure LDAP (Active Directory Example)</h3>
<div class="paragraph">
<p>In this step you need to configure the LDAP server address, the user and group attributes, the bind DN and the bind password.
The example below configures the LDAP server address to <strong>ldaps://ad.example.com:636</strong>, the user attribute to <strong>sAMAccountName</strong>, the user DN to <strong>OU=Users,DC=example,DC=com</strong>, the group DN to <strong>OU=Groups,DC=example,DC=com</strong>, the group attribute to <strong>cn</strong>, the group filter to <strong>(&amp;(objectClass=group)(member:1.2.840.113556.1.4.1941:={{.UserDN}}))</strong>, the bind DN to <strong>CN=openbao-svc,OU=ServiceAccounts,DC=example,DC=com</strong> and the bind password to <strong>service-account-password</strong>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao write auth/ldap/config \
  url=&#34;ldaps://ad.example.com:636&#34; \
  userattr=&#34;sAMAccountName&#34; \
  userdn=&#34;OU=Users,DC=example,DC=com&#34; \
  groupdn=&#34;OU=Groups,DC=example,DC=com&#34; \
  groupattr=&#34;cn&#34; \
  groupfilter=&#34;(&amp;(objectClass=group)(member:1.2.840.113556.1.4.1941:={{.UserDN}}))&#34; \
  binddn=&#34;CN=openbao-svc,OU=ServiceAccounts,DC=example,DC=com&#34; \
  bindpass=&#34;service-account-password&#34; \
  certificate=@/path/to/ldap-ca.pem \
  insecure_tls=false \
  starttls=false</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_step_3_create_the_policies_used_by_the_group_mapping">Step 3: Create the policies used by the group mapping</h3>
<div class="paragraph">
<p>Before mapping LDAP groups to policy names, create those policies. Below are example definitions: <strong>admin-policy</strong> grants read/list/update on secrets (e.g. for operators), and <strong>user-policy</strong> grants read-only access to a limited path.</p>
</div>
<div class="paragraph">
<p><strong>admin-policy</strong> — for members of <strong>openbao-admins</strong> (e.g. operators who may read and update secrets)</p>
</div>
<div class="paragraph">
<p><strong>user-policy</strong> — for members of <strong>openbao-users</strong> (e.g. developers with read-only access to a subset of secrets)</p>
</div>
<div class="paragraph">
<p>Create them with the CLI (run before the group mapping in Step 4):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Create admin-policy (e.g. from file admin-policy.hcl)
bao policy write admin-policy - &lt;&lt;EOF
path &#34;secret/data/*&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;, &#34;update&#34;, &#34;create&#34;, &#34;delete&#34;]
}
path &#34;secret/metadata/*&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;]
}
path &#34;auth/token/renew-self&#34; {
  capabilities = [&#34;update&#34;]
}
EOF

# Create user-policy
bao policy write user-policy - &lt;&lt;EOF
path &#34;secret/data/myapp/*&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;]
}
path &#34;auth/token/renew-self&#34; {
  capabilities = [&#34;update&#34;]
}
EOF</code></pre>
</div>
</div>
<div class="paragraph">
<p>Adjust paths (e.g. <code>secret/data/myapp/</code>) to match your KV v2 mount and the paths you want each role to access. The <strong>default</strong> policy is built-in and grants token lookup/renew/revoke-self. Attaching it in addition to <strong>admin-policy</strong> or <strong>user-policy</strong> is a typical pattern.</p>
</div>
</div>
<div class="sect2">
<h3 id="_step_4_map_ldap_groups_to_policies">Step 4: Map LDAP groups to policies</h3>
<div class="paragraph">
<p>Now map the LDAP groups to the policy names. The example below maps the LDAP group <strong>openbao-admins</strong> to the policies <strong>admin-policy</strong> and <strong>default</strong> and the LDAP group <strong>openbao-users</strong> to the policies <strong>user-policy</strong> and <strong>default</strong>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Map an LDAP group to policies
bao write auth/ldap/groups/openbao-admins \
  policies=&#34;admin-policy,default&#34;

bao write auth/ldap/groups/openbao-users \
  policies=&#34;user-policy,default&#34;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_step_5_test_ldap_authentication">Step 5: Test LDAP authentication</h3>
<div class="paragraph">
<p>Assuming you have a user <strong>jdoe</strong> in the LDAP group <strong>openbao-users</strong>, you can test the LDAP authentication with the following commands:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Login with LDAP credentials
bao login -method=ldap username=jdoe

# Or via API
curl --request POST \
  --data &#39;{&#34;password&#34;: &#34;user-password&#34;}&#39; \
  $BAO_ADDR/v1/auth/ldap/login/jdoe</code></pre>
</div>
</div>
<div class="sect3">
<h4 id="_what_jdoe_can_and_cannot_do_user_policy">What jdoe can and cannot do (user-policy)</h4>
<div class="paragraph">
<p>jdoe holds <strong>user-policy</strong> (and <strong>default</strong>), so their token has only the capabilities defined there.</p>
</div>
<div class="paragraph">
<p>What jdoe can do:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Get a secret under <code>secret/data/myapp/*</code>: after logging in, jdoe can read and list secrets in that path. For example:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># After bao login -method=ldap username=jdoe (and entering the password)
bao kv get secret/myapp/database
# Or via API (use the client_token from the login response)
curl -s -H &#34;X-Vault-Token: $TOKEN&#34; $BAO_ADDR/v1/secret/data/myapp/database</code></pre>
</div>
</div>
</li>
<li>
<p>List keys under <code>secret/data/myapp/</code> to discover available secrets.</p>
</li>
<li>
<p>Renew or revoke their own token (from the <strong>default</strong> policy) and look up their own token properties.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>What jdoe cannot do:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Read secrets outside <code>myapp</code> — e.g. <code>secret/data/expense/database</code> or <code>secret/data/other-app/*</code> returns permission denied.</p>
</li>
<li>
<p>Create, update, or delete any secret — <strong>user-policy</strong> grants only <code>read</code> and <code>list</code> on <code>secret/data/myapp/*</code>, so write operations are denied.</p>
</li>
<li>
<p>Access admin or system paths — no access to <code>sys/<strong></strong></code><strong>, other auth methods, or policies. Only the paths explicitly granted in *user-policy</strong> and <strong>default</strong> are allowed.</p>
</li>
</ul>
</div>
<hr/>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_common_practices_for_authentication">Common Practices for Authentication</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><strong>Use the principle of least privilege</strong> - Do not grant more permissions than necessary.</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-hcl hljs" data-lang="hcl"># Bad: Too broad
path &#34;secret/*&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;]
}

# Good: Specific paths
path &#34;secret/data/myapp/database&#34; {
  capabilities = [&#34;read&#34;]
}</code></pre>
</div>
</div>
</li>
<li>
<p><strong>Set Appropriate Token TTLs</strong> - Set the appropriate TTLs for different use cases.</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Short-lived for automated systems
bao write auth/kubernetes/role/batch-job \
  ttl=5m \
  max_ttl=15m

# Longer for interactive users
bao write auth/oidc/role/human-user \
  ttl=8h \
  max_ttl=24h</code></pre>
</div>
</div>
</li>
<li>
<p><strong>Enable Audit Logging</strong> - Enable audit logging to track authentication attempts and other activities.</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Enable file audit
bao audit enable file file_path=/var/log/openbao/audit.log

# All authentication attempts are logged</code></pre>
</div>
</div>
</li>
<li>
<p><strong>Regularly Rotate Credentials</strong> - Rotate the credentials periodically to reduce the risk of compromise.</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Rotate AppRole Secret IDs periodically
bao write -f auth/approle/role/cicd-role/secret-id

# Revoke old tokens
bao token revoke &lt;old-token&gt;</code></pre>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_common_authentication_patterns">Common Authentication Patterns</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><strong>Pattern 1: Application Pods</strong></p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">Pod → Service Account Token → Kubernetes Auth → Policy → Secret</code></pre>
</div>
</div>
</li>
<li>
<p><strong>Pattern 2: Human Users</strong></p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">User → LDAP/OIDC Login → Group Mapping → Policy → Secret</code></pre>
</div>
</div>
</li>
<li>
<p><strong>Pattern 3: CI/CD Pipeline</strong></p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">Pipeline → AppRole (Role ID + Secret ID) → Policy → Secret</code></pre>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_what_is_coming_next">What is Coming Next?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In Part 8, we will explore secrets engines, like:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>KV (Key-Value) for static secrets</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In upcoming parts, I will try to cover common practices for OpenBao operation and maintenance. If there is time and an opportunity to test other authentication methods, I will do so.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Proper authentication configuration is crucial for OpenBao security. Key takeaways:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Use <strong>Kubernetes auth</strong> for pods</p>
</li>
<li>
<p>Use <strong>LDAP/OIDC</strong> for human users (SSO)</p>
</li>
<li>
<p>Use <strong>AppRole</strong> for automation</p>
</li>
<li>
<p>Create <strong>specific policies</strong> with least privilege</p>
</li>
<li>
<p>Set <strong>appropriate TTLs</strong> for different use cases</p>
</li>
<li>
<p><strong>Enable audit logging</strong> for compliance</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org/docs/auth/kubernetes" rel="noopener" target="_blank">Kubernetes Auth Method</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/auth/jwt" rel="noopener" target="_blank">JWT/OIDC Auth Method</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/auth/ldap" rel="noopener" target="_blank">LDAP Auth Method</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/auth/approle" rel="noopener" target="_blank">AppRole Auth Method</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/concepts/policies" rel="noopener" target="_blank">Policies Documentation</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - Initialisation, Unsealing, and Auto-Unseal - Part 6</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-03-05-openbao-part-6-auto-unsealing/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-03-05-openbao-part-6-auto-unsealing/</guid><pubDate>Thu, 05 Mar 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><category>GitOps</category><description>Configuring OpenBao for automatic unsealing with a Key Management Service, static key, or transit seal; manual and GitOps-friendly approaches</description><content:encoded><![CDATA[<div class="paragraph">
<p>After deploying OpenBao via GitOps (<a href="/openshift-platform/security/secrets-management/openbao/2026-02-20-openbao-part-5-gitops-deployment/">Part 5</a>), OpenBao must be initialised and then unsealed before it becomes functional. You usually do not want to do this unsealing manually, since this is not scalable especially in bigger, productive environments. This article explains how to handle initialisation and unsealing, and possible options to configure an <strong>auto-unseal</strong> process so that OpenBao unseals itself on every restart without manual key entry.</p>
</div>
<div class="sect1">
<h2 id="_what_is_happening">What is happening?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>OpenBao starts in a <strong>sealed</strong> state. You must:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Initialise (once): run <code>bao operator init</code> to generate unseal keys (or recovery keys when using auto-unseal).</p>
</li>
<li>
<p>Unseal (after each restart): provide a threshold of unseal keys so each node can decrypt the root key. In the previous articles, we used a threshold of 3 (out of 5). This means that you need to run <strong>bao operator unseal</strong> three times with different keys on every node after every start before the service becomes available.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Unseal workflow (assuming a threshold of 3 and 5 nodes and initialisation already happened):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code center"="" class="language-mermaid {align=" data-lang="mermaid {align=" hljs"="" zoom="true" }="" }"="">---
title: &#34;Unseal Workflow&#34;
config:
  theme: &#39;dark&#39;
---
flowchart LR
  A[&#34;openbao-0 starts → 3× unseal using different keys&#34;]
  A --&gt; B[&#34;openbao-1 starts → 3× unseal using different keys&#34;]
  B --&gt; C[&#34;openbao-2 starts → 3× unseal using different keys&#34;]
  C --&gt; D[OpenBao is ready]</code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
This is a chicken-egg problem: you need to start somewhere, but you cannot start without the keys.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Manual unsealing does not scale very well and for production, <strong>auto-unseal</strong> is recommended.</p>
</div>
<div class="paragraph">
<p>This article covers:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Practical approaches to initialisation and unsealing (manual, Jobs, init containers).</p>
</li>
<li>
<p>Potential auto-unseal options: with AWS KMS, static key, and transit seal.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_handling_initialisation_and_unsealing">Handling Initialisation and Unsealing</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The challenge with GitOps is that initialisation and unsealing are one-off or stateful operations. Below are several approaches. The problem is always the same: where do you start? You must have the unseal keys available to start the process. Do you keep them locally, do you keep them in a Kubernetes Secret, do you use an external Key Management System (KMS)? The most robust for production in my opinion is auto-unseal using a KMS (see <a href="#_approach_3_auto_unseal_with_key_management_service_kms_recommended_for_production">Approach 3: Auto-unseal with Key Management Service KMS (recommended for production)</a> and the following sections). It uses an external Key Management System (KMS) to store the keys. This way, the keys are not stored in the cluster and are not exposed to the risk of being compromised.</p>
</div>
<div class="paragraph">
<p>Let’s have a look at the different options.</p>
</div>
<hr/>
<div class="sect2">
<h3 id="_approach_1_manual_initialisation_simplest">Approach 1: Manual Initialisation (simplest)</h3>
<div class="paragraph">
<p>While manual initialisation and unsealing is the simplest approach, it is not recommended for production. Still, I would like to mention it here for completeness and at least provide a simple for loop to unseal the OpenBao service (on Kubernetes/OpenShift).</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Manual unsealing is still a valid option when you have a small cluster and assume that it is not required often.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>After Argo CD deploys OpenBao, the first pod, openbao-0, will not become ready until it is initialised and unsealed. Once done, the next pod, openbao-1, will try to start and wait until it is unsealed, and then the third pod, and so on.</p>
</div>
<div class="paragraph">
<p>The following, simplified script will go through the pods and unseal them one by one. It initialises the first pod and stores the unseal keys in the file <strong>openbao-init.json</strong> locally on your machine. From there it takes three different keys and unseals the OpenBao service.
Since it takes a while until other pods are pulling the image and starting, we will use a sleep timer of 30 seconds between each pod. This may or may not be enough depending on your network and cluster speed. As said, this is a very simplified script:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The CLI tool <strong>oc</strong> can be replaced by <strong>kubectl</strong> in case you are using a different cluster. In addition, you will need the jq command line tool to parse the JSON file.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
If your OpenBao was initialised previously, you can remove the first three commands and start with the unseal commands.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Initialise the first pod, assuming the Pod openbao-0 is already running.
# You can skip this if OpenBao was initialised previously.
echo &#34;Initialising OpenBao on openbao-0 (keys will be saved to openbao-init.json)...&#34;
oc exec -it openbao-0 -n openbao -- bao operator init \
  -key-shares=5 -key-threshold=3 -format=json &gt; openbao-init.json <i class="conum" data-value="1"></i><b>(1)</b>
echo &#34;Init complete. Unseal keys and root token are in openbao-init.json.&#34;

# Unseal each pod (three times each with different keys)
echo &#34;Unsealing pods openbao-0, openbao-1, openbao-2 (3 key steps each)...&#34;
for i in 0 1 2; do
  sleep_timer=30
  SLEEPER_TMP=1

  echo &#34;Unsealing openbao-$i...&#34;
  for j in 1 2 3; do <i class="conum" data-value="2"></i><b>(2)</b>
    KEY=$(cat openbao-init.json | jq -r &#34;.unseal_keys_b64[$((j-1))]&#34;)
    oc exec -it openbao-$i -n openbao -- bao operator unseal $KEY
  done

  echo &#34;openbao-$i unsealed. Waiting ${sleep_timer}s for next pod to be ready...&#34;

  while [[ $SLEEPER_TMP -le &#34;$sleep_timer&#34; ]]; do <i class="conum" data-value="3"></i><b>(3)</b>
    if (( SLEEPER_TMP % 10 == 0 )); then
      echo -n &#34;$SLEEPER_TMP&#34;
    else
      echo -n &#34;.&#34;
    fi
    sleep 1
    SLEEPER_TMP=$((SLEEPER_TMP + 1))
  done

  echo &#34;&#34;

done

echo &#34;All pods unsealed. Store init data securely (e.g. in a password manager).&#34;
# Store init data securely (e.g. in a password manager)</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Initialise the first pod, assuming the Pod openbao-0 is already running. This will store the keys (including the root token) in the file <strong>openbao-init.json</strong>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Unseal each pod (three times each with different keys). The keys are taken from the <strong>openbao-init.json</strong> file.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Wait 30 seconds between each pod to give the other pods time to start and pull the image …​ super-fancy sleep timer.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
The unseal keys as well as the root token are stored in the <strong>openbao-init.json</strong> file. This file is stored locally on your machine. Make sure to store it securely and do not share it with anyone.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
<div class="sect2">
<h3 id="_approach_2_kubernetes_job_for_initialisation">Approach 2: Kubernetes Job for initialisation</h3>
<div class="paragraph">
<p>A Job can run after OpenBao is deployed, initialise it if needed, and store the init output (unseal keys and root token) in a Kubernetes Secret. You can then unseal manually or with a second Job that reads from that Secret. This section assumes the init output is stored in a Kubernetes Secret and explains how to create that Secret from the Job and how to use it.</p>
</div>
<div class="sect3">
<h4 id="_how_the_secret_is_created">How the Secret is created</h4>
<div class="paragraph">
<p>The init Job runs <code>bao operator init</code> and then creates the Secret using <code>oc</code> (or <code>kubectl</code>). The Secret name and key used here are <code>openbao-init-data</code> and <code>init.json</code> (the file contains the JSON output of <code>bao operator init</code>, including <code>unseal_keys_b64</code> and <code>root_token</code>). One advantage of this approach is that you can integrate it into your GitOps pipeline. However, we can argue whether it is a good idea to store the unseal keys and the root token as a Secret in the same cluster where OpenBao is running.</p>
</div>
<div class="paragraph">
<p><strong>Example structure of <code>init.json</code></strong>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-json hljs" data-lang="json">{
  &#34;unseal_keys_b64&#34;: [
    &#34;key1&#34;,
    &#34;key2&#34;,
    &#34;key3&#34;,
    &#34;key4&#34;,
    &#34;key5&#34;
  ],
  &#34;unseal_keys_hex&#34;: [
    &#34;hex1&#34;,
    &#34;hex2&#34;,
    &#34;hex3&#34;,
    &#34;hex4&#34;,
    &#34;hex5&#34;
  ],
  &#34;unseal_shares&#34;: 5,
  &#34;unseal_threshold&#34;: 3,
  &#34;recovery_keys_b64&#34;: null,
  &#34;recovery_keys_hex&#34;: null,
  &#34;recovery_keys_shares&#34;: 0,
  &#34;recovery_keys_threshold&#34;: 0,
  &#34;root_token&#34;: &#34;root.token&#34;
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>You need at least <code>unseal_threshold</code> keys (e.g. 3) from <code>unseal_keys_b64</code> to unseal each node. Store this file securely; anyone with access can unseal OpenBao and the <code>root_token</code> has full admin access.</p>
</div>
</div>
<div class="sect3">
<h4 id="_rbac_configuration">RBAC Configuration</h4>
<div class="paragraph">
<p>The Job’s service account (<code>openbao-init</code>) must be allowed to create (and optionally get/update) Secrets in the <code>openbao</code> namespace. Create a Role and RoleBinding:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: v1
kind: ServiceAccount
metadata:
  name: openbao-init <i class="conum" data-value="1"></i><b>(1)</b>
  namespace: openbao
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: openbao-init-secret-writer
  namespace: openbao
rules: <i class="conum" data-value="2"></i><b>(2)</b>
  - apiGroups: [&#34;&#34;]
    resources: [&#34;secrets&#34;]
    verbs: [&#34;create&#34;, &#34;get&#34;, &#34;update&#34;, &#34;patch&#34;]
  - apiGroups: [&#34;&#34;] <i class="conum" data-value="3"></i><b>(3)</b>
    resources: [&#34;pods&#34;]
    verbs: [&#34;get&#34;, &#34;list&#34;]
  - apiGroups: [&#34;&#34;] <i class="conum" data-value="4"></i><b>(4)</b>
    resources: [&#34;pods/exec&#34;]
    verbs: [&#34;create&#34;]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding <i class="conum" data-value="5"></i><b>(5)</b>
metadata:
  name: openbao-init-secret-writer
  namespace: openbao
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: openbao-init-secret-writer
subjects:
  - kind: ServiceAccount
    name: openbao-init
    namespace: openbao</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The ServiceAccount is used by the Job(s) to create the Secret and unseal the OpenBao pods.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The Role is used by the Job to create the Secret. The rules might be extended to include the permission to execute into the pods to unseal the OpenBao service (see below).</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Permissions to get and list the Pods, required for the unseal process later</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Permissions to execute into the Pods, required for the unseal process later</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The RoleBinding is used by the Job to create the Secret.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The Job must also be able to reach the OpenBao API (e.g. <code>openbao.openbao.svc:8200</code>). This is usually possible when running in the same namespace as the OpenBao service.</p>
</div>
<div class="paragraph">
<p>The example below shows a working Job manifest that will perform the initialisation and the creation of the Secret in the <code>openbao</code> namespace. The manifest is already prepared for Argo CD with useful annotations.
It runs an init container to initialise the OpenBao service and a main container to create the Secret. The init container writes (using the OpenBao CLI) the init.json file to a shared volume and the main container (using the kubectl command) creates the Secret from that file.
In addition, the Secret containing the CA certificate is mounted as a volume and the BAO_CACERT environment variable is set to the path of the CA certificate.</p>
</div>
</div>
<div class="sect3">
<h4 id="_init_job_that_creates_the_secret">Init Job that creates the Secret</h4>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: batch/v1
kind: Job
metadata:
  name: openbao-init
  namespace: openbao
  annotations: <i class="conum" data-value="1"></i><b>(1)</b>
    argocd.argoproj.io/sync-wave: &#34;30&#34;
    argocd.argoproj.io/hook: PostSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
  template:
    spec:
      serviceAccountName: openbao-init <i class="conum" data-value="2"></i><b>(2)</b>
      initContainers: <i class="conum" data-value="3"></i><b>(3)</b>
        - name: openbao-init
          image: ghcr.io/openbao/openbao:latest
          command: <i class="conum" data-value="4"></i><b>(4)</b>
            - /bin/sh
            - -c
            - |
              if [ -f /etc/openbao-ca/ca.crt ]; then
                export BAO_CACERT=/etc/openbao-ca/ca.crt
                export BAO_ADDR=https://openbao:8200
                echo &#34;Using TLS CA from /etc/openbao-ca/ca.crt&#34;
              else
                export BAO_ADDR=http://openbao:8200
                echo &#34;Using plain HTTP&#34;
              fi

              until bao status 2&gt;&amp;1 | grep -q &#34;Initialized&#34;; do
                echo &#34;Waiting for OpenBao...&#34;
                sleep 5
              done

              if bao status | grep -q &#34;Initialized.*false&#34;; then
                echo &#34;Initialising OpenBao...&#34;
                bao operator init -key-shares=5 -key-threshold=3 \
                  -format=json &gt; /shared/init.json
                echo &#34;Init complete; init.json written to shared volume.&#34;
              else
                echo &#34;OpenBao already initialised (skipping init).&#34;
              fi
          volumeMounts:
            - name: openbao-ca
              mountPath: /etc/openbao-ca
              readOnly: true
            - name: shared
              mountPath: /shared
      containers: <i class="conum" data-value="5"></i><b>(5)</b>
        - name: create-secret
          image: bitnami/kubectl:latest
          command:
            - /bin/sh
            - -c
            - |
              if [ -f /shared/init.json ]; then
                echo &#34;Creating Secret openbao-init-data from init.json...&#34;
                kubectl create secret generic openbao-init-data \
                  --from-file=init.json=/shared/init.json \
                  -n openbao --dry-run=client -o yaml | kubectl apply -f -
                echo &#34;Initialisation complete!&#34;
              else
                echo &#34;No init.json (OpenBao already initialised or init skipped).&#34;
              fi
          volumeMounts:
            - name: shared
              mountPath: /shared
              readOnly: true
      volumes:
        - name: openbao-ca
          secret:
            secretName: openbao-ca-secret
            optional: true
        - name: shared <i class="conum" data-value="6"></i><b>(6)</b>
          emptyDir: {}
      restartPolicy: Never
  backoffLimit: 3</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The annotations are used by Argo CD to trigger the Job after the OpenBao deployment.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The ServiceAccount is used by the Job to initialise the OpenBao service.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The init container runs the OpenBao CLI (wait for API, then operator init) and writes init.json to a shared volume.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The command is used to initialise the OpenBao service.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The main container runs kubectl to create the Secret from that file. This avoids needing a single image that bundles both <code>bao</code> and <code>kubectl</code>.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The shared volume is used to store the init.json file.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
As a result the secret <code>openbao-init-data</code> is created in the <code>openbao</code> namespace. It contains the unseal keys and the root token.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect3">
<h4 id="_using_the_secret_in_a_job_unseal">Using the Secret in a Job (unseal)</h4>
<div class="paragraph">
<p>A second Job can use the Secret <code>openbao-init-data</code> that was created by the init Job to unseal each OpenBao pod. A lot is happening here:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The init container extracts the unseal keys from the Secret using <code>jq</code> and writes them to a shared volume.</p>
</li>
<li>
<p>The main container is reading the unseal keys from the shared volume and unseals the first pod</p>
</li>
<li>
<p>Then the process is waiting for 30 seconds, to give the next pod time to pull the image and start</p>
</li>
<li>
<p>The process is repeated for the next pod and so on until all pods are unsealed.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>First of all, the unseal Job needs permission to <code>exec</code> into the OpenBao pods. Add a Role that grants the Job’s service account <code>create</code> on <code>pods/exec</code> in the <code>openbao</code> namespace.
To make it easier, we can extend the Role <code>openbao-init-secret-writer</code> that was created in the init Job.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
These rules were already applied with the configuration for the init Job, but we will repeat them here for completeness.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">rules: <i class="conum" data-value="1"></i><b>(1)</b>
  - apiGroups: [&#34;&#34;]
    resources: [&#34;pods&#34;]
    verbs: [&#34;get&#34;, &#34;list&#34;]
  - apiGroups: [&#34;&#34;]
    resources: [&#34;pods/exec&#34;]
    verbs: [&#34;create&#34;]</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The role <code>openbao-init-secret-writer</code> must be extended to include the permission to execute into the pods to unseal the OpenBao service.</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: batch/v1
kind: Job
metadata:
  name: openbao-unseal
  namespace: openbao
  annotations:
    argocd.argoproj.io/sync-wave: &#34;35&#34;
    argocd.argoproj.io/hook: PostSync
    argocd.argoproj.io/hook-delete-policy: HookSucceeded
spec:
  template:
    spec:
      serviceAccountName: openbao-init <i class="conum" data-value="1"></i><b>(1)</b>
      initContainers:
        - name: extract-keys
          image: quay.io/codefreshplugins/curl-jq
          command:
            - /bin/sh
            - -c
            - |
              if [ ! -f /secrets/init.json ]; then
                echo &#34;Secret not found; run init Job first.&#34;
                exit 1
              fi
              for i in 0 1 2; do
                jq -r &#34;.unseal_keys_b64[$i]&#34; /secrets/init.json | tr -d &#39;\n&#39; &gt; &#34;/shared/key$i&#34; <i class="conum" data-value="2"></i><b>(2)</b>
              done
              echo &#34;Unseal keys extracted to shared volume.&#34;
          volumeMounts:
            - name: init-secret
              mountPath: /secrets
              readOnly: true
            - name: shared
              mountPath: /shared
      containers: <i class="conum" data-value="3"></i><b>(3)</b>
        - name: unseal
          image: bitnami/kubectl:latest
          command: <i class="conum" data-value="4"></i><b>(4)</b>
            - /bin/sh
            - -c
            - |
              if [ -f /etc/openbao-ca/ca.crt ]; then
                export BAO_CACERT=/etc/openbao-ca/ca.crt
                export BAO_ADDR=https://openbao:8200
                echo &#34;Using TLS CA from /etc/openbao-ca/ca.crt&#34;
              else
                export BAO_ADDR=http://openbao:8200
                echo &#34;Using plain HTTP&#34;
              fi

              sleep_timer=30

              if [ ! -f /shared/key0 ]; then
                echo &#34;Keys not found; extract-keys init container may have failed.&#34;
                exit 1
              fi

              echo &#34;Unsealing pods openbao-0, openbao-1, openbao-2 (3 key steps each), ${sleep_timer}s delay between pods...&#34;
              for pod in openbao-0 openbao-1 openbao-2; do
                echo &#34;Unsealing $pod...&#34;
                for i in 0 1 2; do
                  key=$(cat &#34;/shared/key$i&#34; | tr -d &#39;\n&#39;)
                  kubectl exec -n openbao &#34;$pod&#34; -- sh -c &#39;bao operator unseal &#34;$1&#34;&#39; _ &#34;$key&#34; || true
                done
                echo &#34;$pod unsealed.&#34;
                if [ &#34;$pod&#34; != &#34;openbao-2&#34; ]; then
                  echo &#34;Waiting ${sleep_timer}s for next pod to be ready...&#34;
                  SLEEPER_TMP=1
                  while [ &#34;$SLEEPER_TMP&#34; -le &#34;$sleep_timer&#34; ]; do
                    if [ $(( SLEEPER_TMP % 10 )) -eq 0 ]; then
                      echo -n &#34;$SLEEPER_TMP&#34;
                    else
                      echo -n &#34;.&#34;
                    fi
                    sleep 1
                    SLEEPER_TMP=$(( SLEEPER_TMP + 1 ))
                  done
                  echo &#34;&#34;
                fi
              done
              echo &#34;Unseal complete.&#34;
          volumeMounts:
            - name: shared
              mountPath: /shared
              readOnly: true
            - name: openbao-ca
              mountPath: /etc/openbao-ca
              readOnly: true
      volumes: <i class="conum" data-value="5"></i><b>(5)</b>
        - name: init-secret
          secret:
            secretName: openbao-init-data
        - name: shared
          emptyDir: {}
        - name: openbao-ca
          secret:
            secretName: openbao-ca-secret
            optional: true
      restartPolicy: Never
  backoffLimit: 2</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The ServiceAccount is used by the Job to unseal the OpenBao pods. Here we are using the same ServiceAccount as the one used to initialise the OpenBao service.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The init container extracts unseal keys from init.json using jq and writes them to a shared volume.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The main container runs kubectl to exec into each OpenBao pod and run <code>bao operator unseal</code> (the OpenBao image is used inside the target pods).</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The command is used to unseal the OpenBao service.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The volumes that are mounted: init-secret (contains the unseal keys), shared (contains the extracted unseal keys, shared between containers), openbao-ca (contains the CA certificate).</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Both Jobs are using the same ServiceAccount and therefore the same RBAC rules. It is also possible to use a different ServiceAccount for the unseal Job.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Store init data securely. Keeping unseal keys in a cluster Secret is convenient but less secure than auto-unseal or an external secrets manager. Restrict access to the <code>openbao-init-data</code> Secret (e.g. RBAC and network policies) and consider rotating or moving keys to a more secure store after bootstrap.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
<div class="sect2">
<h3 id="_approach_3_auto_unseal_with_key_management_service_kms_recommended_for_production">Approach 3: Auto-unseal with Key Management Service KMS (recommended for production)</h3>
<div class="paragraph">
<p>Configure a KMS (e.g. AWS KMS, Azure Key Vault, GCP Cloud KMS, Transit etc.) so that OpenBao unseals itself on every restart. You initialise <strong>once</strong> and thereafter no manual unseal step is needed.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The rest of this article will mention the different options. However, I can only demonstrate a real example using the AWS KMS option.
</td>
</tr>
</tbody></table>
</div>
<div class="sect3">
<h4 id="_auto_unseal_options_overview">Auto-unseal options overview</h4>
<div class="paragraph">
<p>Without auto-unseal, you must run <code>bao operator unseal</code> with a threshold of keys after each restart. With auto-unseal, OpenBao uses a seal backend to protect the root key and unseals itself on startup.</p>
</div>
<div class="paragraph">
<p>Supported options:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;"/>
<col style="width: 25%;"/>
<col style="width: 50%;"/>
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Option</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Use case</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Notes</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">1. AWS KMS</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">AWS (EKS, OpenShift on AWS)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">IRSA or IAM user; no keys in cluster with IRSA.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">2. Azure Key Vault</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Azure (AKS, OpenShift on Azure)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Service principal or managed identity.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">3. Google Cloud KMS</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">GCP (GKE)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Service account key or Workload Identity.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">5. Transit</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Existing Vault/OpenBao as root of trust; or a <strong>dedicated seal-only OpenBao</strong> that exists only to unseal production</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">External transit engine; token in a Secret.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="_why_use_openbao_when_the_seal_is_in_kms_why_not_keep_all_secrets_in_kms_and_skip_openbao">Why use OpenBao when the seal is in KMS? Why not keep all secrets in KMS and skip OpenBao?</h4>
<div class="paragraph">
<p>When using a cloud KMS (or Key Vault) for auto-unseal, a natural question is: why not store and retrieve <strong>all</strong> secrets from the KMS and run without OpenBao at all? OpenBao remains useful for operators and applications for several reasons:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>KMS is for keys, not a full secrets platform.</strong> AWS KMS, Azure Key Vault keys, and GCP Cloud KMS are built to encrypt and decrypt small blobs (e.g. data encryption keys, or OpenBao’s seal blob). They are not a general-purpose secrets store with versioning, path-based access, dynamic credentials, and per-request audit. OpenBao provides that layer: applications request secrets by path, get short-lived tokens, and you get a single place to define who can read what.</p>
</li>
<li>
<p><strong>Dynamic secrets.</strong> OpenBao can generate short-lived credentials on demand (e.g. database users, cloud IAM roles, PKI certificates). The KMS does not create or rotate such credentials; it only holds keys. If you need “give this pod a DB password that expires in 1 hour,” that is OpenBao’s domain, not the KMS.</p>
</li>
<li>
<p><strong>Fine-grained, identity-aware access.</strong> OpenBao supports auth methods (Kubernetes, OIDC, AppRole, LDAP) and path-based policies. You can say “this service account may read only <code>secret/data/myapp/*</code>.” The KMS has IAM or Key Vault RBAC, but not the same model of “one API, many identities, many paths” that applications and operators use day to day.</p>
</li>
<li>
<p><strong>Audit and compliance.</strong> OpenBao logs every secret read and write with identity and path. That gives a clear audit trail of who accessed which secret and when. KMS audit logs key usage, which is different from “which application read which secret at what time” in a unified way.</p>
</li>
<li>
<p><strong>Abstraction and portability.</strong> Applications talk to OpenBao’s API. You can move the seal or the storage backend (or even the cloud) without changing how applications request secrets. If you put everything directly in a cloud KMS, you tie every app to that vendor’s API and limits.</p>
</li>
<li>
<p><strong>Encryption as a service (Transit).</strong> OpenBao’s Transit secrets engine lets applications encrypt data with a key without ever seeing the key—useful for application-level encryption and key rotation. KMS can do something similar, but OpenBao integrates that with the same auth and audit as the rest of your secrets.</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
In short: the KMS is the <strong>root of trust</strong> for the seal (so OpenBao can unseal itself). OpenBao is the <strong>secrets management platform</strong> that applications and operators use for storing, retrieving, generating, and auditing secrets. Both layers complement each other.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>General flow (same for all options):</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Set up the seal backend (KMS key, Key Vault, static key, or transit server).</p>
</li>
<li>
<p>Add the appropriate <code>seal &#34;…​&#34;</code> stanza to OpenBao configuration (e.g. in Helm <code>server.ha.raft.config</code>).</p>
</li>
<li>
<p>Deploy OpenBao; pods start and remain sealed until initialised.</p>
</li>
<li>
<p>Run one-time initialisation: <code>bao operator init -recovery-shares=5 -recovery-threshold=3</code>.</p>
</li>
<li>
<p>From then on, restarts are automatically unsealed.</p>
</li>
</ol>
</div>
</div>
<div class="sect3">
<h4 id="_option_aws_kms">Option: AWS KMS</h4>
<div class="paragraph">
<p>Best for: EKS, OpenShift on AWS (ROSA), or any Kubernetes on AWS.</p>
</div>
<div class="sect4">
<h5 id="_create_a_kms_key">Create a KMS key</h5>
<div class="paragraph">
<p>Create a <strong>symmetric</strong> KMS key used only for the OpenBao seal (do not use for application data).</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>AWS WebUI:</strong></p>
<div class="ulist">
<ul>
<li>
<p>search for: KMS → Create key → Symmetric, Encrypt/Decrypt</p>
</li>
<li>
<p>Optionally set an alias (e.g. <code>openbao-unseal</code>).</p>
</li>
<li>
<p>OPTIONAL: Define key administrative permissions</p>
</li>
<li>
<p>OPTIONAL: Define key usage permissions</p>
</li>
<li>
<p>Edit key policy</p>
</li>
</ul>
</div>
</li>
<li>
<p><strong>AWS CLI:</strong> (requires the AWS CLI to be installed and configured)</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">aws kms create-key \
  --description &#34;OpenBao auto-unseal key&#34; \
  --key-usage ENCRYPT_DECRYPT

aws kms create-alias \
  --alias-name openbao-unseal \
  --target-key-id &lt;key-id-from-above&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Note the <strong>Key ID</strong> or <strong>Alias</strong> and the <strong>region</strong> (e.g. <code>us-west-1</code>) from the output of the command.</p>
</div>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="_key_policy_for_openbao">Key policy for OpenBao</h5>
<div class="paragraph">
<p>The OpenBao process needs permission to use the key. Create an IAM policy. In the UI you can configure this directly when creating the key. When using the CLI, create a <code>policy.json</code> file with the following content:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-json hljs" data-lang="json">{
  &#34;Version&#34;: &#34;2012-10-17&#34;,
  &#34;Statement&#34;: [
    {
      &#34;Effect&#34;: &#34;Allow&#34;,
      &#34;Action&#34;: [
        &#34;kms:Encrypt&#34;,
        &#34;kms:Decrypt&#34;,
        &#34;kms:DescribeKey&#34;
      ],
      &#34;Resource&#34;: &#34;arn:aws:kms:&lt;REGION&gt;:&lt;ACCOUNT_ID&gt;:key/&lt;KEY_ID&gt;&#34; <i class="conum" data-value="1"></i><b>(1)</b>
    }
  ]
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Replace <code>&lt;REGION&gt;</code>, <code>&lt;ACCOUNT_ID&gt;</code>, and <code>&lt;KEY_ID&gt;</code> with your values (or use the key ARN).</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect4">
<h5 id="_create_an_iam_user_for_the_seal">Create an IAM user for the seal</h5>
<div class="paragraph">
<p>When using static credentials (e.g. on OpenShift or when IRSA is not available), create a dedicated IAM user that has permission only to use the KMS key above. Use that user’s access keys in the Kubernetes Secret.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>AWS WebUI:</strong></p>
<div class="ulist">
<ul>
<li>
<p>search for: IAM → Users → Create user</p>
</li>
<li>
<p>User name: e.g. <code>openbao-seal</code></p>
</li>
<li>
<p>DO NOT select &#34;Provide user access to the AWS Management Console&#34; (programmatic access only)</p>
</li>
<li>
<p>Create user</p>
</li>
<li>
<p>Open the created user → Permissions → Add permissions → Create inline policy (or Attach policies → Create policy)</p>
</li>
<li>
<p>In the policy editor, choose JSON and paste the policy from <a href="#_key_policy_for_openbao">Key policy for OpenBao</a>, replacing <code>&lt;REGION&gt;</code>, <code>&lt;ACCOUNT_ID&gt;</code>, and <code>&lt;KEY_ID&gt;</code> with your KMS key ARN or alias</p>
</li>
<li>
<p>Name the policy (e.g. <code>OpenBaoSealKMS</code>) and attach it to the user</p>
</li>
<li>
<p>Security credentials → Create access key → Application running outside AWS (or &#34;Third-party service&#34;) → Create access key</p>
</li>
<li>
<p>Save the Access key ID and Secret access key; you will put them in the Kubernetes Secret <code>openbao-aws-credentials</code>.</p>
</li>
</ul>
</div>
</li>
<li>
<p><strong>AWS CLI:</strong> (requires the AWS CLI to be installed and configured)</p>
<div class="paragraph">
<p>Create a policy file (e.g. <code>openbao-seal-policy.json</code>) with the same JSON as in <a href="#_key_policy_for_openbao">Key policy for OpenBao</a>, then create the user, attach the policy, and create access keys:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Replace REGION, ACCOUNT_ID, and KEY_ID in the policy (or use alias: arn:aws:kms:REGION:ACCOUNT_ID:alias/openbao-unseal)
aws iam create-policy \
  --policy-name OpenBaoSealKMS \
  --policy-document file://openbao-seal-policy.json

aws iam create-user --user-name openbao-seal

aws iam attach-user-policy \
  --user-name openbao-seal \
  --policy-arn arn:aws:iam::ACCOUNT_ID:policy/OpenBaoSealKMS

aws iam create-access-key --user-name openbao-seal</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The last command returns <code>AccessKeyId</code> and <code>SecretAccessKey</code>; store them in the Secret <code>openbao-aws-credentials</code> with key <code>AWS_REGION</code> set to your region (e.g. <code>us-west-1</code>).
</td>
</tr>
</tbody></table>
</div>
</li>
</ul>
</div>
</div>
<div class="sect4">
<h5 id="_create_the_secret">Create the Secret</h5>
<div class="paragraph">
<p>Create the Secret <code>openbao-aws-credentials</code> in the <code>openbao</code> namespace. It contains the access key, secret access key, and region.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: v1
kind: Secret
metadata:
  name: openbao-aws-credentials
  namespace: openbao
type: Opaque
stringData: <i class="conum" data-value="1"></i><b>(1)</b>
  AWS_ACCESS_KEY_ID: &lt;your-access-key&gt;
  AWS_SECRET_ACCESS_KEY: &lt;your-secret-key&gt;
  AWS_REGION: &lt;your-region&gt;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Replace <code>&lt;your-access-key&gt;</code>, <code>&lt;your-secret-key&gt;</code>, and <code>&lt;your-region&gt;</code> with the values from the previous steps.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect4">
<h5 id="_helm_argo_cd_configuration_aws">Helm / Argo CD configuration (AWS)</h5>
<div class="paragraph">
<p>Add the <code>seal &#34;awskms&#34;</code> block inside the same HCL config that contains <code>listener</code>, <code>storage &#34;raft&#34;</code>. In Helm values this is typically under <code>openbao.server.ha.raft.config</code>.</p>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Be sure to update the region and key ID.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The values file we used for Argo CD can be found at: <a href="https://github.com/tjungbauer/openshift-clusterconfig-gitops/blob/main/clusters/management-cluster/openbao/values.yaml" rel="noopener" target="_blank">OpenBao Argo CD values file</a></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">openbao:
  server:

    extraSecretEnvironmentVars: <i class="conum" data-value="1"></i><b>(1)</b>
      - envName: AWS_ACCESS_KEY_ID
        secretName: openbao-aws-credentials
        secretKey: AWS_ACCESS_KEY_ID
      - envName: AWS_SECRET_ACCESS_KEY
        secretName: openbao-aws-credentials
        secretKey: AWS_SECRET_ACCESS_KEY
      - envName: AWS_REGION
        secretName: openbao-aws-credentials
        secretKey: AWS_REGION

    ha:
      raft:
        config: |
          ui = true

          seal &#34;awskms&#34; { <i class="conum" data-value="2"></i><b>(2)</b>
            region     = &#34;us-east-1&#34;
            kms_key_id = &#34;alias/openbao-unseal&#34;
          }

          listener &#34;tcp&#34; {
            tls_disable = 0
            address     = &#34;[::]:8200&#34;
            cluster_address = &#34;[::]:8201&#34;
            tls_cert_file   = &#34;/openbao/tls/openbao-server-tls/tls.crt&#34;
            tls_key_file    = &#34;/openbao/tls/openbao-server-tls/tls.key&#34;
            tls_min_version = &#34;tls12&#34;
          }

          storage &#34;raft&#34; {
            path = &#34;/openbao/data&#34;
          }

          service_registration &#34;kubernetes&#34; {}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>If you use static credentials (e.g. for OpenShift), inject them via a Secret.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>This must be added. Be sure to update your region and key ID.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
The <code>seal &#34;awskms&#34;</code> block alone is not enough. OpenBao must have AWS credentials available at runtime. If you see an error such as <code>NoCredentialProviders: no valid providers in chain</code> or <code>error fetching AWS KMS wrapping key information</code>, the pod has no credentials. You must either inject static credentials from a Secret (see below) or use IRSA so the pod can assume an IAM role.
</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_approach_4_init_container_with_external_secret_store">Approach 4: Init container with external secret store</h3>
<div class="paragraph">
<p>Another option is to use an init container that retrieves secrets from an external source. Two use cases can be considered here:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Shamir unseal:</strong> The init container fetches the unseal keys from an external secret manager and then runs <code>bao operator unseal</code> (or writes keys to a file used by a sidecar/unseal script). This is the classic “external secret store” idea (e.g. using AWS Secrets Manager, HashiCorp Vault, another Kubernetes cluster).</p>
</li>
<li>
<p><strong>Transit seal token:</strong> The init container fetches the <strong>token</strong> that production OpenBao uses to call the dedicated unseal service (see <a href="#_dedicated_unseal_service_seal_only_openbao">Dedicated unseal service (seal-only OpenBao)</a>). That token is written to a file or shared volume so the main OpenBao process can use it in <code>seal &#34;transit&#34;</code>. The token never lives in a Kubernetes Secret in Git or in plain YAML; it is fetched at pod start from the external store.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Below is a generic placeholder for the init container.</p>
</div>
<div class="sect3">
<h4 id="_option_init_container_example">Option: init Container example</h4>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The following options are generic and more theoretical. Unlike the other options, I could not test them in a real environment yet. This may be covered in a future article.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Generic placeholder (implement according to your secret store):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml"># Additional values for the Helm chart
server:
  extraInitContainers:
    - name: fetch-secrets
      image: registry.access.redhat.com/ubi9/ubi-minimal:latest
      command:
        - /bin/sh
        - -c
        - |
          # Fetch unseal keys OR transit token from external secret manager
          echo &#34;Waiting for OpenBao to be ready...&#34;
          sleep 30
          # Your fetch logic here (e.g. aws secretsmanager get-secret-value, vault kv get, curl to API) <i class="conum" data-value="1"></i><b>(1)</b>
      env:
        - name: EXTERNAL_SECRET_ENDPOINT <i class="conum" data-value="2"></i><b>(2)</b>
          value: &#34;https://your-external-secret-store.example.com&#34;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Replace with your fetch logic.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Replace with your external secret store endpoint.</td>
</tr>
</tbody></table>
</div>
<hr/>
</div>
<div class="sect3">
<h4 id="_option_transit_seal">Option: Transit seal</h4>
<div class="paragraph">
<p>When you already have a Vault or OpenBao cluster and want it to act as the root of trust (e.g. central Vault encrypts the seal key), you can use this option.</p>
</div>
<div class="paragraph">
<p>To prepare everything, you need to do the following:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Enable the <strong>Transit</strong> secrets engine on the external Vault/OpenBao and create a key (e.g. <code>openbao-unseal</code>).</p>
</li>
<li>
<p>Grant the token used by this OpenBao permission to encrypt/decrypt with that key.</p>
</li>
<li>
<p>Store the token in a Kubernetes Secret and inject via <code>extraSecretEnvironmentVars</code></p>
</li>
</ul>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Do not put the token in the config file.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The following HCL configuration is used to configure the OpenBao cluster to use the transit seal.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-hcl hljs" data-lang="hcl">seal &#34;transit&#34; {
  address         = &#34;https://external-vault.example.com:8200&#34;
  token           = &#34;s.xxx&#34;
  disable_renewal = &#34;false&#34;
  key_name        = &#34;openbao-unseal&#34;
  mount_path      = &#34;transit/&#34;
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>See the <a href="https://openbao.org/docs/configuration/seal/transit/" rel="noopener" target="_blank">OpenBao transit seal</a> documentation for further details.</p>
</div>
<div class="sect4">
<h5 id="_dedicated_unseal_service_seal_only_openbao">Dedicated unseal service (seal-only OpenBao)</h5>
<div class="paragraph">
<p>A common and recommended pattern is to run a <strong>separate, standalone OpenBao instance</strong> whose <strong>only</strong> role is to provide the seal for your production OpenBao. In other words: the external OpenBao holds the unseal keys—via its Transit secrets engine—and the production OpenBao cluster uses the transit seal to auto-unseal by calling that external instance. No application secrets or other workloads run on the dedicated instance; it exists solely to unseal the production OpenBao.</p>
</div>
<div class="paragraph">
<p><strong>Why use a dedicated unseal service?</strong></p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Separation of concerns:</strong> The root of trust for unsealing lives outside the production cluster. If the production OpenBao is compromised or rebuilt, the seal keys remain in the dedicated instance.</p>
</li>
<li>
<p><strong>Simpler operations:</strong> You unseal and manage only one small, locked-down OpenBao (the seal service). The production OpenBao unseals itself automatically via transit.</p>
</li>
<li>
<p><strong>No cloud KMS required:</strong> On-premise or air-gapped environments can use this pattern instead of AWS KMS, Azure Key Vault, or GCP Cloud KMS.</p>
</li>
<li>
<p><strong>Clear trust boundary:</strong> The dedicated instance can be hardened, network-isolated, and backed up independently.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p><strong>Architecture (high level):</strong></p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><strong>Dedicated unseal service:</strong> A standalone OpenBao (single node is often enough) with the Transit secrets engine enabled and a dedicated transit key (e.g. <code>production-openbao-unseal</code>). This instance is initialised and unsealed once; you keep its unseal keys and root token very secure. It does not store application secrets.</p>
</li>
<li>
<p><strong>Production OpenBao:</strong> Your HA OpenBao cluster (e.g. in Kubernetes) is configured with <code>seal &#34;transit&#34;</code> pointing at the dedicated service URL and a token that has permission only to use that transit key. On startup, each production node asks the dedicated OpenBao to decrypt its seal blob and thus unseals automatically.</p>
</li>
</ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_migration_from_shamir_to_auto_unseal">Migration from Shamir to auto-unseal</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You might wonder if you can migrate from Shamir to auto-unseal. The answer is yes, you can.</p>
</div>
<div class="paragraph">
<p>If OpenBao was previously initialised with <strong>Shamir</strong> unseal keys and you want to switch to any auto-unseal backend, you can do the following:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Plan a short maintenance window. Raft HA will tolerate one node at a time.</p>
</li>
<li>
<p>Add the appropriate <code>seal &#34;…​&#34;</code> block to the config and deploy (e.g. via Argo CD).</p>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Do NOT re-run init.
</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Unseal the <strong>leader</strong> with the existing Shamir unseal keys.</p>
</li>
<li>
<p>Run <strong>seal migration</strong> on the leader:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao operator unseal -migrate</code></pre>
</div>
</div>
</li>
<li>
<p>Restart the leader. It should auto-unseal via the new seal.</p>
</li>
<li>
<p>Update and restart standby nodes. They should auto-unseal as well.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org/docs/concepts/seal/" rel="noopener" target="_blank">OpenBao seal concepts</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/platform/k8s/" rel="noopener" target="_blank">OpenBao on Kubernetes</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/configuration/seal/awskms/" rel="noopener" target="_blank">AWS KMS seal</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/configuration/seal/azurekeyvault/" rel="noopener" target="_blank">Azure Key Vault seal</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/configuration/seal/gcpckms/" rel="noopener" target="_blank">Google Cloud KMS seal</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/configuration/seal/static/" rel="noopener" target="_blank">Static seal</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/configuration/seal/transit/" rel="noopener" target="_blank">Transit seal</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - GitOps Deployment with Argo CD - Part 5</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-20-openbao-part-5-gitops-deployment/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-20-openbao-part-5-gitops-deployment/</guid><pubDate>Fri, 20 Feb 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><category>GitOps</category><description>Deploying and managing OpenBao using GitOps principles with Argo CD for declarative, version-controlled secret management infrastructure</description><content:encoded><![CDATA[<div class="paragraph">
<p>Following the GitOps mantra &#34;If it is not in Git, it does not exist&#34;, this article demonstrates how to deploy and manage OpenBao using Argo CD. This approach provides version control, audit trails, and declarative management for your secret management infrastructure.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Deploying OpenBao via GitOps offers significant advantages:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Version Control</strong>: All configuration changes are tracked in Git</p>
</li>
<li>
<p><strong>Audit Trail</strong>: Who changed what, when, and why</p>
</li>
<li>
<p><strong>Declarative</strong>: Desired state is defined, not imperative commands</p>
</li>
<li>
<p><strong>Reproducible</strong>: Same deployment process across environments</p>
</li>
<li>
<p><strong>Self-healing</strong>: Argo CD ensures actual state matches desired state</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>However, there are challenges specific to secret management:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Initial unsealing requires manual intervention or automationxw</p>
</li>
<li>
<p>Root tokens and unseal keys must be handled carefully</p>
</li>
<li>
<p>Chicken-and-egg problem: How to store OpenBao secrets before OpenBao exists?</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This article will focus on the deployment of the applicaiotns for the OpenBao deployment. The problem with the automatic unsealing will be addressed in the next article.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before you begin, ensure you have:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenShift GitOps (Argo CD) installed and configured</p>
</li>
<li>
<p>A Git repository for your cluster configuration</p>
</li>
<li>
<p>Understanding of the App-of-Apps pattern (see <a href="/gitopscollection/2024-04-02-configure_app_of_apps/">Configure App-of-Apps</a>)</p>
</li>
<li>
<p>The official OpenBao Helm chart from <a href="/openshift-platform/security/secrets-management/openbao/2026-02-13-openbao-part-3-openshift-deployment/">Part 3</a></p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_the_wrapper_helm_chart">The (Wrapper) Helm Chart</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The official OpenBao Helm Chart works well for deploying OpenBao itself. However, additional settings such as certificates are not covered there. Therefore, I created a (wrapper) Helm Chart that includes the official OpenBao Helm Chart, a <a href="https://github.com/tjungbauer/helm-charts/tree/main/charts/cert-manager" rel="noopener" target="_blank">Cert-Manager Helm Chart</a> that I created a while ago, and allows you to add additional objects in the templates folder.</p>
</div>
<div class="paragraph">
<p>I will follow the same setup as discussed in <a href="/openshift-platform/security/secrets-management/openbao/2026-02-17-openbao-part-4-enabling-tls">Part 4</a>. This means:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Create Issuer for Cert-Manager</p>
</li>
<li>
<p>Create CA Certificate for OpenBao</p>
</li>
<li>
<p>Create Certificate for OpenBao Server</p>
</li>
<li>
<p>Create Certificate for OpenBao Agent Injector</p>
</li>
<li>
<p>Install OpenBao Helm Chart</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>However, there is <strong>one significant issue</strong> with this approach: we need the certificate details (especially the CA certificate) before we can install the OpenBao Helm Chart, since the certificate must be referenced in the values file. This is a chicken-and-egg problem—particularly if you use self-signed CA certificates.</p>
</div>
<div class="paragraph">
<p>Since you typically create the CA certificate first and only once (or have it already), a separate Application for the CA certificate is a good approach. Once this is synchronised, the OpenBao Application can be updated and deployed.</p>
</div>
<div class="paragraph">
<p>This means we will need two Helm Charts: one for the CA certificate and one for OpenBao itself.</p>
</div>
<div class="sect2">
<h3 id="_helm_chart_for_the_ca_certificate">Helm Chart for the CA Certificate</h3>
<div class="paragraph">
<p>Create a new Helm Chart for the CA certificate. This will use the <a href="https://github.com/tjungbauer/helm-charts/tree/main/charts/cert-manager" rel="noopener" target="_blank">Cert-Manager Helm Chart</a> as a dependency and will create the:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Issuer for Cert-Manager</p>
</li>
<li>
<p>Request the CA certificate from the Issuer</p>
</li>
<li>
<p>Create the <strong>openbao</strong> namespace</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The example I am using can be found at <a href="https://github.com/tjungbauer/openshift-clusterconfig-gitops/tree/main/clusters/management-cluster/openbao-ca-certificate" rel="noopener" target="_blank">GitOps openbao-ca-certificate</a>.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Please check the <a href="/gitopscollection/2023-12-28-gitops-repostructure/" rel="noopener" target="_blank">GitOps Repository Structure</a> and subsequent articles for more information on how to structure your Git repository.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>In the <strong>Chart.yaml</strong> file you can see two dependencies:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">dependencies:
  - name: tpl
    version: ~1.0.0
    repository: https://charts.stderr.at/
  - name: cert-manager
    version: ~2.0.3 <i class="conum" data-value="1"></i><b>(1)</b>
    repository: https://charts.stderr.at/
    condition: cert-manager.enabled</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The Cert-Manager Helm Chart version must be at least 2.0.3 to support the namespace parameter for the Issuer.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The <strong>tpl</strong> dependency is a library that contains templates for the namespace and other shared components (I keep this library in my <a href="/helm-charts/" rel="noopener" target="_blank">Helm Charts</a> repository). The <strong>cert-manager</strong> dependency is the Cert-Manager Helm Chart.</p>
</div>
<div class="paragraph">
<p>The <strong>values.yaml</strong> file below contains the configuration for the Cert-Manager:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
All settings that are passed to a subchart (cert-manager) must be prefixed with the name of the subchart. In this case, <code>cert-manager.</code>.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">namespace:
  create: true <i class="conum" data-value="1"></i><b>(1)</b>
  name: &#34;openbao&#34;
  description: &#34;OpenBao Namespace&#34;
  displayName: &#34;OpenBao Namespace&#34;
  additionalLabels:
    pod-security.kubernetes.io/audit: restricted
    pod-security.kubernetes.io/audit-version: latest
    pod-security.kubernetes.io/warn: restricted
    pod-security.kubernetes.io/warn-version: latest

cert-manager: <i class="conum" data-value="2"></i><b>(2)</b>
  enabled: true <i class="conum" data-value="3"></i><b>(3)</b>

  issuer:
      # Name of issuer
    - name: openbao-selfsigned <i class="conum" data-value="4"></i><b>(4)</b>

      # -- Syncwave to create this issuer
      syncwave: 5 <i class="conum" data-value="5"></i><b>(5)</b>

      # -- Type can be either ClusterIssuer or Issuer
      type: Issuer

      # -- Enable this issuer.
      # @default -- false
      enabled: true

      # -- Namespace for Issuer (ignored for ClusterIssuer). Defaults to the default namespace when not set.
      namespace: openbao <i class="conum" data-value="6"></i><b>(6)</b>

      # -- Create a selfSigned issuer. The SelfSigned issuer doesn&#39;t represent a certificate authority as such, but instead denotes that certificates will &#34;sign themselves&#34; using a given private key.
      selfSigned: true <i class="conum" data-value="7"></i><b>(7)</b>

  certificates: <i class="conum" data-value="8"></i><b>(8)</b>
    enabled: true

    # List of certificates
    certificate:
      - name: openbao-ca
        enabled: true
        namespace: openbao
        syncwave: &#34;10&#34;
        secretName: openbao-ca-secret

        duration: 87660h

        dnsNames:
          - openbao-ca

        privateKey:
          algorithm: ECDSA
          size: 256
          rotationPolicy: Always

        isCA: true

        # Reference to the issuer that shall be used.
        issuerRef:
          name: openbao-selfsigned
          kind: Issuer</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Create the <strong>openbao</strong> namespace with various settings.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Enable the Cert-Manager subchart. All settings below will be passed to the Cert-Manager subchart.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Enables Cert-Manager.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Name of the issuer.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Syncwave for this issuer; it must be lower than the syncwave of the certificate.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>Namespace for the issuer; supported since version 2.0.3 of the Cert-Manager Helm Chart.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>Creates a self-signed issuer.</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td>The certificate section and all the settings. Verify the <a href="/openshift-platform/security/secrets-management/openbao/2026-02-17-openbao-part-4-enabling-tls/#_step_1_certificate_authority_ca_for_openbao">Part 4</a> for more information.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
This chart creates the <strong>openbao</strong> namespace, which is required for the OpenBao deployment.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_helm_chart_for_the_openbao_deployment">Helm Chart for the OpenBao Deployment</h3>
<div class="paragraph">
<p>Create a new Helm Chart for the OpenBao deployment. This will use the official <a href="https://github.com/openbao/openbao-helm" rel="noopener" target="_blank">OpenBao Helm chart</a> and the <a href="https://github.com/tjungbauer/helm-charts/tree/main/charts/cert-manager" rel="noopener" target="_blank">Cert-Manager Helm Chart</a> as dependencies and will create the:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenBao deployment (including Route)</p>
</li>
<li>
<p>Issuer for the OpenBao server using the CA certificate</p>
</li>
<li>
<p>Required OpenBao certificates based on the CA certificate</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>I have added the full values.yaml file below. Please check the <a href="https://github.com/tjungbauer/openshift-clusterconfig-gitops/blob/main/clusters/management-cluster/openbao/values.yaml" rel="noopener" target="_blank">GitOps openbao/values.yaml</a> to fetch the full chart.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Besides the two certificates added here in the values.yaml file, I made two further changes: fullnameOverride and nameOverride are both set to <strong>openbao</strong>. This is good practice for setting the name of the deployment when using Argo CD.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
This values file contains the CA certificate in plain text. Whether that is acceptable is debatable—it is a public certificate, and here it is self-signed and used only in my demo environment.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml"># Full values.yaml file for the OpenBao deployment

########################################################
# Cert-Manager
########################################################
cert-manager:
  enabled: true

  issuer:
      # Name of issuer
    - name: openbao-ca-issuer <i class="conum" data-value="1"></i><b>(1)</b>

      # -- Syncwave to create this issuer
      syncwave: &#39;-1&#39;

      # -- Type can be either ClusterIssuer or Issuer
      type: Issuer

      # -- Enable this issuer.
      # @default -- false
      enabled: true

      # -- Namespace for Issuer (ignored for ClusterIssuer). Defaults to the default namespace when not set.
      namespace: openbao

      ca:
        secretName: openbao-ca-secret

  certificates:
    enabled: true

    # List of certificates
    certificate:
      ########################################################
      # OpenBao Server TLS Certificate
      ########################################################
      - name: openbao-server-tls <i class="conum" data-value="2"></i><b>(2)</b>
        enabled: true
        namespace: openbao
        syncwave: &#34;0&#34;
        secretName: openbao-server-tls

        duration: 8760h
        renewBefore: 720h

        dnsNames:
          - openbao.openbao.svc
          - openbao.apps.ocp.aws.ispworld.at # Route host (adjust to your domain)
          - openbao
          - openbao.openbao
          - openbao.openbao.svc
          - openbao.openbao.svc.cluster.local
          - openbao-internal
          - openbao-internal.openbao
          - openbao-internal.openbao.svc
          - openbao-internal.openbao.svc.cluster.local
          - openbao-0.openbao-internal
          - openbao-0.openbao-internal.openbao
          - openbao-0.openbao-internal.openbao.svc
          - openbao-0.openbao-internal.openbao.svc.cluster.local
          - openbao-1.openbao-internal
          - openbao-1.openbao-internal.openbao
          - openbao-1.openbao-internal.openbao.svc
          - openbao-2.openbao-internal
          - openbao-2.openbao-internal.openbao
          - openbao-2.openbao-internal.openbao.svc

        ipAddresses:
          - 127.0.0.1
          - &#34;::1&#34;

        # Reference to the issuer that shall be used.
        issuerRef:
          name: openbao-ca-issuer
          kind: Issuer

      ########################################################
      # Injector TLS Certificate
      ########################################################
      - name: injector-certificate <i class="conum" data-value="3"></i><b>(3)</b>
        enabled: true
        namespace: openbao
        syncwave: &#34;0&#34;
        secretName: injector-tls

        duration: 24h
        renewBefore: 144m

        dnsNames:
          - openbao-agent-injector-svc
          - openbao-agent-injector-svc.openbao
          - openbao-agent-injector-svc.openbao.svc
          - openbao-agent-injector-svc.openbao.svc.cluster.local

        # Reference to the issuer that shall be used.
        issuerRef:
          name: openbao-ca-issuer
          kind: Issuer

########################################################
# OpenBao Deployment
########################################################
openbao: <i class="conum" data-value="4"></i><b>(4)</b>
  # Override the full name of the deployment via Argo CD
  fullnameOverride: openbao
  nameOverride: openbao

  global:
    # Enable OpenShift-specific settings
    openshift: true

    # -- The namespace to deploy to. Defaults to the `helm` installation namespace.
    namespace: openbao

    # Required when TLS is enabled: tells the chart to use HTTPS for readiness/liveness
    # probes and for in-pod API_ADDR (127.0.0.1:8200). Otherwise you get &#34;client sent
    # an HTTP request to an HTTPS server&#34; from the probes.
    tlsDisable: false

  server:
    extraEnvironmentVars:
      BAO_CACERT: /openbao/tls/openbao-server-tls/ca.crt

    # High Availability configuration
    ha:
      enabled: true
      replicas: 3

      # Raft storage configuration
      raft:
        enabled: true
        setNodeId: true

        config: |
          ui = true

          listener &#34;tcp&#34; {
            tls_disable = 0
            address = &#34;[::]:8200&#34;
            cluster_address = &#34;[::]:8201&#34;
            tls_cert_file = &#34;/openbao/tls/openbao-server-tls/tls.crt&#34;
            tls_key_file  = &#34;/openbao/tls/openbao-server-tls/tls.key&#34;
            tls_min_version = &#34;tls12&#34;
            telemetry {
              unauthenticated_metrics_access = &#34;true&#34;
            }
          }

          storage &#34;raft&#34; {
            path = &#34;/openbao/data&#34;

            retry_join {
              leader_api_addr = &#34;https://openbao-0.openbao-internal:8200&#34;
              leader_tls_servername = &#34;openbao-0.openbao-internal&#34;
              leader_ca_cert_file = &#34;/openbao/tls/openbao-server-tls/ca.crt&#34;
            }
            retry_join {
              leader_api_addr = &#34;https://openbao-1.openbao-internal:8200&#34;
              leader_tls_servername = &#34;openbao-1.openbao-internal&#34;
              leader_ca_cert_file = &#34;/openbao/tls/openbao-server-tls/ca.crt&#34;
            }
            retry_join {
              leader_api_addr = &#34;https://openbao-2.openbao-internal:8200&#34;
              leader_tls_servername = &#34;openbao-2.openbao-internal&#34;
              leader_ca_cert_file = &#34;/openbao/tls/openbao-server-tls/ca.crt&#34;
            }
          }

          service_registration &#34;kubernetes&#34; {}

          telemetry {
            prometheus_retention_time = &#34;30s&#34;
            disable_hostname = true
          }

    route:
      enabled: true
      host: openbao.apps.ocp.aws.ispworld.at
      tls:
        # Route terminates client TLS; backend can use reencrypt or passthrough
        termination: reencrypt
        insecureEdgeTerminationPolicy: Redirect
        destinationCACertificate: |
          -----BEGIN CERTIFICATE-----
          MIIBWzCCAQCgAwIBAgIQNdbg4KIu9oi6dDClE8drmjAKBggqhkjOPQQDAjAAMB4X
          DTI2MDIxODA5NDIxNFoXDTM2MDIxODIxNDIxNFowADBZMBMGByqGSM49AgEGCCqG
          SM49AwEHA0IABIeYw35/kEHvyctLtOA5xMlyQNxUtXtfBbZMUfPh6AN5MFjIGuNS
          cn07a3EpSpfY6/3DaPpu+4wYNFlc+/qDNYajXDBaMA4GA1UdDwEB/wQEAwICpDAP
          BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQgyRk5Vv9K0VULcCgga5mRg4O9kTAY
          BgNVHREBAf8EDjAMggpvcGVuYmFvLWNhMAoGCCqGSM49BAMCA0kAMEYCIQCwQ7lZ
          Q0jzUjJFzpTGkQjU2+OB159LIQMSbSQ7dz8nVQIhAIDa7f87tjQxDxbJio+/vJx2
          awFaWnueGOOQpvwCcV/+
          -----END CERTIFICATE-----

    extraVolumes:
      - type: secret
        name: openbao-server-tls
        path: /openbao/tls
        readOnly: true

    extraVolumeMounts:
      - name: openbao-server-tls
        mountPath: /openbao/tls
        readOnly: true

    # Resource requests and limits
    resources:
      requests:
        memory: 256Mi
        cpu: 250m
      limits:
        memory: 1Gi
        cpu: 1000m

    # Persistent volume for data
    dataStorage:
      enabled: true
      size: 10Gi
      # storageClass: &#34;gp3-csi&#34;

  # Injector configuration
  injector:
    enabled: true
    replicas: 2  # HA for the injector too
    certs:
      secretName: injector-tls
      # For a private CA: set caBundle to the CA cert (PEM) so the Kubernetes API server trusts the injector webhook. E.g. oc get secret openbao-ca-secret -n openbao -o jsonpath=&#39;{.data.ca\.crt}&#39; | base64 -d
      caBundle:  &#34;LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJXekNDQVFDZ0F3SUJBZ0lRTmRiZzRLSXU5b2k2ZERDbEU4ZHJtakFLQmdncWhrak9QUVFEQWpBQU1CNFgKRFRJMk1ESXhPREE1TkRJeE5Gb1hEVE0yTURJeE9ESXhOREl4TkZvd0FEQlpNQk1HQnlxR1NNNDlBZ0VHQ0NxRwpTTTQ5QXdFSEEwSUFCSWVZdzM1L2tFSHZ5Y3RMdE9BNXhNbHlRTnhVdFh0ZkJiWk1VZlBoNkFONU1GaklHdU5TCmNuMDdhM0VwU3BmWTYvM0RhUHB1KzR3WU5GbGMrL3FETllhalhEQmFNQTRHQTFVZER3RUIvd1FFQXdJQ3BEQVAKQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlFneVJrNVZ2OUswVlVMY0NnZ2E1bVJnNE85a1RBWQpCZ05WSFJFQkFmOEVEakFNZ2dwdmNHVnVZbUZ2TFdOaE1Bb0dDQ3FHU000OUJBTUNBMGtBTUVZQ0lRQ3dRN2xaClEwanpVakpGenBUR2tRalUyK09CMTU5TElRTVNiU1E3ZHo4blZRSWhBSURhN2Y4N3RqUXhEeGJKaW8rL3ZKeDIKYXdGYVdudWVHT09RcHZ3Q2NWLysKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=&#34;
      certName: tls.crt
      keyName: tls.key

  # UI configuration
  ui:
    enabled: true</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Issuer for OpenBao. The syncwave is set to &#39;-1&#39; to create the issuer before the certificate request and the OpenBao deployment.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Certificate for the OpenBao server, with all DNS names and IP addresses used to reach it. The syncwave is set to &#39;0&#39; so the certificate is created after the issuer.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Certificate for the OpenBao Agent Injector, with all DNS names used to reach it. The syncwave is set to &#39;0&#39; so the certificate is created after the issuer.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>OpenBao deployment configuration; the two overrides fullnameOverride and nameOverride are both set to <strong>openbao</strong>. See <a href="/openshift-platform/security/secrets-management/openbao/2026-02-17-openbao-part-4-enabling-tls/#_step_5_helm_values_for_server_tls">Part 4</a> for more information.</td>
</tr>
</tbody></table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_creating_argo_cd_applications">Creating Argo CD Applications</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Whilst the Helm Charts are ready, we need to create the Argo CD Applications for the CA certificate and the OpenBao deployment.
If you read our blog carefully, you will notice that these Application resources are created automatically when I add something to the folder clusters/management-cluster :)
This is done by leveraging ApplicationSet resources and is fully described in the <a href="/gitopscollection/2023-12-28-gitops-repostructure/" rel="noopener" target="_blank">GitOps Repository Structure</a> and subsequent articles.</p>
</div>
<div class="paragraph">
<p>For the sake of simplicity, I will show the created Application resources below. The setup is the same for both; they simply target a different path in the Git repository.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml"># Full Application resource for the OpenBao CA Certificate
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: in-cluster-openbao-ca-certificate
  namespace: openshift-gitops
spec:
  destination:
    name: in-cluster <i class="conum" data-value="1"></i><b>(1)</b>
    namespace: default <i class="conum" data-value="2"></i><b>(2)</b>
  info:
    - name: Description
      value: ApplicationSet that Deploys on Management Cluster Configuration (using Git Generator)
  project: in-cluster <i class="conum" data-value="3"></i><b>(3)</b>
  source:
    path: clusters/management-cluster/openbao-ca-certificate <i class="conum" data-value="4"></i><b>(4)</b>
    repoURL: &#39;https://github.com/tjungbauer/openshift-clusterconfig-gitops&#39; <i class="conum" data-value="5"></i><b>(5)</b>
    targetRevision: main
  syncPolicy:
    retry:
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 3m
      limit: 5
---
# Full Application resource for the OpenBao deployment
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: in-cluster-openbao
  namespace: openshift-gitops
spec:
  destination:
    name: in-cluster <i class="conum" data-value="1"></i><b>(1)</b>
    namespace: openbao <i class="conum" data-value="2"></i><b>(2)</b>
  info:
    - name: Description
      value: ApplicationSet that Deploys on Management Cluster Configuration (using Git Generator)
  project: in-cluster <i class="conum" data-value="3"></i><b>(3)</b>
  source:
    path: clusters/management-cluster/openbao <i class="conum" data-value="6"></i><b>(6)</b>
    repoURL: &#39;https://github.com/tjungbauer/openshift-clusterconfig-gitops&#39; <i class="conum" data-value="5"></i><b>(5)</b>
    targetRevision: main
  syncPolicy:
    retry:
      backoff:
        duration: 5s
        factor: 2
        maxDuration: 3m
      limit: 5</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Target cluster; here, the local cluster</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Namespace of the target cluster; here, the OpenBao deployment will be installed.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Argo CD Project (must exist)</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Path to the Git repository for the CA certificate</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>URL of the Git repository</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>Path to the OpenBao deployment</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>This will create the following Applications:
- in-cluster-openbao-ca-certificate
- in-cluster-openbao</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The ApplicationSet adds the prefix <strong>in-cluster-</strong> to each Application name so that they remain unique in Argo CD.
</td>
</tr>
</tbody></table>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/logos/part5_openbao_argocd.png" alt="OpenBao Argo CD Applications"/>
</div>
<div class="title">Figure 1. Argo CD: OpenBao Argo CD Applications</div>
</div>
<div class="paragraph">
<p>The first Application to synchronise is <strong>in-cluster-openbao-ca-certificate</strong>.</p>
</div>
<div class="paragraph">
<p>It creates the following:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Namespace</p>
</li>
<li>
<p>CA Issuer</p>
</li>
<li>
<p>CA Certificate</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Then synchronise <strong>in-cluster-openbao</strong>. It creates:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenBao deployment</p>
</li>
<li>
<p>OpenBao Agent Injector</p>
</li>
<li>
<p>OpenBao Server TLS Certificate</p>
</li>
<li>
<p>OpenBao Agent Injector TLS Certificate</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_openbao_is_runningwhat_next">OpenBao is running—what next?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Deploying OpenBao via GitOps gives you version control and declarative management for your secret management infrastructure.</p>
</div>
<div class="paragraph">
<p>Whilst OpenBao is running and managed by Argo CD, the next step is to configure it: you will need to handle initialisation (for a new cluster) and unsealing (see <a href="/openshift-platform/security/secrets-management/openbao/2026-02-13-openbao-part-3-openshift-deployment/">Part 3</a> and <a href="/openshift-platform/security/secrets-management/openbao/2026-02-17-openbao-part-4-enabling-tls/">Part 4</a>). That manual approach does not scale. In the next article, I will discuss ways to automate initialisation and unsealing.</p>
</div>
<div class="paragraph">
<p>Key takeaways:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Use sync waves to control deployment order</p>
</li>
<li>
<p>Consider auto-unseal for production (Part 6)</p>
</li>
<li>
<p>Store initialisation data securely outside Git</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="/gitopscollection/2024-04-02-configure_app_of_apps/" rel="noopener" target="_blank">Configure App-of-Apps</a></p>
</li>
<li>
<p><a href="https://argo-cd.readthedocs.io/en/stable/user-guide/helm/" rel="noopener" target="_blank">Argo CD Helm Support</a></p>
</li>
<li>
<p><a href="https://argo-cd.readthedocs.io/en/stable/user-guide/sync-waves/" rel="noopener" target="_blank">Argo CD Sync Waves</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - Enabling TLS on OpenShift - Part 4</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-17-openbao-part-4-enabling-tls/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-17-openbao-part-4-enabling-tls/</guid><pubDate>Tue, 17 Feb 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Enable TLS for OpenBao and the Agent Injector on OpenShift using cert-manager for encryption in transit and production-ready secret management</description><content:encoded><![CDATA[<div class="paragraph">
<p>In <a href="/openshift-platform/security/secrets-management/openbao/2026-02-13-openbao-part-3-openshift-deployment/">Part 3</a> we deployed OpenBao on OpenShift in HA mode with TLS disabled: the OpenShift Route terminates TLS at the edge, and traffic from the Route to the pods is plain HTTP. While this is ok for quick tests, for a production-ready deployment, you should consider TLS for the entire journey. This article explains why and how to enable TLS end-to-end using the cert-manager operator, what to consider, and the exact steps to achieve it.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Part 3 uses <code>tls_disable = 1</code> in the OpenBao listener and relies on the OpenShift Route for TLS. That gives encryption between the client and the Route, but <strong>not</strong> between the Route and the OpenBao pods or between pods (e.g. Raft). Enabling TLS on OpenBao itself adds encryption in transit everywhere and aligns with defense-in-depth and compliance requirements. After all, we are talking about a secrets management system here and should not compromise security.</p>
</div>
<div class="paragraph">
<p>This part assumes:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenBao is already deployed as in <a href="/openshift-platform/security/secrets-management/openbao/2026-02-13-openbao-part-3-openshift-deployment/">Part 3</a> (HA with Raft, Agent Injector enabled).</p>
</li>
<li>
<p>The <strong>cert-manager operator</strong> is installed and configured on your OpenShift cluster.</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The article <a href="https://your-blog/openshift-platform/security/certificates/ssl-certificate-management/">SSL Certificate Management for OpenShift</a> describes the setup and usage of the cert-manager operator as an example.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_why_enable_tls">Why Enable TLS?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Enabling TLS for OpenBao makes sense for several reasons:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Encryption in transit</strong>: Traffic between the Route and the pods, and between OpenBao peers (Raft), is encrypted. Secrets and tokens are never sent in plain text on the cluster network.</p>
</li>
<li>
<p><strong>Defense in depth</strong>: Even if the Route or network is misconfigured, backend traffic remains protected.</p>
</li>
<li>
<p><strong>Compliance</strong>: Many standards (e.g. PCI-DSS, SOC 2) require encryption in transit for sensitive data; TLS to the application (OpenBao) helps satisfy this.</p>
</li>
<li>
<p><strong>Agent Injector</strong>: The injector webhook is called by the Kubernetes API server. Using TLS for the webhook (with a valid certificate) is required for production and when running multiple replicas.</p>
</li>
<li>
<p><strong>Consistency</strong>: Using HTTPS everywhere simplifies client configuration and avoids mixing HTTP/HTTPS in the same environment.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_what_must_be_considered">What Must Be Considered?</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><strong>Two TLS contexts</strong>: Each needs its own certificate and configuration.</p>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>OpenBao server (API and Raft)</p>
</li>
<li>
<p>Agent Injector (mutating webhook)</p>
</li>
</ol>
</div>
</li>
<li>
<p><strong>Certificate SANs</strong>: Server certificates must include <strong>all names</strong> used to reach OpenBao: Route host, internal service names (e.g. openbao.openbao.svc, openbao-0.openbao-internal.openbao.svc), 127.0.0.1 and ::1 for in-pod traffic, and any external DNS you use. The injector certificate must match the injector Service DNS name (e.g. openbao-agent-injector-svc.openbao.svc).</p>
</li>
<li>
<p><strong>cert-manager</strong>: Using cert-manager gives automatic issuance and renewal. You need a ClusterIssuer (or an Issuer) in the OpenBao namespace.</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
In this example, we will use a self-signed CA for the OpenBao server and the Agent Injector. In a production environment, you should use a trusted CA.
</td>
</tr>
</tbody></table>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>OpenShift Route</strong>: With backend TLS enabled, you can keep the Route in reencrypt mode: the Route terminates TLS from the client and opens a new TLS connection to the pod. Alternatively, use passthrough if you want end-to-end TLS without re-encryption at the Route.</p>
</li>
<li>
<p><strong>Raft join</strong>: After switching to TLS, retry_join and cluster addresses must use https:// and the correct hostnames. Existing unseal keys and root token are unchanged; only the transport is different.</p>
</li>
<li>
<p><strong>Clients</strong>: CLI and applications must use https:// for BAO_ADDR and, if you use a private CA, BAO_CACERT (or the system trust store) so that the client trusts the server certificate.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p>OpenBao HA deployment from <a href="/openshift-platform/security/secrets-management/openbao/2026-02-13-openbao-part-3-openshift-deployment/">Part 3</a> (namespace <code>openbao</code>, Helm release <code>openbao</code>).</p>
</li>
<li>
<p>cert-manager operator installed on OpenShift.</p>
</li>
<li>
<p>Sufficient rights to create Issuers, Certificates, and Secrets in the <code>openbao</code> namespace.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_overview_of_steps">Overview of Steps</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Create a <strong>Certificate Authority (CA)</strong> in the <code>openbao</code> namespace (or use an existing ClusterIssuer).</p>
</li>
<li>
<p>Issue a <strong>Certificate for the OpenBao server</strong> (API + Raft) and store it in a Secret.</p>
</li>
<li>
<p>Issue a <strong>Certificate for the Agent Injector</strong> and reference it in the Helm values.</p>
</li>
<li>
<p>Update <strong>Helm values</strong> to mount the server cert and CA, and configure the listener and Raft for TLS.</p>
</li>
<li>
<p><strong>Upgrade</strong> the Helm release; initialize and unseal openbao-0 (new cluster) or re-unseal (existing).</p>
</li>
<li>
<p><strong>Verify</strong> access via HTTPS and configure clients (<code>BAO_ADDR</code>, <code>BAO_CACERT</code>).</p>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_1_certificate_authority_ca_for_openbao">Step 1: Certificate Authority (CA) for OpenBao</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you already have a ClusterIssuer (e.g. Let’s Encrypt or an enterprise CA), you can use it for the server and injector certificates and skip this step. For a self-signed CA in the OpenBao namespace (typical for internal cluster TLS), create the following.</p>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
This self-signed CA is only for testing purposes. In a production environment, you should use a trusted CA, preferably your own.
</td>
</tr>
</tbody></table>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Create a self-signed CA Issuer in the openbao namespace:</p>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
You might have your own CA or a ClusterIssuer already. You can use them, instead of creating a new one.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: openbao-selfsigned
  namespace: openbao <i class="conum" data-value="1"></i><b>(1)</b>
spec:
  selfSigned: {} <i class="conum" data-value="2"></i><b>(2)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The namespace where the OpenBao deployment is running.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The self-signed CA Issuer.</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Create a self-signed CA Certificate in the openbao namespace:</p>
<div class="paragraph">
<p>This will now actually request the CA certificate from the self-signed CA Issuer. This process is fully automated by cert-manager because everything is self-signed. The requested certificate will be stored in the secret openbao-ca-secret and is available immediately.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: openbao-ca
  namespace: openbao <i class="conum" data-value="1"></i><b>(1)</b>
spec:
  isCA: true <i class="conum" data-value="2"></i><b>(2)</b>
  commonName: OpenBao CA
  secretName: openbao-ca-secret <i class="conum" data-value="3"></i><b>(3)</b>
  duration: 87660h <i class="conum" data-value="4"></i><b>(4)</b>
  privateKey: <i class="conum" data-value="5"></i><b>(5)</b>
    algorithm: ECDSA
    size: 256 <i class="conum" data-value="6"></i><b>(6)</b>
    rotationPolicy: Always <i class="conum" data-value="6"></i><b>(6)</b>
  issuerRef:
    name: openbao-selfsigned <i class="conum" data-value="7"></i><b>(7)</b>
    kind: Issuer <i class="conum" data-value="8"></i><b>(8)</b>
    group: cert-manager.io</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The namespace where the OpenBao deployment is running.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The certificate is a CA certificate.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The name of the secret where the certificate and key will be stored.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The duration of the certificate. In this case 10 years.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The private key algorithm and size.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The rotation policy of the private key.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>The issuer of the certificate.</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td>The kind of the issuer. Can be Issuer or ClusterIssuer.</td>
</tr>
</tbody></table>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_2_create_an_issuer_for_the_openbao_server_and_agent_injector">Step 2: Create an Issuer for the OpenBao Server and Agent Injector</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Create an Issuer for the OpenBao Server and Agent Injector. This Issuer will reference the CA certificate and key stored in the secret openbao-ca-secret.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: openbao-ca-issuer
  namespace: openbao
spec:
  ca:
    secretName: openbao-ca-secret</code></pre>
</div>
</div>
<div class="paragraph">
<p>The name of the secret where the CA certificate and key are stored.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_3_certificate_for_the_openbao_server">Step 3: Certificate for the OpenBao Server</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now it is time to create the certificate for the OpenBao server. The server certificate must include <strong>every hostname</strong> used to reach OpenBao: the Route host, the headless service, and each Raft member. Adjust the dnsNames and optional uris to match your cluster and Route.</p>
</div>
<div class="paragraph">
<p>Create the following Certificate object:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: openbao-server-tls
  namespace: openbao
spec:
  secretName: openbao-server-tls <i class="conum" data-value="1"></i><b>(1)</b>
  duration: 8760h <i class="conum" data-value="2"></i><b>(2)</b>
  renewBefore: 720h  <i class="conum" data-value="3"></i><b>(3)</b>
  commonName: openbao.openbao.svc <i class="conum" data-value="4"></i><b>(4)</b>
  dnsNames:
    - openbao.apps.cluster.example.com # Route host (adjust to your domain) <i class="conum" data-value="5"></i><b>(5)</b>
    - openbao <i class="conum" data-value="6"></i><b>(6)</b>
    - openbao.openbao
    - openbao.openbao.svc
    - openbao.openbao.svc.cluster.local
    - openbao-internal
    - openbao-internal.openbao
    - openbao-internal.openbao.svc
    - openbao-internal.openbao.svc.cluster.local
    - openbao-0.openbao-internal
    - openbao-0.openbao-internal.openbao
    - openbao-0.openbao-internal.openbao.svc
    - openbao-0.openbao-internal.openbao.svc.cluster.local
    - openbao-1.openbao-internal
    - openbao-1.openbao-internal.openbao
    - openbao-1.openbao-internal.openbao.svc
    - openbao-2.openbao-internal
    - openbao-2.openbao-internal.openbao
    - openbao-2.openbao-internal.openbao.svc
  ipAddresses: <i class="conum" data-value="7"></i><b>(7)</b>
    - 127.0.0.1
    - &#34;::1&#34;
  issuerRef:
    name: openbao-ca-issuer <i class="conum" data-value="8"></i><b>(8)</b>
    kind: Issuer
    group: cert-manager.io</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The name of the secret where the certificate and key will be stored.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The duration of the certificate. In this case 1 year.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The duration before the certificate is renewed. In this case 30 days.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The common name of the certificate. This is the service name of the OpenBao server.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The Route host. Adjust to your domain.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The headless service names, all should be included.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>Required for in-pod traffic: Readiness/liveness probes and local bao commands (e.g. raft join, operator unseal) connect to 127.0.0.1:8200. Without these IP SANs you get &#34;tls: bad certificate&#34; or &#34;x509: cannot validate certificate for 127.0.0.1 because it doesn’t contain any IP SANs&#34;.</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td>The issuer of the certificate, this time openbao-ca-issuer.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>After a few moments the certificate will be ready and the secret will be created. The cert-manager will store the signed certificate and key in the Secret openbao-server-tls with keys tls.crt and tls.key. The Helm chart can mount this secret for the OpenBao listener.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_4_certificate_for_the_agent_injector">Step 4: Certificate for the Agent Injector</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The Agent Injector runs as a webhook; the Kubernetes API server calls it over TLS. The certificate must match the Service DNS name of the injector. Create a Certificate that references the same CA Issuer. In this example we use a short-lived certificate valid for 24 hours, renewed when 10% of the validity period remains.</p>
</div>
<div class="paragraph">
<p>Save as openbao-injector-cert.yaml:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: injector-certificate
  namespace: openbao
spec:
  secretName: injector-tls <i class="conum" data-value="1"></i><b>(1)</b>
  duration: 24h <i class="conum" data-value="2"></i><b>(2)</b>
  renewBefore: 144m
  commonName: Agent Inject Cert <i class="conum" data-value="3"></i><b>(3)</b>
  dnsNames:
    - openbao-agent-injector-svc <i class="conum" data-value="4"></i><b>(4)</b>
    - openbao-agent-injector-svc.openbao
    - openbao-agent-injector-svc.openbao.svc
    - openbao-agent-injector-svc.openbao.svc.cluster.local
  issuerRef:
    name: openbao-ca-issuer
    kind: Issuer
    group: cert-manager.io</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The name of the secret where the certificate and key will be stored.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The duration of the certificate. In this case 24 hours. (renewal is done 10% before expiry)</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The injector service name.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The injector service name is defined by the Helm chart. If you override the injector service name, adjust dnsNames accordingly.</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_5_helm_values_for_server_tls">Step 5: Helm Values for Server TLS</h2>
<div class="sectionbody">
<div class="paragraph">
<p>With all the certificates created, we can update the Helm values so that OpenBao uses the server certificate and listens with TLS. You need to:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Mount the Secret openbao-server-tls into the OpenBao pods.</p>
</li>
<li>
<p>Set the listener to use tls_cert_file and tls_key_file and disable tls_disable.</p>
</li>
<li>
<p>Switch Raft retry_join and cluster addresses to https://.</p>
</li>
<li>
<p>Add the environment variable BAO_CACERT to the OpenBao pods.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Before we start, we need to export the CA certificate from the secret openbao-ca-secret and save its value:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get secret openbao-ca-secret -n openbao -o jsonpath=&#39;{.data.ca\.crt}&#39; | base64 -d</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will return the certificate like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----</code></pre>
</div>
</div>
<div class="paragraph">
<p>Save this, you will need it in the next step.</p>
</div>
<div class="paragraph">
<p>Now we need to create the Helm values file. This time we will enable TLS. Refer to Part 3 of this series to see what the initial values file looks like.</p>
</div>
<div class="paragraph">
<p>Create or update openbao-ha-values-tls.yaml (building on your Part 3 values):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">global:
  # Enable OpenShift-specific settings
  openshift: true

  # Required when TLS is enabled: tells the chart to use HTTPS for readiness/liveness
  # probes and for in-pod API_ADDR (127.0.0.1:8200). Otherwise you get &#34;client sent
  # an HTTP request to an HTTPS server&#34; from the probes.
  tlsDisable: false <i class="conum" data-value="1"></i><b>(1)</b>

server:
  extraEnvironmentVars:
    BAO_CACERT: /openbao/tls/openbao-server-tls/ca.crt <i class="conum" data-value="2"></i><b>(2)</b>

  # High Availability configuration
  ha:
    enabled: true
    replicas: 3

    # Raft storage configuration
    raft:
      enabled: true
      setNodeId: true

      config: |
        ui = true

        listener &#34;tcp&#34; {
          tls_disable = 0 <i class="conum" data-value="3"></i><b>(3)</b>
          address = &#34;[::]:8200&#34;
          cluster_address = &#34;[::]:8201&#34;
          tls_cert_file = &#34;/openbao/tls/openbao-server-tls/tls.crt&#34; <i class="conum" data-value="4"></i><b>(4)</b>
          tls_key_file  = &#34;/openbao/tls/openbao-server-tls/tls.key&#34; <i class="conum" data-value="5"></i><b>(5)</b>
          tls_min_version = &#34;tls12&#34; <i class="conum" data-value="6"></i><b>(6)</b>
          telemetry {
            unauthenticated_metrics_access = &#34;true&#34;
          }
        }

        storage &#34;raft&#34; {
          path = &#34;/openbao/data&#34;

          retry_join {
            leader_api_addr = &#34;https://openbao-0.openbao-internal:8200&#34; <i class="conum" data-value="7"></i><b>(7)</b>
            leader_tls_servername = &#34;openbao-0.openbao-internal&#34;
            leader_ca_cert_file = &#34;/openbao/tls/openbao-server-tls/ca.crt&#34; <i class="conum" data-value="8"></i><b>(8)</b>
          }
          retry_join {
            leader_api_addr = &#34;https://openbao-1.openbao-internal:8200&#34;
            leader_tls_servername = &#34;openbao-1.openbao-internal&#34;
            leader_ca_cert_file = &#34;/openbao/tls/openbao-server-tls/ca.crt&#34;
          }
          retry_join {
            leader_api_addr = &#34;https://openbao-2.openbao-internal:8200&#34;
            leader_tls_servername = &#34;openbao-2.openbao-internal&#34;
            leader_ca_cert_file = &#34;/openbao/tls/openbao-server-tls/ca.crt&#34;
          }
        }

        service_registration &#34;kubernetes&#34; {}

        telemetry {
          prometheus_retention_time = &#34;30s&#34;
          disable_hostname = true
        }

  route:
    enabled: true
    host: openbao.apps.cluster.example.com
    tls: <i class="conum" data-value="9"></i><b>(9)</b>
      # Route terminates client TLS; backend can use reencrypt or passthrough
      termination: reencrypt
      insecureEdgeTerminationPolicy: Redirect
      destinationCACertificate: | <i class="conum" data-value="10"></i><b>(10)</b>
        -----BEGIN CERTIFICATE-----
        # CA Certificate
        -----END CERTIFICATE-----

  extraVolumes: <i class="conum" data-value="11"></i><b>(11)</b>
    - type: secret
      name: openbao-server-tls
      path: /openbao/tls
      readOnly: true

  extraVolumeMounts: <i class="conum" data-value="12"></i><b>(12)</b>
    - name: openbao-server-tls
      mountPath: /openbao/tls
      readOnly: true

  # Resource requests and limits
  resources:
    requests:
      memory: 256Mi
      cpu: 250m
    limits:
      memory: 1Gi
      cpu: 1000m

  # Persistent volume for data
  dataStorage:
    enabled: true
    size: 10Gi
    # storageClass: &#34;gp3-csi&#34;

# Injector configuration
injector:
  enabled: true
  replicas: 2  # HA for the injector too
  certs: <i class="conum" data-value="13"></i><b>(13)</b>
    secretName: injector-tls
    # For a private CA: set caBundle to the CA cert (PEM) so the Kubernetes API server trusts the injector webhook. E.g. oc get secret openbao-ca-secret -n openbao -o jsonpath=&#39;{.data.ca\.crt}&#39; | base64 -d
    caBundle:  &#34;BASE64_ENCODED_CA_CERTIFICATE&#34;
    certName: tls.crt
    keyName: tls.key

# UI configuration
ui:
  enabled: true</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td><strong>global.tlsDisable</strong>: Set to false when the server listener uses TLS. This makes the chart use HTTPS for readiness/liveness probes and for the in-pod API_ADDR env var. If you leave it true (default), probes and local clients will use HTTP and you will see &#34;client sent an HTTP request to an HTTPS server&#34;.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The environment variable BAO_CACERT is set to the CA certificate file path. This is helpful to execute the boa command inside the container.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The listener tls_disable is set to 0 to enable TLS.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The listener tls_cert_file is set to the certificate file path.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The listener tls_key_file is set to the key file path.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The listener tls_min_version is set to tls12.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>The leader API address is set to the HTTPS address.</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td>The leader CA certificate file is set to the CA certificate file path.</td>
</tr>
<tr>
<td><i class="conum" data-value="9"></i><b>9</b></td>
<td>The Route tls termination is set to reencrypt.</td>
</tr>
<tr>
<td><i class="conum" data-value="10"></i><b>10</b></td>
<td>The destination CA certificate is set to the CA certificate. Be sure not to add any extra lines or spaces.</td>
</tr>
<tr>
<td><i class="conum" data-value="11"></i><b>11</b></td>
<td>The extra volumes are mounted at the /openbao/tls path.</td>
</tr>
<tr>
<td><i class="conum" data-value="12"></i><b>12</b></td>
<td>The extra volume mounts are mounted at the /openbao/tls path.</td>
</tr>
<tr>
<td><i class="conum" data-value="13"></i><b>13</b></td>
<td>The injector certs are set to the injector TLS secret name. The caBundle must be provided in base64 format.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The secret key names must match what cert-manager writes: tls.crt and tls.key. The OpenBao Helm chart mounts each entry in extraVolumes at path + name (e.g. with path: /openbao/tls and name: openbao-server-tls the secret is mounted at /openbao/tls/openbao-server-tls/). The listener tls_cert_file and tls_key_file must use that full path.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Be sure to change the Route host in the Helm values to the one you are using. In addition, make sure that the CA certificate is added correctly to the Route. Do not add any extra lines or spaces and do not forget the | after destinationCACertificate: and the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- lines.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_6_upgrade_the_helm_release">Step 6: Upgrade the Helm Release</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Perform a Helm upgrade so the new volumes and configuration are applied. Pods will restart and pick up TLS; Raft will use HTTPS for join and replication.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">helm upgrade openbao openbao/openbao \
  --namespace openbao \
  --values openbao-ha-values-tls.yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p>Watch the rollout. The first pod (openbao-0) will log &#34;raft retry join initiated&#34; and stay 0/1 Ready until it is initialized and unsealed (new cluster) or until it forms quorum (existing cluster).</p>
</div>
<div class="sect2">
<h3 id="_new_cluster_initialize_and_unseal_openbao_0">New cluster: initialize and unseal openbao-0</h3>
<div class="paragraph">
<p>openbao-0 will not become Ready until it is initialized and unsealed. Fetch the certificate, use port-forward and talk to OpenBao over HTTPS with the CA:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># 1. Save the CA cert (for BAO_CACERT)
oc get secret openbao-ca-secret -n openbao -o jsonpath=&#39;{.data.ca\.crt}&#39; | base64 -d &gt; openbao-ca.crt

# 2. Port-forward to openbao-0 (background)
oc port-forward openbao-0 8200:8200 -n openbao &amp;

# 3. Use HTTPS and CA cert
export BAO_ADDR=&#39;https://127.0.0.1:8200&#39;
export BAO_CACERT=&#34;$PWD/openbao-ca.crt&#34;

# 4. Check status, then initialize (only once) and unseal 3 times
bao status
bao operator init -key-shares=5 -key-threshold=3 -format=json &gt; openbao-init.json
bao operator unseal
bao operator unseal
bao operator unseal
bao status</code></pre>
</div>
</div>
<div class="paragraph">
<p>After unsealing, openbao-0 becomes leader and goes 1/1 Ready. Then start openbao-1 and openbao-2 and join or unseal them as in Part 3 (use https://).</p>
</div>
<div class="paragraph">
<p>Perform the following steps for the other pods - join the raft cluster and unseal them (3 times):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc exec -ti openbao-1 -- bao operator raft join https://openbao-0.openbao-internal:8200

# 3 times with 3 different unseal keys
oc exec -ti openbao-1 -- bao operator unseal
Unseal Key (will be hidden):</code></pre>
</div>
</div>
<div class="paragraph">
<p>Repeat the same steps for openbao-2.</p>
</div>
</div>
<div class="sect2">
<h3 id="_existing_cluster_re_unseal_after_restart">Existing cluster: re-unseal after restart</h3>
<div class="paragraph">
<p>The existing cluster is already initialized. Re-unseal the pods (and re-join the raft cluster if necessary).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get pods -n openbao -w
oc exec -ti openbao-1 -- bao operator raft join https://openbao-0.openbao-internal:8200
oc exec -ti openbao-1 -- bao operator unseal  # three times; same for openbao-2</code></pre>
</div>
</div>
<div class="paragraph">
<p>Repeat the same steps for openbao-2.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_step_7_verify_and_use_https_from_clients">Step 7: Verify and Use HTTPS from Clients</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Verify server health over HTTPS (from inside the cluster):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">curl -k https://openbao.apps.cluster.example.com/v1/sys/health | jq</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Be sure to use the Route host in the Helm values.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>From your workstation, use the Route URL with HTTPS. If the Route host is signed by your internal CA, set BAO_CACERT to the CA file:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">export BAO_ADDR=&#39;https://openbao.apps.cluster.example.com&#39;
export BAO_CACERT=&#39;/path/to/openbao-ca.crt&#39;
bao status</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Be sure to use the Route host in the Helm values.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Agent Injector: New pods that use the injector should start without webhook certificate errors. Check injector logs if you see TLS or certificate errors:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc logs -n openbao -l app.kubernetes.io/name=openbao-agent-injector -f</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_troubleshooting">Troubleshooting</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_mutatingwebhookconfiguration_conflict_vault_k8s">MutatingWebhookConfiguration conflict (vault-k8s)</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">conflict occurred while applying object ... MutatingWebhookConfiguration: Apply failed with 1 conflict: conflict with &#34;vault-k8s&#34; using ... .webhooks[name=&#34;vault.hashicorp.com&#34;].clientConfig.caBundle
this is a server-side apply (SSA) field ownership conflict. The OpenBao chart uses the same webhook name (vault.hashicorp.com) as the HashiCorp Vault agent injector for annotation compatibility. The clientConfig.caBundle field is still owned by a previous manager (e.g. a prior Vault Helm release or the Vault injector), so Helm cannot update it when you change the injector certificate.</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Fix option 1</strong> – Delete the webhook and re-upgrade (recommended)</p>
</div>
<div class="paragraph">
<p>Remove the MutatingWebhookConfiguration so Helm can recreate it and own all fields. There will be a short window where the injector webhook is missing (new pods requesting injection may fail until the upgrade completes).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Replace RELEASE_NAME with your Helm release name (e.g. openbao)
RELEASE_NAME=openbao
oc delete mutatingwebhookconfiguration ${RELEASE_NAME}-agent-injector-cfg

# Re-run the upgrade
helm upgrade ${RELEASE_NAME} openbao/openbao \
  --namespace openbao \
  --values openbao-ha-values-tls.yaml</code></pre>
</div>
</div>
<div class="paragraph">
<p><strong>Fix option 2</strong> – Force takeover of the conflicting field</p>
</div>
<div class="paragraph">
<p>If you cannot delete the webhook (e.g. in production), take over the caBundle field with server-side apply, then run the Helm upgrade again:</p>
</div>
<div class="paragraph">
<p>Export the MutatingWebhookConfiguration, set webhooks[0].clientConfig.caBundle to your injector CA (base64 PEM from openbao-ca-secret), then re-apply with --server-side --force-conflicts:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Get the current object and the new CA bundle
oc get mutatingwebhookconfiguration openbao-agent-injector-cfg -o yaml &gt; mwc.yaml
CA_BUNDLE=$(oc get secret openbao-ca-secret -n openbao -o jsonpath=&#39;{.data.ca\.crt}&#39;)

# Edit mwc.yaml: set .webhooks[0].clientConfig.caBundle to the value of CA_BUNDLE (no quotes in YAML).
# Then apply with force-conflicts so Helm can later manage it:
oc apply -f mwc.yaml --server-side --force-conflicts

# Re-run the Helm upgrade
helm upgrade openbao openbao/openbao --namespace openbao --values openbao-ha-values-tls.yaml</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If you still have HashiCorp Vault’s agent injector installed on the same cluster, ensure only one injector is active for a given namespace (e.g. use namespace selectors) or uninstall the Vault injector to avoid two webhooks with the same name in different resources.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_route_ui_tls_bad_record_mac">Route / UI – tls: bad record MAC</h3>
<div class="paragraph">
<p>Pod logs show <code>tls: bad record MAC</code> from the router IP. The Route is likely using <strong>edge</strong> termination (HTTP to pod). Fix: Use reencrypt and set <code>destinationCACertificate</code> (Step 5).</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get route openbao -n openbao -o jsonpath=&#39;{.spec.tls.termination}&#39;</code></pre>
</div>
</div>
<div class="paragraph">
<p>If the OpenBao UI does not load and the pod logs show:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">http: TLS handshake error from 10.x.x.x:xxxxx: local error: tls: bad record MAC</code></pre>
</div>
</div>
<div class="paragraph">
<p>the traffic is coming from the OpenShift router (the IP is typically a cluster pod IP).</p>
</div>
<div class="paragraph">
<p><strong>Cause</strong>: The Route is likely using edge termination: the router terminates TLS at the edge and sends plain HTTP to the pod. The pod expects HTTPS, so the TLS layer receives non-TLS data and reports &#34;bad record MAC&#34;.</p>
</div>
<div class="paragraph">
<p><strong>Fix</strong>: Use reencrypt (or passthrough) and set destinationCACertificate so the router talks HTTPS to the pod. See Step 5 above. Quick check:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get route openbao -n openbao -o jsonpath=&#39;{.spec.tls.termination}&#39;
# Must be &#34;reencrypt&#34; or &#34;passthrough&#34;, not &#34;edge&#34;</code></pre>
</div>
</div>
<div class="paragraph">
<p>If the output is edge, patch the Route to reencrypt and set spec.tls.destinationCACertificate to the CA PEM (Step 5).</p>
</div>
</div>
<div class="sect2">
<h3 id="_tls_handshake_127_0_0_1_certificate_errors">TLS handshake / 127.0.0.1 certificate errors</h3>
<div class="paragraph">
<p>If you see in the pod logs:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">remote error: tls: bad certificate (from 127.0.0.1)</code></pre>
</div>
</div>
<div class="paragraph">
<p>or when running:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc exec -ti openbao-0 — bao operator raft join https://…​;: x509: cannot validate certificate for 127.0.0.1 because it doesn’t contain any IP SANs</code></pre>
</div>
</div>
<div class="paragraph">
<p>The server certificate does not include 127.0.0.1 (and optionally ::1) as Subject Alternative Names. Readiness/liveness probes and in-pod bao commands connect to the listener on 127.0.0.1, so the certificate must include these IP SANs.</p>
</div>
<div class="paragraph">
<p><strong>Fix</strong>: Add ipAddresses to the OpenBao server Certificate and let cert-manager re-issue:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Edit the Certificate (or re-apply the YAML from Step 3 with ipAddresses added)
oc edit certificate openbao-server-tls -n openbao
# Add under spec:
#   ipAddresses:
#     - 127.0.0.1
#     - &#34;::1&#34;

# cert-manager will issue a new cert; wait until the secret is updated
oc get certificate openbao-server-tls -n openbao
# Restart OpenBao pods so they load the new cert
oc rollout restart statefulset/openbao -n openbao</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org/docs/platform/k8s/helm/configuration/" rel="noopener" target="_blank">OpenBao Helm configuration</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/platform/k8s/helm/examples/injector-tls-cert-manager/" rel="noopener" target="_blank">OpenBao Agent Injector TLS with cert-manager</a></p>
</li>
<li>
<p><a href="https://cert-manager.io/docs/" rel="noopener" target="_blank">cert-manager documentation</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - OpenShift Deployment with Helm - Part 3</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-13-openbao-part-3-openshift-deployment/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-13-openbao-part-3-openshift-deployment/</guid><pubDate>Fri, 13 Feb 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Deploying OpenBao on OpenShift and Kubernetes using the official Helm chart for production-ready secret management</description><content:encoded><![CDATA[<div class="paragraph">
<p>After understanding standalone installation in <a href="/openshift-platform/security/secrets-management/openbao/2026-02-12-openbao-part-2-standalone-installation/" rel="noopener" target="_blank">Part 2</a>, it is time to deploy OpenBao on OpenShift/Kubernetes using the official Helm chart. This approach provides high availability, Kubernetes-native management, and seamless integration with the OpenShift ecosystem.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Deploying OpenBao on OpenShift/Kubernetes offers several advantages:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>High Availability</strong>: Multiple replicas with automatic failover</p>
</li>
<li>
<p><strong>Kubernetes-native</strong>: Managed by standard Kubernetes primitives</p>
</li>
<li>
<p><strong>Persistent Storage</strong>: Data survives pod restarts via PVCs</p>
</li>
<li>
<p><strong>Integration</strong>: Works with Kubernetes service accounts for authentication</p>
</li>
<li>
<p><strong>Scalability</strong>: Easy to scale and manage</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>The official <a href="https://github.com/openbao/openbao-helm" rel="noopener" target="_blank">OpenBao Helm chart</a> supports multiple deployment modes:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Dev</strong>: Single server, in-memory storage (testing only)</p>
</li>
<li>
<p><strong>Standalone</strong>: Single server, persistent storage</p>
</li>
<li>
<p><strong>HA</strong>: Multiple servers with Raft consensus (recommended)</p>
</li>
<li>
<p><strong>External</strong>: Connect to external OpenBao cluster</p>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_integrations">Integrations</h3>
<div class="paragraph">
<p>Currently, OpenBao supports the following integrations that help seamlessly load secrets into applications without the need to modify the application code:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Agent Injector</strong>: A mutating webhook that automatically injects a sidecar container that retrieves and renews secrets.</p>
</li>
<li>
<p><strong>CSI Provider</strong>: A (vendor neutral) CSI driver that mounts secrets as volumes.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before deploying, ensure you have:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenShift 4.12+ or Kubernetes 1.30+</p>
</li>
<li>
<p>Helm 3.6+</p>
</li>
<li>
<p><code>oc</code> or <code>kubectl</code> CLI configured</p>
</li>
<li>
<p>The OpenBao CLI (<code>bao</code>) for initialization and unsealing (see <a href="https://openbao.org/docs/install/" rel="noopener" target="_blank">OpenBao installation</a>)</p>
</li>
<li>
<p>Cluster-admin privileges (for initial setup)</p>
</li>
<li>
<p>A storage class that supports ReadWriteOnce PVCs</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Verify prerequisites
oc version
helm version

# Check available storage classes
oc get storageclass</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_adding_the_helm_repository">Adding the Helm Repository</h2>
<div class="sectionbody">
<div class="paragraph">
<p>First, add the OpenBao Helm repository:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Add the OpenBao Helm repository
helm repo add openbao https://openbao.github.io/openbao-helm

# Update repository cache
helm repo update

# Search for available charts
helm search repo openbao

# Expected output:
# NAME            CHART VERSION   APP VERSION     DESCRIPTION
# openbao/openbao 0.x.x           2.x.x           Official OpenBao Helm chart</code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
According to the official documentation, the Helm chart is new and under significant development. It should always be run with --dry-run before any install or upgrade to verify changes.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_creating_the_namespace">Creating the Namespace</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Create a dedicated namespace for OpenBao:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
While I am using the <strong>oc</strong> CLI, you can also use the <strong>kubectl</strong> CLI as in-place replacement.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc new-project openbao</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_deployment_mode_high_availability_recommended">Deployment Mode: High Availability (Recommended)</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For production environments, deploy in HA mode with Raft. This is the recommended deployment mode for production and is straightforward to achieve on Kubernetes and OpenShift.
The following values definitions will use OpenShift specific settings. I will mark them in the callouts.</p>
</div>
<div class="paragraph">
<p>We will first create a values file, deploy openbao and then discuss what must be done to activate all OpenBao pods.</p>
</div>
<div class="sect2">
<h3 id="_create_ha_values_file">Create HA Values File</h3>
<div class="paragraph">
<p>Create <code>openbao-ha-values.yaml</code>:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The values file is based on the official <a href="https://github.com/openbao/openbao-helm/blob/main/charts/openbao/values.yaml" rel="noopener" target="_blank">values file from that chart</a>, but only modified values or important changes are listed here.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">global:
  # Enable OpenShift-specific settings
  openshift: true <i class="conum" data-value="1"></i><b>(1)</b>

server:
  # High Availability configuration
  ha:
    enabled: true <i class="conum" data-value="2"></i><b>(2)</b>
    replicas: 3 <i class="conum" data-value="3"></i><b>(3)</b>

    # Raft storage configuration
    raft:
      enabled: true <i class="conum" data-value="4"></i><b>(4)</b>
      setNodeId: true

      config: | <i class="conum" data-value="5"></i><b>(5)</b>
        ui = true

        listener &#34;tcp&#34; {
          tls_disable = 1
          address = &#34;[::]:8200&#34;
          cluster_address = &#34;[::]:8201&#34;
          telemetry {
            unauthenticated_metrics_access = &#34;true&#34;
          }
        }

        storage &#34;raft&#34; {
          path = &#34;/openbao/data&#34;

          retry_join {
            leader_api_addr = &#34;http://openbao-0.openbao-internal:8200&#34;
          }
          retry_join {
            leader_api_addr = &#34;http://openbao-1.openbao-internal:8200&#34;
          }
          retry_join {
            leader_api_addr = &#34;http://openbao-2.openbao-internal:8200&#34;
          }
        }

        service_registration &#34;kubernetes&#34; {}

        telemetry {
          prometheus_retention_time = &#34;30s&#34;
          disable_hostname = true
        }

  route:
    enabled: true <i class="conum" data-value="6"></i><b>(6)</b>
    host: openbao.apps.cluster.example.com <i class="conum" data-value="7"></i><b>(7)</b>
    tls:
      termination: edge

  # Resource requests and limits
  resources:
    requests:
      memory: 256Mi
      cpu: 250m
    limits:
      memory: 1Gi
      cpu: 1000m

  # Persistent volume for data
  dataStorage: <i class="conum" data-value="8"></i><b>(8)</b>
    enabled: true
    size: 10Gi
    # storageClass: &#34;gp3-csi&#34;

# Injector configuration
injector:
  enabled: true
  replicas: 2  # HA for the injector too <i class="conum" data-value="9"></i><b>(9)</b>


# UI configuration
ui: <i class="conum" data-value="10"></i><b>(10)</b>
  enabled: true</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td><strong>OpenShift specific</strong>: Activate OpenShift Mode: Critical setting, if you install on OpenShift. It adjusts the Helm chart to use Routes instead of Ingress and modifies RoleBindings to work with OpenShift’s stricter authentication.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>High Availability (HA): Deploys OpenBao as a StatefulSet rather than a Deployment.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Raft Consensus Quorum: Sets the cluster size to 3. Raft requires an <strong>odd number of nodes</strong> to handle leader elections and avoid split-brain scenarios. This cluster can survive the loss of 1 node.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Integrated Raft Storage: Enables the internal Raft storage backend, removing the need for external dependencies like Consul or Etcd.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>Server Configuration (HCL): The actual OpenBao server configuration file. Note that <strong>tls_disable = 1</strong> is used because the OpenShift Route handles TLS termination at the edge, passing unencrypted traffic to the pod.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td><strong>OpenShift specific</strong>: Route: Tells Helm to create an OpenShift Route object automatically.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td><strong>OpenShift specific</strong>: Host: The external DNS address where users and applications will access the OpenBao API and UI.</td>
</tr>
<tr>
<td><i class="conum" data-value="8"></i><b>8</b></td>
<td>Persistent Storage: Allocates a 10Gi Persistent Volume Claim (PVC) for each of the 3 pods to store encrypted data and Raft logs.</td>
</tr>
<tr>
<td><i class="conum" data-value="9"></i><b>9</b></td>
<td>Injector Redundancy: Runs 2 replicas of the sidecar injector. If the injector service is down, new application pods attempting to start with secrets will fail.</td>
</tr>
<tr>
<td><i class="conum" data-value="10"></i><b>10</b></td>
<td>Web UI: Enables the graphical dashboard service.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_deploy_ha_cluster">Deploy HA Cluster</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Deploy with HA values
helm install openbao openbao/openbao \
  --namespace openbao \
  --values openbao-ha-values.yaml</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_verify_the_deployment">Verify the Deployment</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get pods -n openbao</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will result in the following output:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">NAME                                    READY   STATUS    RESTARTS   AGE
openbao-0                               0/1     Running   0          60s <i class="conum" data-value="1"></i><b>(1)</b>
openbao-agent-injector-xxx              1/1     Running   0          60s
openbao-agent-injector-yyy              1/1     Running   0          60s</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Only 1 openbao pod (instead of 3) is running, and the pod is not in &#34;ready&#34; state.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>As you can see, only one OpenBao pod exists so far, and it is not in &#34;ready&#34; state. This is because OpenBao is not yet initialized and unsealed. Once that is done, the other pods will appear and join the cluster.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The OpenBao pods show 0/1 ready because they are sealed and need initialization.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>This is also indicated in the logs of the openbao pod:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">2026-02-13T14:44:52.587Z [ERROR] core: failed to get raft challenge: leader_addr=http://openbao-0.openbao-internal.openbao.svc:8200
  error=
  | error during raft bootstrap init call: Error making API request.
  |
  | URL: PUT http://openbao-0.openbao-internal.openbao.svc:8200/v1/sys/storage/raft/bootstrap/challenge
  | Code: 503. Errors:
  |
  | * Vault is sealed <i class="conum" data-value="1"></i><b>(1)</b>

2026-02-13T14:44:52.588Z [ERROR] core: failed to get raft challenge: leader_addr=http://openbao-2.openbao-internal.openbao.svc:8200 error=&#34;error during raft bootstrap init call: Put \&#34;http://openbao-2.openbao-internal.openbao.svc:8200/v1/sys/storage/raft/bootstrap/challenge\&#34;: dial tcp: lookup openbao-2.openbao-internal.openbao.svc on 172.30.0.10:53: no such host&#34; <i class="conum" data-value="2"></i><b>(2)</b>
2026-02-13T14:44:52.589Z [ERROR] core: failed to get raft challenge: leader_addr=http://openbao-1.openbao-internal.openbao.svc:8200 error=&#34;error during raft bootstrap init call: Put \&#34;http://openbao-1.openbao-internal.openbao.svc:8200/v1/sys/storage/raft/bootstrap/challenge\&#34;: dial tcp: lookup openbao-1.openbao-internal.openbao.svc on 172.30.0.10:53: no such host&#34;
2026-02-13T14:44:52.589Z [ERROR] core: failed to retry join raft cluster: retry=2s err=&#34;failed to get raft challenge&#34;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Vault is sealed: This means that the OpenBao service is not yet initialized and unsealed.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>No such host: This means that the OpenBao service is not yet available.</td>
</tr>
</tbody></table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_initializing_and_unsealing_openbao">Initializing and Unsealing OpenBao</h2>
<div class="sectionbody">
<div class="paragraph">
<p>After deployment, OpenBao needs to be initialized and unsealed. This is done on the first pod. Once this is done, the other pods will appear and can join the cluster. We will create a local portforwarding to the first pod to initialize it.</p>
</div>
<div class="sect2">
<h3 id="_initialize_the_cluster">Initialize the Cluster</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Create a local port forwarding to the first pod</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc port-forward openbao-0 8200:8200 -n openbao &amp;</code></pre>
</div>
</div>
</li>
<li>
<p>Set environment variable</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">export BAO_ADDR=&#39;http://127.0.0.1:8200&#39;</code></pre>
</div>
</div>
</li>
<li>
<p>Check status</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao status</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will result in the following output:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Key                Value
---                -----
Seal Type          shamir
Initialized        false <i class="conum" data-value="1"></i><b>(1)</b>
Sealed             true <i class="conum" data-value="2"></i><b>(2)</b>
Total Shares       0
Threshold          0
Unseal Progress    0/0
Unseal Nonce       n/a
Version            2.5.0
Build Date         2026-02-04T16:19:33Z
Storage Type       raft
HA Enabled         true <i class="conum" data-value="3"></i><b>(3)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Not yet initialized</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Vault is sealed</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>High Availability is enabled</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Initialize the cluster with 5 key shares and 3 threshold</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao operator init -key-shares=5 -key-threshold=3 -format=json &gt; openbao-init.json</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will create the file <code>openbao-init.json</code> with the unseal keys and root token.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">cat openbao-init.json</code></pre>
</div>
</div>
</li>
</ol>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Take care of the <code>openbao-init.json</code> file. It contains the unseal keys and root token!
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_unseal_pod_openbao_0">Unseal Pod openbao-0</h3>
<div class="paragraph">
<p>After initialization, we need to unseal the first pod. This is done by providing 3 different unseal keys. (threshold is 3)</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Unseal openbao-0 (3 times with different keys)
bao operator unseal  # Enter first key
bao operator unseal  # Enter second key
bao operator unseal  # Enter third key</code></pre>
</div>
</div>
<div class="paragraph">
<p>This unseals openbao-0, which can be verified with the command <code>bao status</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Key                     Value
---                     -----
Seal Type               shamir
Initialized             true
Sealed                  false <i class="conum" data-value="1"></i><b>(1)</b>
Total Shares            5
Threshold               3
Version                 2.5.0
Build Date              2026-02-04T16:19:33Z
Storage Type            raft
Cluster Name            vault-cluster-80c01167
Cluster ID              b81ecb85-9751-655a-95b7-69463dd13241
HA Enabled              true
HA Cluster              https://openbao-0.openbao-internal:8201
HA Mode                 active
Active Since            2026-02-13T14:46:13.292643992Z
Raft Committed Index    29
Raft Applied Index      29</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Vault is unsealed</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>This makes openbao-0 ready and openbao-1 is trying to start:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get pods
NAME                                     READY   STATUS    RESTARTS   AGE
openbao-0                                1/1     Running   0          2m10s <i class="conum" data-value="1"></i><b>(1)</b>
openbao-1                                0/1     Running   0          14s <i class="conum" data-value="2"></i><b>(2)</b>
openbao-agent-injector-98769cf97-r4stk   1/1     Running   0          2m12s
openbao-agent-injector-98769cf97-xldgm   1/1     Running   0          2m12s</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>openbao-0 is ready</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>openbao-1 is trying to start and wants to join the Raft cluster</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_activate_pod_openbao_1">Activate Pod openbao-1</h3>
<div class="paragraph">
<p>Since OpenBao is already initialized, we can skip the initialization step. However, we must join the <strong>Raft cluster</strong>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc exec -ti openbao-1 -- bao operator raft join http://openbao-0.openbao-internal:8200</code></pre>
</div>
</div>
<div class="paragraph">
<p>Once done, we can unseal openbao-1. We need to provide 3 different unseal keys again.
Execute the following command 3 times:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc exec -ti openbao-1 -- bao operator unseal
Unseal Key (will be hidden):</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now <strong>openbao-1</strong> is ready and openbao-2 is trying to start:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get pods
NAME                                     READY   STATUS    RESTARTS   AGE
openbao-0                                1/1     Running   0          3m48s
openbao-1                                1/1     Running   0          112s
openbao-2                                0/1     Running   0          18s
openbao-agent-injector-98769cf97-r4stk   1/1     Running   0          3m50s
openbao-agent-injector-98769cf97-xldgm   1/1     Running   0          3m50s</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_activate_pod_openbao_2">Activate Pod openbao-2</h3>
<div class="paragraph">
<p>Now we need to repeat the previous steps for openbao-2.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc exec -ti openbao-2 -- bao operator raft join http://openbao-0.openbao-internal:8200

# Run 3 times (enter a different unseal key each time):
oc exec -ti openbao-2 -- bao operator unseal</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_verify_raft_cluster">Verify Raft Cluster</h3>
<div class="paragraph">
<p>You can verify the Raft cluster by logging in with the root token and then checking the Raft peer list.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc exec -ti openbao-0 -- bao login</code></pre>
</div>
</div>
<div class="paragraph">
<p>Check the peer list:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Check Raft peer list
oc exec -ti openbao-0 -- bao operator raft list-peers
Node         Address                            State       Voter
----         -------                            -----       -----
openbao-0    openbao-0.openbao-internal:8201    leader      true
openbao-1    openbao-1.openbao-internal:8201    follower    true
openbao-2    openbao-2.openbao-internal:8201    follower    true</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_accessing_the_ui">Accessing the UI</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Once unsealed, access the OpenBao UI:</p>
</div>
<div class="sect2">
<h3 id="_via_route_production">Via Route (Production)</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc get route openbao -n openbao
# Open browser: https://openbao.apps.cluster.example.com</code></pre>
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part3_openbao_login_form.png?width=480px" alt="OpenBao Login Form"/>
</div>
<div class="title">Figure 1. OpenBao Login Form</div>
</div>
<div class="paragraph">
<p>Login with the root token from initialization, or with credentials once authentication is configured.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_upgrading_openbao">Upgrading OpenBao</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Keep your secrets management up to date. To upgrade an existing deployment:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Update Helm repository
helm repo update

# Check available versions
helm search repo openbao --versions

# Upgrade with your values file
helm upgrade openbao openbao/openbao \
  --namespace openbao \
  --values openbao-ha-values.yaml

# Watch the rolling update
oc get pods -n openbao -w</code></pre>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
After upgrade, pods may need to be unsealed again if they restart.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_troubleshooting">Troubleshooting</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_pods_not_starting">Pods Not Starting</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Check pod status
oc describe pod openbao-0 -n openbao

# Check pod logs
oc logs openbao-0 -n openbao

# Check events
oc get events -n openbao --sort-by=&#39;.lastTimestamp&#39;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_pvc_issues">PVC Issues</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Check PVC status
oc get pvc -n openbao

# If pending, check storage class
oc describe pvc data-openbao-0 -n openbao</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_raft_join_failures">Raft Join Failures</h3>
<div class="paragraph">
<p>If pods cannot join the Raft cluster:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Check internal DNS resolution
oc exec -it openbao-0 -n openbao -- nslookup openbao-internal

# Check connectivity between pods
oc exec -it openbao-0 -n openbao -- wget -O- http://openbao-1.openbao-internal:8200/v1/sys/health</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_what_should_be_considered_next">What Should Be Considered Next?</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p>Securely store the unseal keys and root token</p>
</li>
<li>
<p>Configure pod anti-affinity for true HA</p>
</li>
<li>
<p>Consider auto-unseal for operational ease (upcoming article)</p>
</li>
<li>
<p>Put everything into a GitOps pipeline</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You now have OpenBao running on OpenShift in high-availability mode. This deployment:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Survives pod failures and restarts</p>
</li>
<li>
<p>Uses Raft for distributed consensus</p>
</li>
<li>
<p>Integrates with OpenShift security model</p>
</li>
<li>
<p>Is ready for production use (after unsealing automation)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Key points to remember:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Use HA mode for production</p>
</li>
<li>
<p>Store unseal keys securely</p>
</li>
<li>
<p>Configure pod anti-affinity for true HA</p>
</li>
<li>
<p>Consider auto-unseal for operational ease (upcoming article)</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org/docs/platform/k8s/helm" rel="noopener" target="_blank">OpenBao Helm Chart Documentation</a></p>
</li>
<li>
<p><a href="https://github.com/openbao/openbao-helm" rel="noopener" target="_blank">OpenBao Helm Chart GitHub</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/platform/k8s/helm/run" rel="noopener" target="_blank">Running OpenBao on Kubernetes</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - Standalone Installation - Part 2</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-12-openbao-part-2-standalone-installation/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-12-openbao-part-2-standalone-installation/</guid><pubDate>Thu, 12 Feb 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Installing OpenBao as a standalone service outside of Kubernetes for testing and edge deployments</description><content:encoded><![CDATA[<div class="paragraph">
<p>In the previous article, we introduced OpenBao and its core concepts. Now it is time to get our hands dirty with a standalone installation. This approach is useful for testing, development environments, edge deployments, or scenarios where Kubernetes is not available.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>While OpenBao shines in Kubernetes environments, understanding the standalone installation helps you grasp the fundamentals. This knowledge is valuable whether you are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Learning OpenBao before deploying to production</p>
</li>
<li>
<p>Running OpenBao outside of Kubernetes (edge, legacy systems)</p>
</li>
<li>
<p>Debugging issues in containerized deployments</p>
</li>
<li>
<p>Setting up a development environment</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_installation_methods_overview">Installation Methods Overview</h2>
<div class="sectionbody">
<div class="paragraph">
<p>OpenBao can be installed through multiple methods:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;"/>
<col style="width: 40%;"/>
<col style="width: 40%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Method</th>
<th class="tableblock halign-left valign-top">Best For</th>
<th class="tableblock halign-left valign-top">Complexity</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Package managers (apt, dnf, brew)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Production Linux/macOS systems</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Low</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Container images (Podman/Docker)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Quick testing, isolated environments</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Low</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Binary download</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Air-gapped environments</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Low</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Source compilation</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Custom builds, development</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Medium</p></td>
</tr>
</tbody>
</table>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
For this article, we will focus on macOS for local testing with binary and container image (using Podman) and Red Hat Enterprise Linux to set up an example production-ready server.
The deployment on the Kubernetes environment will be discussed in the next article.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_method_1_package_manager_installation">Method 1: Package Manager Installation</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_rhelfedoracentos">RHEL/Fedora/CentOS</h3>
<div class="paragraph">
<p>On RHEL or CentOS, before you can install OpenBao you need to install the EPEL repository. To do so, you first need to enable the Code Ready Repository. The following commands will do the trick. Be sure that your system is registered, in case of RHEL.</p>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
If you get the error &#34;Repositories disabled by configuration.&#34; you need to tell the subscription manager that you want to manage the repositories. This can be done permanently or temporarily. You can use the command: <strong>sudo subscription-manager config --rhsm.manage_repos=1</strong> to do so.
</td>
</tr>
</tbody></table>
</div>
<div class="sect3">
<h4 id="_rhel">RHEL</h4>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Enable Code Ready Repository</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">sudo subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms</code></pre>
</div>
</div>
</li>
<li>
<p>Install EPEL Repository</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm</code></pre>
</div>
</div>
</li>
<li>
<p>Install OpenBao</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">sudo dnf install -y openbao</code></pre>
</div>
</div>
</li>
</ol>
</div>
</div>
<div class="sect3">
<h4 id="_centos">CentOS</h4>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Enable Code Ready Repository on CentOS</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">sudo dnf config-manager --set-enabled crb</code></pre>
</div>
</div>
</li>
<li>
<p>Install EPEL Repository</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">sudo dnf install epel-release epel-next-release</code></pre>
</div>
</div>
</li>
<li>
<p>Install OpenBao</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">sudo dnf install -y openbao</code></pre>
</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_macos_homebrew">macOS (Homebrew)</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Install OpenBao</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">brew install openbao</code></pre>
</div>
</div>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_verify_installation">Verify Installation</h3>
<div class="paragraph">
<p>After installation, verify OpenBao is available:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao version
# Output:
OpenBao v2.5.0 (bcbb6036ec2b747bceb98c7706ce9b974faa1b23), built 2026-02-04T15:57:17Z (cgo)</code></pre>
</div>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
The OpenBao CLI command is <code>bao</code>, not <code>vault</code>. This distinguishes it from HashiCorp Vault.
</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_start_development_server">Start Development Server</h3>
<div class="paragraph">
<p>To start a development environment, you can use the following command.</p>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
This is NOT suitable for production, it is just a test to evaluate the basic concepts of OpenBao.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao server -dev -dev-root-token-id=&#34;dev-only-token&#34;</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will start the server. The UI is accessible at <a class="bare" href="http://localhost:8200">http://localhost:8200</a> where you can login using the root token <code>dev-only-token</code>.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_method_2_container_image">Method 2: Container Image</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For quick testing or isolated environments, container images are ideal. Luckily, OpenBao offers several types of containers suitable for any environment. We will use the image hosted on <strong>quay.io</strong>, which is based on <strong>RHEL UBI</strong> and can be found at: <a href="https://quay.io/openbao/openbao-ubi" rel="noopener" target="_blank">quay.io/openbao/openbao-ubi</a></p>
</div>
<div class="sect2">
<h3 id="_using_podman">Using Podman</h3>
<div class="paragraph">
<p>The following command will fetch the image and start the container.</p>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
This is NOT suitable for production, it is just a test to evaluate the basic concepts of OpenBao.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Run in dev mode (for testing only!)
podman run --rm -d \
  --name openbao-dev \
  -p 8200:8200 \
  -e &#39;BAO_DEV_ROOT_TOKEN_ID=dev-only-token&#39; \
  -e &#39;BAO_DEV_LISTEN_ADDRESS=0.0.0.0:8200&#39; \
  quay.io/openbao/openbao-ubi:latest server -dev</code></pre>
</div>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Verify it is running
podman logs -f openbao-dev</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will start the server. The UI is accessible at <a class="bare" href="http://localhost:8200">http://localhost:8200</a> where you can login using the root token <code>dev-only-token</code>.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If you prefer to use Docker, simply replace <code>podman</code> with <code>docker</code> in the commands.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_dev_mode_quick_start_for_testing">Dev Mode: Quick Start for Testing</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Dev mode is the fastest way to start using OpenBao for learning and testing.</p>
</div>
<div class="paragraph">
<p>The characteristics in this mode are:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In-memory storage (data lost on restart)</p>
</li>
<li>
<p>Automatically initialized and unsealed</p>
</li>
<li>
<p>Root token printed to stdout</p>
</li>
<li>
<p>TLS disabled</p>
</li>
<li>
<p>Single server (no HA)</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Let’s create an example secret and try to retrieve it again.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Authenticate against OpenBao</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">export VAULT_TOKEN=&#34;dev-only-token&#34;
export BAO_ADDR=&#39;http://127.0.0.1:8200&#39;</code></pre>
</div>
</div>
</li>
<li>
<p>Create Secret</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">curl \
  --header &#34;X-Vault-Token: $VAULT_TOKEN&#34; \
  --header &#34;Content-Type: application/json&#34; \
  --request POST \
  --data &#39;{&#34;data&#34;: {&#34;password&#34;: &#34;OpenBao123&#34;}}&#39; \
  $BAO_ADDR/v1/secret/data/my-secret-password &amp;&amp;
  echo &#34;Secret written successfully.&#34;</code></pre>
</div>
</div>
</li>
<li>
<p>Retrieve Secret</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">curl --header &#34;X-Vault-Token: $VAULT_TOKEN&#34; \
  $BAO_ADDR/v1/secret/data/my-secret-password | jq &#39;.data.data&#39;</code></pre>
</div>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>You should see the password that was created before:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-json hljs" data-lang="json">{
  &#34;password&#34;: &#34;OpenBao123&#34;
}</code></pre>
</div>
</div>
<div class="sect2">
<h3 id="_check_status_of_openbao_server">Check Status of OpenBao Server</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao status</code></pre>
</div>
</div>
<div class="paragraph">
<p>This will give you the status of your running OpenBao instance.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Key             Value
---             -----
Seal Type       shamir
Initialized     true
Sealed          false
Total Shares    1
Threshold       1
Version         2.5.0
Build Date      2026-02-04T15:57:17Z
Storage Type    inmem
Cluster Name    vault-cluster-421b2431
Cluster ID      6d42dcd2-e399-211e-999a-49b1874cc8ce
HA Enabled      false</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_hardening_your_system">Hardening your System</h2>
<div class="sectionbody">
<div class="paragraph">
<p>OpenBao does a good job to secure your secrets, however, memory paging (or swap) can undermine the protection. Your OS should either have swap disabled completely or encrypt the swap space.</p>
</div>
<div class="paragraph">
<p>As I am testing on macOS, the swap space is encrypted out of the box.</p>
</div>
<div class="paragraph">
<p>However, OpenBao has documented what must be done for various operating systems at <a href="https://openbao.org/docs/install/#post-installation-hardening" rel="noopener" target="_blank">Post-installation hardening</a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_production_standalone_setup">Production Standalone Setup</h2>
<div class="sectionbody">
<div class="paragraph">
<p>For a proper standalone installation, follow these steps:</p>
</div>
<div class="sect2">
<h3 id="_step_1_create_configuration_file">Step 1: Create Configuration File</h3>
<div class="paragraph">
<p>Create <code>/etc/openbao.d/openbao.hcl</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-hcl hljs" data-lang="hcl"># Full configuration for standalone OpenBao server

# Cluster name for identification
cluster_name = &#34;openbao-standalone&#34;

# Storage backend using integrated Raft
storage &#34;raft&#34; {
  path    = &#34;/var/lib/openbao/data&#34;
  node_id = &#34;node1&#34;
}

# HTTP listener (for internal communication)
listener &#34;tcp&#34; {
  address         = &#34;0.0.0.0:8200&#34;
  cluster_address = &#34;0.0.0.0:8201&#34;
  tls_disable     = false
  tls_cert_file   = &#34;/etc/openbao.d/tls/tls.crt&#34;
  tls_key_file    = &#34;/etc/openbao.d/tls/tls.key&#34;
}

# API address for clients
api_addr = &#34;https://openbao.example.com:8200&#34;

# Cluster address for raft communication
cluster_addr = &#34;https://openbao.example.com:8201&#34;

# UI enabled
ui = true

# Logging
log_level = &#34;info&#34;
log_file  = &#34;/var/log/openbao/openbao.log&#34;

# Disable memory locking (enable in production if possible)
disable_mlock = true

# Telemetry (optional)
telemetry {
  prometheus_retention_time = &#34;30s&#34;
  disable_hostname          = true
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_step_2_generate_tls_certificates">Step 2: Generate TLS Certificates</h3>
<div class="paragraph">
<p>For production, you should use proper certificates. For testing, create self-signed ones:</p>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
This is only for testing purposes. In production, you should use proper certificates.
</td>
</tr>
</tbody></table>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>First, prepare the TLS directory if it does not exist</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">sudo mkdir -p /etc/openbao.d/tls</code></pre>
</div>
</div>
</li>
<li>
<p>Then create a configuration file for the TLS certificates:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Create TLS config
cat &lt;&lt;EOF &gt; openbao.cnf
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no

[req_distinguished_name]
CN = openbao.example.com

[v3_req]
subjectAltName = @alt_names

[alt_names]
DNS.1 = openbao.example.com
IP.1 = 127.0.0.1 <i class="conum" data-value="1"></i><b>(1)</b>
EOF</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The IP address of the server. In this case we are using localhost, but you can add your IPs here.</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Then generate the certificate:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Generate private key
sudo openssl genrsa -out /etc/openbao.d/tls/tls.key 4096

# Generate certificate signing request
sudo openssl req -new -key /etc/openbao.d/tls/tls.key -out /etc/openbao.d/tls/tls.csr -subj &#34;/CN=openbao.example.com&#34;

# Generate self-signed certificate
sudo openssl x509 -req -days 365 -in /etc/openbao.d/tls/tls.csr -signkey /etc/openbao.d/tls/tls.key -out /etc/openbao.d/tls/tls.crt -extfile openbao.cnf -extensions v3_req

# Set permissions
sudo chown -R openbao:openbao /etc/openbao.d/tls
sudo chmod 600 /etc/openbao.d/tls/tls.key
sudo chmod 755 /etc/openbao.d/tls</code></pre>
</div>
</div>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_step_3_create_systemd_service">Step 3: Create Systemd Service</h3>
<div class="paragraph">
<p>Create <code>/etc/systemd/system/openbao.service</code>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-ini hljs" data-lang="ini">[Unit]
Description=OpenBao Secret Management
Documentation=https://openbao.org/docs
Requires=network-online.target
After=network-online.target
ConditionFileNotEmpty=/etc/openbao.d/openbao.hcl

[Service]
User=openbao
Group=openbao
ProtectSystem=full
ProtectHome=read-only
PrivateTmp=yes
PrivateDevices=yes
SecureBits=keep-caps
AmbientCapabilities=CAP_IPC_LOCK
CapabilityBoundingSet=CAP_SYSLOG CAP_IPC_LOCK
NoNewPrivileges=yes
ExecStart=/usr/bin/bao server -config=/etc/openbao.d/openbao.hcl
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=5
TimeoutStopSec=30
LimitNOFILE=65536
LimitMEMLOCK=infinity

[Install]
WantedBy=multi-user.target</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_step_4_start_the_service">Step 4: Start the Service</h3>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Reload systemd
sudo systemctl daemon-reload

# Enable and start OpenBao
sudo systemctl enable openbao
sudo systemctl start openbao

# Check status
sudo systemctl status openbao

# View logs
sudo journalctl -u openbao -f</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_initialize_and_unseal_openbao">Initialize and Unseal OpenBao</h2>
<div class="sectionbody">
<div class="paragraph">
<p>After starting OpenBao for the first time, it needs to be initialized and unsealed.</p>
</div>
<div class="sect2">
<h3 id="_set_environment_variables">Set Environment Variables</h3>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
We will do the following commands as root user.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Be sure that the hostname is resolvable. In this case I am using the test domain: openbao.example.com.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Set the OpenBao address
export BAO_ADDR=&#39;https://openbao.example.com:8200&#39;

# If using self-signed certificates
export BAO_CACERT=&#39;/etc/openbao.d/tls/tls.crt&#39;</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_check_status">Check Status</h3>
<div class="paragraph">
<p>You will see that OpenBao is running but not yet initialized. This will be the next step.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao status

Key                Value
---                -----
Seal Type          shamir
Initialized        false <i class="conum" data-value="1"></i><b>(1)</b>
Sealed             true
Total Shares       0
Threshold          0
Unseal Progress    0/0
Unseal Nonce       n/a
Version            2.4.4-1.el9
Build Date         2025-11-24
Storage Type       file
HA Enabled         false</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Not yet initialized</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_initialize_openbao">Initialize OpenBao</h3>
<div class="paragraph">
<p>Before we use OpenBao, we need to initialize it. This will create the unseal keys and the root token. The unseal keys are used to … well, unseal the OpenBao service.
The root token is used as a master key to authenticate against the OpenBao service. This token has access to ALL secrets. <strong>Treat this root token with care.</strong></p>
</div>
<div class="paragraph">
<p>We will initialize OpenBao with default options of 5 key shares and a threshold of 3. This means that we need 3 different unseal keys to unseal the OpenBao service.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao operator init -key-shares=5 -key-threshold=3 -format=json &gt; /root/openbao-init.json</code></pre>
</div>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Store the unseal keys and root token securely! Anyone with these can access all secrets.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The output looks like:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-json hljs" data-lang="json">{
  &#34;unseal_keys_b64&#34;: [
    &#34;key1...&#34;,
    &#34;key2...&#34;,
    &#34;key3...&#34;,
    &#34;key4...&#34;,
    &#34;key5...&#34;
  ],
  &#34;unseal_keys_hex&#34;: [...],
  &#34;unseal_shares&#34;: 5,
  &#34;unseal_threshold&#34;: 3,
  &#34;recovery_keys_b64&#34;: [],
  &#34;recovery_keys_hex&#34;: [],
  &#34;root_token&#34;: &#34;sbr.xxxxxxxxxxxx&#34;
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_unseal_openbao">Unseal OpenBao</h3>
<div class="paragraph">
<p>Now everything is set up and we can use the unseal keys to unseal the OpenBao service.</p>
</div>
<div class="paragraph">
<p>You need to provide 3 (threshold) different unseal keys:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># First key
bao operator unseal
# Enter first unseal key

# Second key
bao operator unseal
# Enter second unseal key

# Third key
bao operator unseal
# Enter third unseal key</code></pre>
</div>
</div>
<div class="paragraph">
<p>After providing enough keys:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao status

Key             Value
---             -----
Seal Type       shamir
Initialized     true
Sealed          false <i class="conum" data-value="1"></i><b>(1)</b>
Total Shares    5
Threshold       3
Version         2.4.4-1.el9
Build Date      2025-11-24
Storage Type    file
Cluster Name    openbao-standalone
Cluster ID      d07874ef-df52-e45f-1723-ade333c6d609
HA Enabled      false</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Now unsealed and ready</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Now we can login with the root token to the OpenBao service.</p>
</div>
</div>
<div class="sect2">
<h3 id="_login_with_root_token">Login with Root Token</h3>
<div class="paragraph">
<p>Since we have not created any users yet, we will use the root token to authenticate.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash"># Enter the root token from initialization
bao login</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_basic_verification">Basic Verification</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Let us verify the installation works:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>List enabled secrets engines</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao secrets list</code></pre>
</div>
</div>
<div class="paragraph">
<p>This lists the enabled secrets engines.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Path          Type         Accessor              Description
----          ----         --------              -----------
cubbyhole/    cubbyhole    cubbyhole_84c3d2a5    per-token private secret storage
identity/     identity     identity_61809171     identity store
sys/          system       system_034ae772       system endpoints used for control, policy and debugging</code></pre>
</div>
</div>
</li>
<li>
<p>List enabled auth methods</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao auth list</code></pre>
</div>
</div>
<div class="paragraph">
<p>This lists the enabled authentication methods.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">Path      Type     Accessor               Description                Version
----      ----     --------               -----------                -------
token/    token    auth_token_c7feca17    token based credentials    n/a</code></pre>
</div>
</div>
</li>
<li>
<p>Create a test secret</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao secrets enable -path=secret kv-v2</code></pre>
</div>
</div>
<div class="paragraph">
<p>This enables the KV (key/value) secrets engine at the path <code>secret</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao kv put secret/test message=&#34;Hello from OpenBao&#34;</code></pre>
</div>
</div>
<div class="paragraph">
<p>This creates a test secret at the path <code>secret/test</code>.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">bao kv get secret/test</code></pre>
</div>
</div>
<div class="paragraph">
<p>This retrieves the test secret from the path <code>secret/test</code>.</p>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>That’s it for the basic verification. You can now start to use OpenBao in your production environment. Let’s see what we can do in the UI.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_visiting_the_ui">Visiting the UI</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you watched the previous commands closely, you will have noticed that the UI has been enabled in the configuration file:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-hcl hljs" data-lang="hcl"># UI enabled
ui = true</code></pre>
</div>
</div>
<div class="paragraph">
<p>The UI is accessible at <a class="bare" href="http://openbao.example.com:8200">http://openbao.example.com:8200</a>. You can login with the root token from the initialization.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part2_openbao_login_form.png?width=480px" alt="OpenBao Login Form"/>
</div>
<div class="title">Figure 1. OpenBao Login Form</div>
</div>
<div class="paragraph">
<p>Here you will see several options to explore. For now we are interested in the Secrets Engine section.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part2_openbao_secrets_engine.png?width=480px" alt="OpenBao Secrets Engine"/>
</div>
<div class="title">Figure 2. OpenBao Secrets Engine</div>
</div>
<div class="paragraph">
<p>We have created the path &#34;secret&#34; and inside it a secret called &#34;test&#34;.
We can retrieve it now:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part2_test_secret_retrieval.png?width=480px" alt="OpenBao Secret Retrieval"/>
</div>
<div class="title">Figure 3. OpenBao Secret Retrieval</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_security_hardening_checklist">Security Hardening Checklist</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before using OpenBao in production you should always consider the following checklist:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;"/>
<col style="width: 75%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Item</th>
<th class="tableblock halign-left valign-top">Recommendation</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">TLS</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Always enable TLS with valid certificates</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Root Token</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Revoke root token after initial setup and create admin users instead</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Unseal Keys</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Distribute to different people/locations, consider auto-unseal</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Network</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Restrict access with firewall rules</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Audit</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enable audit logging</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Backups</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Regular Raft snapshots</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Updates</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Keep OpenBao updated</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect1">
<h2 id="_what_is_coming_next">What is Coming Next?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In Part 3, we will deploy OpenBao on OpenShift/Kubernetes using the official Helm chart. This provides:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>High availability out of the box</p>
</li>
<li>
<p>Kubernetes-native management</p>
</li>
<li>
<p>Integration with OpenShift security features</p>
</li>
<li>
<p>Persistent storage via PVCs</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>You now have a working standalone OpenBao installation. This forms the foundation for understanding how OpenBao operates. While standalone mode is useful for testing and edge cases, most production deployments will use Kubernetes, which we will cover next.</p>
</div>
<div class="paragraph">
<p>Key takeaways:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenBao can run standalone or in containers</p>
</li>
<li>
<p>Dev mode is for testing only</p>
</li>
<li>
<p>Production requires proper TLS, initialization, and security hardening</p>
</li>
<li>
<p>Unseal keys must be stored securely</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org/docs/install" rel="noopener" target="_blank">OpenBao Installation Documentation</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/configuration" rel="noopener" target="_blank">OpenBao Configuration Reference</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs/commands" rel="noopener" target="_blank">OpenBao CLI Reference</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>The Guide to OpenBao - Introduction - Part 1</title><link>https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-11-openbao-part-1-introduction/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/secrets-management/openbao/2026-02-11-openbao-part-1-introduction/</guid><pubDate>Wed, 11 Feb 2026 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Introduction to OpenBao - What it is, why it exists, and when to use it for secret management</description><content:encoded><![CDATA[<div class="paragraph">
<p>I finally had some time to dig into Secret Management. For my demo environments, SealedSecrets is usually enough to quickly test something. But if you want to deploy a real application with Secret Management, you need to think of a more permanent solution.</p>
</div>
<div class="paragraph">
<p>This article is the first of a series of articles about <strong>OpenBao</strong>, a HashiCorp Vault fork. Today, we will explore what OpenBao is, why it was created, and when you should consider using it for your secret management needs. If you are familiar with HashiCorp Vault, you will find many similarities, but also some important differences that we will discuss.</p>
</div>
<div class="sect1">
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In general, sensitive information in any system should be stored in a secure way. When it comes to OpenShift or Kubernetes, this is especially true, since the secrets are stored in the etcd database. Even if etcd is encrypted at rest, anybody can decode a given base64 string which is stored in the Secret.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Base64 is not an encryption format. It is an encoding format.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>For example, the string <code>Thomas</code> encoded as base64 is <code>VGhvbWFzCg==</code>. This is simply masked plain text and it is not secure to share these values, especially not on Git. To make your CI/CD pipelines or GitOps process secure, you need to think of a secure way to manage your Secrets.</p>
</div>
<div class="paragraph">
<p>This is where OpenBao comes in.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_what_is_openbao">What is OpenBao?</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://openbao.org" rel="noopener" target="_blank">OpenBao</a> is an identity-based secrets and encryption management system. It is an open-source, community driven fork of HashiCorp Vault and provides secure storage, fine-grained access control, and lifecycle management for secrets such as API or SSH keys, passwords, certificates, and encryption keys.</p>
</div>
<div class="paragraph">
<p>The core OpenBao workflow consists of four stages:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Authentication</strong>: Verifying the identity of the client to determine if they are who they say they are. Once authenticated, a token is created and associated with a so-called policy.</p>
</li>
<li>
<p><strong>Validation</strong>: Checking if the client has the required permissions</p>
</li>
<li>
<p><strong>Authorization</strong>: Granting access based on policies that provide or deny access to certain paths and operations in OpenBao.</p>
</li>
<li>
<p><strong>Access</strong>: Limiting what the client can do with the secret</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>At its core, OpenBao:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Stores and encrypts sensitive information at rest and in transit</p>
</li>
<li>
<p>Provides fine-grained access controls (ACL)</p>
</li>
<li>
<p>Supports dynamic secret generation</p>
</li>
<li>
<p>Offers a comprehensive audit trail (must be enabled)</p>
</li>
<li>
<p>Enables encryption as a service</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_the_history_why_openbao_exists">The History: Why OpenBao Exists</h2>
<div class="sectionbody">
<div class="paragraph">
<p>OpenBao is a community-driven, open-source fork of HashiCorp Vault. But why was it created?</p>
</div>
<div class="paragraph">
<p>In August 2023, HashiCorp announced a significant change to the licensing of their products, including Vault. They moved from the Mozilla Public License 2.0 (MPL 2.0) to the Business Source License 1.1 (BSL 1.1).</p>
</div>
<div class="paragraph">
<p>The BSL 1.1 license includes restrictions on competitive use:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Competitors could no longer use Vault’s code to offer competing services</p>
</li>
<li>
<p>Cloud providers and managed service providers faced restrictions</p>
</li>
<li>
<p>The open-source community lost the freedom to fork and commercialize</p>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_the_fork">The Fork</h3>
<div class="paragraph">
<p>In response to this license change, the Linux Foundation announced the OpenBao project in December 2023. OpenBao is:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>A fork of HashiCorp Vault (from version 1.14.x)</p>
</li>
<li>
<p>Licensed under the OSI-approved Mozilla Public License 2.0</p>
</li>
<li>
<p>Governed by a community-driven model</p>
</li>
<li>
<p>Maintained independently of HashiCorp</p>
</li>
<li>
<p>Continues to enable innovation without license restrictions</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_openbao_vs_hashicorp_vault_key_differences">OpenBao vs. HashiCorp Vault: Key Differences</h2>
<div class="sectionbody">
<div class="paragraph">
<p>While OpenBao shares its heritage with Vault, there are several important differences:</p>
</div>
<div class="sect2">
<h3 id="_licensing">Licensing</h3>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;"/>
<col style="width: 40%;"/>
<col style="width: 40%;"/>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Aspect</th>
<th class="tableblock halign-left valign-top">OpenBao</th>
<th class="tableblock halign-left valign-top">HashiCorp Vault</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">License</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">MPL 2.0 (OSI-approved open source)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">BSL 1.1 (with staged conversion)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Governance</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Community-driven (Linux Foundation)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">HashiCorp/IBM controlled</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Commercial restrictions</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">None</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Restrictions on competitive use</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Enterprise Features</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Community-driven additions</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Paid Enterprise tier</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Support</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Community support</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Paid support available</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Branding</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">bao CLI, OpenBao naming</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">vault CLI, Vault naming</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="_technical_differences">Technical Differences</h3>
<div class="ulist">
<ul>
<li>
<p><strong>Token Format</strong> - OpenBao uses shorter tokens in the format <code>sbr.<a href="#random">[random]</a></code>, while Vault uses longer tokens (<code>hvs.</code>, <code>hvb.</code>, <code>hvr.</code> prefixes followed by long random strings). Old Vault tokens are still accepted according to their TTLs, but newly issued tokens follow the OpenBao format.</p>
</li>
<li>
<p><strong>Plugin Ecosystem</strong> - OpenBao comes with fewer built-in plugins by default, focusing on OSI-licensed integrations. Proprietary cloud vendor plugins have been moved to external repositories.</p>
</li>
<li>
<p><strong>Storage Backend</strong> - OpenBao has simplified its storage options, primarily supporting Raft as the recommended backend.</p>
</li>
<li>
<p><strong>API Compatibility</strong> - OpenBao’s API is designed to be compatible with Vault, meaning existing clients and integrations should work without modification. However, some edge cases may require updates.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_core_concepts">Core Concepts</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before diving into installation and configuration in the next articles, it is essential to understand the fundamental concepts of OpenBao:</p>
</div>
<div class="sect2">
<h3 id="_secrets_engines">Secrets Engines</h3>
<div class="paragraph">
<p>Secrets engines are components that store, generate, or encrypt data. OpenBao supports multiple types:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>KV (Key-Value)</strong>: Simple static secret storage with optional versioning</p>
</li>
<li>
<p><strong>PKI</strong>: Certificate Authority for generating TLS certificates</p>
</li>
<li>
<p><strong>Database</strong>: Dynamic credential generation for databases</p>
</li>
<li>
<p><strong>Transit</strong>: Encryption as a Service (EaaS)</p>
</li>
<li>
<p><strong>SSH</strong>: SSH key signing and OTP generation</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_authentication_methods">Authentication Methods</h3>
<div class="paragraph">
<p>Authentication methods verify client identity before granting access:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Kubernetes</strong>: Uses Kubernetes service account tokens. Essential for Kubernetes/OpenShift deployments.</p>
</li>
<li>
<p><strong>OIDC</strong>: OpenID Connect for user authentication, like Keycloak, Okta, or Azure AD.</p>
</li>
<li>
<p><strong>LDAP</strong>: Directory service authentication, like Active Directory, OpenLDAP, or Microsoft AD.</p>
</li>
<li>
<p><strong>AppRole</strong>: Machine-oriented authentication for applications. Ideal for CI/CD pipelines.</p>
</li>
<li>
<p><strong>Token</strong>: Direct token-based authentication. The root token is created during initialization.</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_storage_backend">Storage Backend</h3>
<div class="paragraph">
<p>OpenBao encrypts all data before writing to storage. Supported backends include:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Integrated Raft</strong> (recommended): Built-in distributed storage</p>
</li>
<li>
<p><strong>Consul</strong>: HashiCorp’s service discovery and KV store (less common with OpenBao)</p>
</li>
<li>
<p><strong>File</strong>: Single-node deployments only</p>
</li>
<li>
<p><strong>PostgreSQL/MySQL</strong>: Database-backed storage</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_policies">Policies</h3>
<div class="paragraph">
<p>Policies define what a client can do after authentication. They use path-based access control (deny-by-default mode):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-hcl hljs" data-lang="hcl">path &#34;secret/data/myapp/*&#34; {
  capabilities = [&#34;read&#34;, &#34;list&#34;]
}

path &#34;pki/issue/my-role&#34; {
  capabilities = [&#34;create&#34;, &#34;update&#34;]
}

path &#34;database/creds/myapp-role&#34; {
  capabilities = [&#34;read&#34;]
}</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_tokens">Tokens</h3>
<div class="paragraph">
<p>Tokens are the primary authentication credential in OpenBao. After successful authentication, clients receive a token that:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Has a TTL (Time To Live)</p>
</li>
<li>
<p>Is associated with one or more policies</p>
</li>
<li>
<p>Can be renewed (if renewable)</p>
</li>
<li>
<p>Can create child tokens</p>
</li>
</ul>
</div>
</div>
<div class="sect2">
<h3 id="_sealunseal">Seal/Unseal</h3>
<div class="paragraph">
<p>OpenBao starts in a <strong>sealed</strong> state where it cannot access encrypted data. The unseal process requires multiple key shares (using Shamir’s Secret Sharing) or auto-unseal mechanisms to decrypt the master key.</p>
</div>
</div>
<div class="sect2">
<h3 id="_leases">Leases</h3>
<div class="paragraph">
<p>Most secrets in OpenBao have an associated lease - a duration after which the secret expires. This enables:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Automatic secret rotation</p>
</li>
<li>
<p>Revocation of compromised credentials</p>
</li>
<li>
<p>Audit trail of secret usage</p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_use_cases">Use Cases</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_dynamic_database_credentials">Dynamic Database Credentials</h3>
<div class="paragraph">
<p>Instead of storing static database passwords:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Application authenticates to OpenBao</p>
</li>
<li>
<p>Requests database credentials</p>
</li>
<li>
<p>OpenBao creates a temporary database user</p>
</li>
<li>
<p>Returns credentials with a short TTL</p>
</li>
<li>
<p>Credentials automatically expire</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Benefits: No long-lived credentials, automatic rotation, per-application isolation.</p>
</div>
</div>
<div class="sect2">
<h3 id="_certificate_management_with_pki">Certificate Management with PKI</h3>
<div class="paragraph">
<p>Instead of manually managing TLS certificates:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Configure OpenBao as an intermediate CA</p>
</li>
<li>
<p>Applications request certificates on demand</p>
</li>
<li>
<p>Short-lived certificates (hours/days instead of years)</p>
</li>
<li>
<p>Automatic renewal before expiration</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Benefits: No certificate sprawl, automated rotation, reduced attack surface.</p>
</div>
</div>
<div class="sect2">
<h3 id="_encryption_as_a_service">Encryption as a Service</h3>
<div class="paragraph">
<p>Instead of implementing encryption in each application:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Applications send plaintext to OpenBao’s Transit engine</p>
</li>
<li>
<p>OpenBao encrypts with managed keys</p>
</li>
<li>
<p>Applications store ciphertext</p>
</li>
<li>
<p>Decryption requests go through OpenBao</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Benefits: Centralized key management, separation of duties, key rotation without re-encryption.</p>
</div>
</div>
<div class="sect2">
<h3 id="_kubernetes_secret_injection">Kubernetes Secret Injection</h3>
<div class="paragraph">
<p>Instead of storing secrets in Kubernetes Secrets:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Deploy OpenBao with Kubernetes auth</p>
</li>
<li>
<p>Configure injector or External Secrets Operator</p>
</li>
<li>
<p>Pods automatically receive secrets at startup</p>
</li>
<li>
<p>Secrets never stored in etcd</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Benefits: Secrets not in cluster, dynamic injection, centralized management.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_when_to_use_openbao">When to Use OpenBao</h2>
<div class="sectionbody">
<div class="paragraph">
<p>OpenBao is an excellent choice when you need:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Centralized Secret Management</strong> - If you have secrets scattered across configuration files, environment variables, and various secret stores, OpenBao provides a single source of truth.</p>
</li>
<li>
<p><strong>Dynamic Secrets</strong> - For use cases where you need short-lived, automatically rotated credentials (e.g., database passwords), OpenBao can generate them on-demand.</p>
</li>
<li>
<p><strong>Encryption as a Service</strong> - If applications need encryption capabilities without managing encryption keys, OpenBao’s Transit engine provides this functionality.</p>
</li>
<li>
<p><strong>Certificate Management</strong> - OpenBao’s PKI engine can act as a Certificate Authority, issuing and managing TLS certificates.</p>
</li>
<li>
<p><strong>Compliance Requirements</strong> - For environments with strict audit requirements, OpenBao provides comprehensive audit logging of all secret access.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_when_not_to_use_openbao">When NOT to Use OpenBao</h2>
<div class="sectionbody">
<div class="paragraph">
<p>OpenBao might be overkill for:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Simple, Static Secrets</strong> - If you only have a few static secrets that rarely change, simpler solutions like Sealed Secrets or External Secrets Operator with a basic backend might suffice.</p>
</li>
<li>
<p><strong>Small Teams with Limited Resources</strong> - OpenBao requires operational expertise to maintain. If you do not have the resources to operate it properly, consider managed alternatives.</p>
</li>
<li>
<p><strong>Single-Application Deployments</strong> - If you have a single application with minimal secret requirements, the complexity of OpenBao may not be justified.</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_architecture_overview">Architecture Overview</h2>
<div class="sectionbody">
<div class="paragraph">
<p>A typical OpenBao deployment consists of:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/secrets-management/openbao/images/part1_openbao_architecture.png" alt="Architecture Overview"/>
</div>
<div class="title">Figure 1. Architecture Overview</div>
</div>
<div class="ulist">
<ul>
<li>
<p><strong>Multiple Nodes</strong>: For high availability (HA), OpenBao runs as a cluster</p>
</li>
<li>
<p><strong>Raft Consensus</strong>: Leader election and data replication</p>
</li>
<li>
<p><strong>Persistent Storage</strong>: Encrypted data stored on persistent volumes</p>
</li>
<li>
<p><strong>Load Balancer</strong>: Distributes client requests</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>OpenBao provides a powerful, open-source solution for secret management that addresses the challenges of modern cloud-native environments. Its fork from HashiCorp Vault means it benefits from years of development while remaining truly open source.</p>
</div>
<div class="paragraph">
<p>In the next article, we will start with a standalone installation to understand the fundamentals before moving to Kubernetes deployments.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_resources">Resources</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://openbao.org" rel="noopener" target="_blank">OpenBao Official Website</a></p>
</li>
<li>
<p><a href="https://openbao.org/docs" rel="noopener" target="_blank">OpenBao Documentation</a></p>
</li>
<li>
<p><a href="https://github.com/openbao/openbao" rel="noopener" target="_blank">OpenBao GitHub Repository</a></p>
</li>
<li>
<p><a href="https://www.linuxfoundation.org/press/linux-foundation-launches-openbao" rel="noopener" target="_blank">Linux Foundation OpenBao Announcement</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>Hosted Control Planes behind a Proxy</title><link>https://blog.stderr.at/openshift-platform/other-topics/2025-12-15-hosted-control-planes-and-proxy/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/other-topics/2025-12-15-hosted-control-planes-and-proxy/</guid><pubDate>Mon, 15 Dec 2025 00:00:00 +0100</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Installation</category><category>Security</category><description>Run OpenShift Hosted Control Planes behind an HTTP proxy: configure the management cluster and Hypershift so spoke clusters can pull images and reach APIs.</description><content:encoded><![CDATA[<div class="paragraph">
<p>Recently, I encountered a problem deploying a Hosted Control Plane (HCP) at a customer site. The installation started successfully—etcd came up fine—but then it just stopped. The virtual machines were created, but they never joined the cluster. No OVN or Multus pods ever started.
The only meaningful message in the cluster-version-operator pod logs was:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-console hljs" data-lang="console">I1204 08:22:35.473783       1 status.go:185] Synchronizing status errs=field.ErrorList(nil) status=&amp;cvo.SyncWorkerStatus{Generation:1, Failure:(*payload.UpdateError)(0xc0006313b0), Done:575, Total:623,</code></pre>
</div>
</div>
<div class="paragraph">
<p>This message did appear over and over again.</p>
</div>
<div class="sect1">
<h2 id="_problem_summary">Problem Summary</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p>etcd started successfully, but the installation stalled</p>
</li>
<li>
<p>API server was running</p>
</li>
<li>
<p>VMs started but never joined the cluster</p>
</li>
<li>
<p>No OVN or Multus pods ever started</p>
</li>
<li>
<p>The installation was stuck in a loop</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_troubleshooting">Troubleshooting</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Troubleshooting was not straightforward. The cluster-version-operator logs provided the only clue.
However, the VMs were already running, so we could log in to them—and there it was, the reason for the stalled installation.</p>
</div>
<div class="sect2">
<h3 id="_connect_to_a_vm">Connect to a VM</h3>
<div class="paragraph">
<p>To connect to a VM, use the <code>virtctl</code> command. This connects you to the machine as the <code>core</code> user:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
You can download <code>virtctl</code> from the OpenShift Downloads page in the OpenShift web console.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock warning">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
You need the SSH key for the <code>core</code> user.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">virtctl ssh -n clusters-my-hosted-cluster core@vmi/my-node-pool-dsj7z-sss8w <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Replace <strong>my-hosted-cluster</strong> with the name of your hosted cluster and <strong>my-node-pool-dsj7z-sss8w</strong> with the name of your VM.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_verify_the_problem">Verify the Problem</h3>
<div class="paragraph">
<p>Once logged in, check the <code>journalctl -xf</code> output. In case of a proxy issue, you’ll see an error like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">&gt; Dec 10 06:23:09 my-node-pool2-gwvjh-rwtx8 sh[2143]: time=&#34;2025-12-10T06:23:09Z&#34; level=warning msg=&#34;Failed, retrying in 1s ... (3/3). Error: initializing source docker://quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:500704de3ef374e61417cc14eda99585450c317d72f454dda0dadd5dda1ba57a: pinging container registry quay.io: Get \&#34;https://quay.io/v2/\&#34;: dial tcp 3.209.93.201:443: i/o timeout&#34;</code></pre>
</div>
</div>
<div class="paragraph">
<p>So we have a timeout when trying to pull the image from the container registry. This is a classic proxy issue. When you try <code>curl</code> or manual pulls you will get the same message.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configuring_the_proxy_for_the_hosted_control_plane">Configuring the Proxy for the Hosted Control Plane</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The big question is: How do we configure the proxy for the Hosted Control Plane?</p>
</div>
<div class="paragraph">
<p>This is not well documented yet—in fact, it’s barely documented at all.</p>
</div>
<div class="paragraph">
<p>The Hosted Control Plane is managed through a custom resource called <code>HostedCluster</code>, and that’s exactly where we configure the proxy.
The upstream documentation at <a href="https://hypershift.pages.dev/how-to/configure-ocp-components/#overview" rel="noopener" target="_blank">HyperShift Documentation</a> explains that you can add a <code>configuration</code> section to the resource. Let’s do that:</p>
</div>
<div class="paragraph">
<p>Update the <code>HostedCluster</code> resource with the following configuration:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">spec:
  configuration:
    proxy:
      httpProxy: http://proxy.example.com:8080 <i class="conum" data-value="1"></i><b>(1)</b>
      httpsProxy: https://proxy.example.com:8080 <i class="conum" data-value="2"></i><b>(2)</b>
      noProxy: .cluster.local,.svc,10.128.0.0/14,127.0.0.1,localhost <i class="conum" data-value="3"></i><b>(3)</b>
      trustedCA:
        name: user-ca-bundle <i class="conum" data-value="4"></i><b>(4)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>HTTP proxy URL</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>HTTPS proxy URL</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Comma-separated list of domains, IPs, or CIDRs to exclude from proxy routing</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>OPTIONAL: Name of a ConfigMap containing a custom CA certificate bundle</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
If you’re using a custom CA, create the ConfigMap beforehand or alongside the <code>HostedCluster</code> resource. The ConfigMap must contain a key named <code>ca-bundle.crt</code> with your CA certificate(s).
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_but_wait_there_is_more">But wait there is more…​</h2>
<div class="sectionbody">
<div class="paragraph">
<p>If you are using such a proxy, which is injecting it’s own certificate, then you probably saw the following: The <strong>Release Image</strong> is not available when you try to deploy a new Hosted Control Plane.
The drop down in the UI is empty and you can’t select a release image.</p>
</div>
<div class="paragraph">
<p>This happens because the Pod that is trying to fetch the image is not able to connect to Github.</p>
</div>
<div class="paragraph">
<p>You can test this with the following commands:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc rsh cluster-image-set-controller-XXXXX -n multicluster-engine <i class="conum" data-value="1"></i><b>(1)</b>

curl -v https://github.com/stolostron/acm-hive-openshift-releases.git/info/refs?service=git-upload-pack <i class="conum" data-value="2"></i><b>(2)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Replace <strong>XXXXX</strong> with the name of the Pod cluster-image-set-controller in the <strong>multicluster-engine</strong> namespace</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Try to execute the curl command to see if you can connect to Github</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>If this command fails with a certificate error, then you need to add the certificate to the Pod/Deployment.
A Configmap called <strong>trusted-ca-bundle</strong> should already exist in the multicluster-engine namespace. If not, it must be created with the certificate chain of your Proxy (key: ca-bundle.crt)</p>
</div>
<div class="paragraph">
<p>The following command will add the ConfigMap to the deployment.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc -n multicluster-engine set volume deployment/cluster-image-set-controller --add --type configmap --configmap-name trusted-ca-bundle --name trusted-ca-bundle --mount-path /etc/pki/tls/certs/ --overwrite</code></pre>
</div>
</div>
<div class="paragraph">
<p>Wait a couple of minutes after the Pods has been restarted. It will try to download the release images from Github again.</p>
</div>
<div class="paragraph">
<p>You can check the logs of the Pod to see if the download was successful.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc logs cluster-image-set-controller-XXXXX -n multicluster-engine <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Replace <strong>XXXXX</strong> with the name of the Pod cluster-image-set-controller in the <strong>multicluster-engine</strong> namespace</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>That should do it, you should now be able to select a release image and deploy a new Hosted Control Plane.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/other-topics/images/HCP-Release-Images.png" alt="Release Images"/>
</div>
<div class="title">Figure 1. Drow Down with Release Images</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_summary">Summary</h2>
<div class="sectionbody">
<div class="paragraph">
<p>That’s actually everything you need for proxy configuration with Hosted Control Planes. Hopefully, the official OpenShift documentation will be updated soon to include this information.
red Hat created two tickets to track the progress of this:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="https://issues.redhat.com/browse/ACM-10151" rel="noopener" target="_blank">ACM-10151</a></p>
</li>
<li>
<p><a href="https://issues.redhat.com/browse/ACM-23664" rel="noopener" target="_blank">ACM-23664</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item><item><title>Red Hat Quay Registry - Integrate Keycloak</title><link>https://blog.stderr.at/openshift-platform/quay/2025-09-19-quay-integrate-keycloak/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/quay/2025-09-19-quay-integrate-keycloak/</guid><pubDate>Fri, 19 Sep 2025 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Quay</category><category>Security</category><description>Red Hat Quay Registry - Authentication with Keycloak</description><content:encoded><![CDATA[<div class="paragraph">
<p>This guide shows you how to configure Keycloak as an OpenID Connect (OIDC) provider for Red Hat Quay Registry. It covers what to configure in Keycloak, what to put into Quay’s config.yaml (or Operator config), how to verify the login flow, and how to switch your Quay initial/admin account (stored locally in Quay’s DB) to an admin user that authenticates via Keycloak.</p>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before starting this integration, ensure you have:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenShift cluster with admin access</p>
</li>
<li>
<p>Red Hat Quay Registry 3.15+ installed (via Operator)</p>
</li>
<li>
<p>Red Hat build of Keycloak stable-v22+ installed and configured (via Operator)</p>
</li>
<li>
<p>Valid SSL certificates for both Quay and Keycloak</p>
</li>
<li>
<p>Admin access to both Keycloak Admin Console and Quay configuration</p>
</li>
<li>
<p>Basic understanding of OIDC/OAuth2 concepts</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Here we are using the Quay Operator and the Keycloak Operator on OpenShift.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_quick_overview_what_happens">Quick overview (what happens)</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Create a Keycloak client for Quay (OIDC).</p>
</li>
<li>
<p>Configure Quay’s OIDC provider section in config.yaml to point to Keycloak (client id/secret, endpoints, scopes, claim names).</p>
</li>
<li>
<p>Restart Quay, test login via Keycloak. The first time an OIDC user logs in, Quay creates a local user record that is linked to the OIDC identity.</p>
</li>
<li>
<p>Promote that Quay user to superuser by adding their Quay username to SUPER_USERS (or use the UI/API).</p>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_keycloak_create_a_client_for_quay">Keycloak: create a client for Quay</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Steps in Keycloak Admin console:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Log in to the Keycloak Admin Console and select the realm you will use for Quay or create a new realm.</p>
</li>
<li>
<p>Select that realm and go to clients</p>
</li>
<li>
<p>Press <strong>Create client</strong> to create and configure a new client for Quay. Not much must be configured here, but at least the following:</p>
<div class="olist loweralpha">
<ol class="loweralpha" type="a">
<li>
<p>Client type: OpenID Connect</p>
</li>
<li>
<p>Client ID: quay-enterprise (The ID we will use in the Quay configuration as well)</p>
</li>
<li>
<p>Client authentication: ON</p>
</li>
<li>
<p>Valid redirects URIs:</p>
<div class="ulist">
<ul>
<li>
<p><a class="bare" href="https://&lt;quay-hostname&gt;/oauth2/&lt;service-id&gt;/callback">https://&lt;quay-hostname&gt;/oauth2/&lt;service-id&gt;/callback</a></p>
</li>
<li>
<p>(Optional) <a class="bare" href="https://&lt;quay-hostname&gt;/oauth2/&lt;service-id&gt;/callback/attach">https://&lt;quay-hostname&gt;/oauth2/&lt;service-id&gt;/callback/attach</a></p>
</li>
<li>
<p>(Optional) <a class="bare" href="https://&lt;quay-hostname&gt;/oauth2/&lt;service-id&gt;/callback/cli">https://&lt;quay-hostname&gt;/oauth2/&lt;service-id&gt;/callback/cli</a></p>
</li>
</ul>
</div>
</li>
</ol>
</div>
</li>
</ol>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The service-id is the parent key you’ll use in Quay config — e.g. keycloak.
</td>
</tr>
</tbody></table>
</div>
<div class="olist loweralpha">
<ol class="loweralpha" type="a">
<li>
<p>Save the client.</p>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Go to Credentials and create or copy the <strong>client secret</strong> you will use in Quay.</p>
</li>
</ol>
</div>
</li>
</ol>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<strong>(Optional)</strong> If you intend to use groups/roles from Keycloak for Quay team synchronization, ensure your Keycloak users or groups are populated and that Keycloak includes group membership in tokens or exposes group claims (you may need to add a protocol mapper in the client to include groups or roles in the ID token or userinfo response). Refer to Keycloak docs for adding protocol mappers.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_keycloak_create_users_and_groups">Keycloak: create users and groups</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Go to Users and create a new user or use an existing one.</p>
</li>
<li>
<p>If you created a new user, set a password for them in the Credentials tab.</p>
</li>
<li>
<p>Go to Groups and create a new group or use an existing one.</p>
</li>
<li>
<p>You can assign users to that group.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_quay_add_oidc_configuration">Quay: add OIDC configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Quay’s OIDC block is a nested object under <strong>AUTHENTICATION_TYPE: OIDC</strong>. The parent key can be any name (e.g., KEYCLOAK_LOGIN_CONFIG) — Quay uses the parent key name to form the callback paths.</p>
</div>
<div class="admonitionblock important">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
The parent key name (before _LOGIN_CONFIG) must match the service-id used in Keycloak redirect URIs.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Example config.yaml snippet for Keycloak:</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Using Quay Operator this configuration is stored as a secret in the namespace where Quay is installed.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">AUTHENTICATION_TYPE: OIDC <i class="conum" data-value="1"></i><b>(1)</b>
KEYCLOAK_LOGIN_CONFIG: <i class="conum" data-value="2"></i><b>(2)</b>
  CLIENT_ID: quay-enterprise <i class="conum" data-value="3"></i><b>(3)</b>
  CLIENT_SECRET: &lt;client-secret&gt; <i class="conum" data-value="4"></i><b>(4)</b>
  LOGIN_SCOPES:
    - openid
    - email
    - profile
    - groups
  OIDC_SERVER: https://&lt;keycloak hostname&gt;/realms/quay/ <i class="conum" data-value="5"></i><b>(5)</b>
  SERVICE_NAME: keycloak <i class="conum" data-value="6"></i><b>(6)</b>
  PREFERRED_USERNAME_CLAIM_NAME: preferred_username
  VERIFIED_EMAIL_CLAIM_NAME: email
  PREFERRED_GROUP_CLAIM_NAME: groups
  OIDC_DISABLE_USER_ENDPOINT: false <i class="conum" data-value="7"></i><b>(7)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Set this parameter to <strong>OIDC</strong>.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>parent key name can be any string (use KEYCLOAK_LOGIN_CONFIG here). This is important, and the part in front of _LOGIN_CONFIG must match the service-id you used in Keycloak.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The client id you used in Keycloak.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The client secret you used in Keycloak.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The realm base URL (no trailing /protocol…​), e.g.:
<a class="bare" href="https://&lt;keycloak_hostname&gt;/realms/quay/">https://&lt;keycloak_hostname&gt;/realms/quay/</a> — Quay will discover .well-known/openid-configuration endpoints automatically.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The service name you used in Keycloak.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>Set this parameter to <strong>false</strong> to allow Quay to fetch user information from Keycloak. If using Azure Entra ID set this to <strong>true</strong>.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Since we are using Quay Operator, the operator will pick up the changes automatically and restart Quay.
If you are using a standalone Quay installation, you need to restart Quay for the change to take effect. (Config is not hot-reloaded.)</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_testing_login">Testing Login</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Let’s do some tests to verify the configuration.
Above we have created some users and groups in Keycloak. Let’s try to log in with one of them.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Open your Quay UI ( <a class="bare" href="https://&lt;quay_hostname&gt;">https://&lt;quay_hostname&gt;</a>; ) in a browser. On the login page you should see the external login option labelled Keycloak (or the SERVICE_NAME you set).</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/quay/images/quay-login-oidc.png?width=320" alt="quay login oidc"/>
</div>
</div>
<div class="olist arabic">
<ol class="arabic" start="2">
<li>
<p>Click the &#34;Sign in with Keycloak&#34; option. and you will be redirected to Keycloak’s login screen. Here you can authenticate with a Keycloak user.</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/quay/images/quay-keycloak.png?width=320" alt="quay keycloak"/>
</div>
</div>
<div class="paragraph">
<p>After successful authentication, Keycloak redirects back to Quay and Quay creates a local user mapped to the OIDC claims (username, email). If you set USERNAME_CLAIM to preferred_username, look at the created Quay username in the UI under your user’s profile.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_make_the_keycloak_user_a_quay_admin">Make the Keycloak user a Quay admin</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In Quay only one identity provider can be used at a time. If you previously set up a local admin account, you need to make a Keycloak user a Quay admin by adding their Quay username to SUPER_USERS where all administrators are listed.</p>
</div>
<div class="paragraph">
<p>In the Quay configuration, you can define administrators using the SUPER_USERS array.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Make sure the Keycloak user has logged in once so Quay has created a local user record
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Edit the Quay configuration once more and add the Quay username (exact username created by Quay).</p>
</div>
<div class="paragraph">
<p>For example, let’s say we have created a user called &#34;alice&#34; in Keycloak. We need to add this user to the SUPER_USERS array.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">SETUP_COMPLETE: true
SUPER_USERS:
  - admin              # existing local admin (optional)
  - alice              # alice is the Quay username created from Keycloak login</code></pre>
</div>
</div>
<div class="paragraph">
<p>After restart, the Quay account alice will have superuser privileges (same as if created in the UI).</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_working_with_podman_on_cli">Working with Podman on CLI</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now, as we changed the authentication method, we need to verify if we can push/pull images from/to the registry.
The command line tool of the choice is <strong>podman</strong>.</p>
</div>
<div class="paragraph">
<p>However, podman does not redirect to SSO login, so it needs a token to authenticate. We can generate a new token for a user in the Quay UI.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>In the Quay UI, go to the <strong>Account Settings</strong> (upper right corner)</p>
</li>
<li>
<p>In the settings section, under <strong>Docker CLI and other Application Tokens</strong>, click on <strong>Create Application Token</strong></p>
</li>
<li>
<p>Enter a name for the token</p>
</li>
<li>
<p>Select the newly created token and copy the podman login command (or any other command you need)</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/quay/images/quay-app-pass.png?width=320" alt="quay app pass"/>
</div>
</div>
</li>
<li>
<p>The command for podman will look like this:</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">podman login -u=&#39;$app&#39; -p=&#39;&lt;token&gt;&#39; &lt;quay-url&gt;

Login Succeeded!</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you can push/pull images from/to the registry.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_troubleshooting">Troubleshooting</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Common issues and their solutions:</p>
</div>
<div class="sect2">
<h3 id="_redirect_uri_mismatch">Redirect URI Mismatch</h3>
<div class="paragraph">
<p><strong>Problem</strong>: Keycloak returns &#34;Invalid redirect URI&#34; error</p>
</div>
<div class="paragraph">
<p><strong>Solution</strong>: Ensure all three redirect URIs are configured in Keycloak client:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-none hljs">https://&lt;quay-hostname&gt;/oauth2/keycloak/callback
https://&lt;quay-hostname&gt;/oauth2/keycloak/callback/attach
https://&lt;quay-hostname&gt;/oauth2/keycloak/callback/cli</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_username_mapping_issues">Username Mapping Issues</h3>
<div class="paragraph">
<p><strong>Problem</strong>: Quay creates unexpected usernames</p>
</div>
<div class="paragraph">
<p><strong>Solution</strong>:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Check which claim Keycloak sends: inspect ID token in browser dev tools</p>
</li>
<li>
<p>Common claims: preferred_username, email, sub, name</p>
</li>
<li>
<p>Update PREFERRED_USERNAME_CLAIM_NAME in Quay config accordingly</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_ssl_certificate_issues">SSL Certificate Issues</h3>
<div class="paragraph">
<p><strong>Problem</strong>: Quay cannot reach Keycloak due to TLS verification errors</p>
</div>
<div class="paragraph">
<p><strong>Solutions</strong>:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Install your internal CA certificate in the Quay container</p>
</li>
<li>
<p>Use publicly trusted certificates for both services</p>
</li>
<li>
<p>For testing only: disable SSL verification (not recommended for production)</p>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_authentication_flow_failures">Authentication Flow Failures</h3>
<div class="paragraph">
<p><strong>Problem</strong>: Login redirects but fails to create user in Quay</p>
</div>
<div class="paragraph">
<p><strong>Debugging steps</strong>:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Check Quay logs: <code>oc logs deployment/quay-app</code></p>
</li>
<li>
<p>Verify OIDC discovery endpoint: <code><a class="bare" href="https://&lt;keycloak&gt;/realms/&lt;realm&gt;/.well-known/openid-configuration">https://&lt;keycloak&gt;/realms/&lt;realm&gt;/.well-known/openid-configuration</a></code></p>
</li>
<li>
<p>Confirm client secret matches between Keycloak and Quay</p>
</li>
<li>
<p>Test with curl: <code>curl -k <a class="bare" href="https://&lt;keycloak&gt;/realms/&lt;realm&gt;/.well-known/openid-configuration">https://&lt;keycloak&gt;/realms/&lt;realm&gt;/.well-known/openid-configuration</a></code></p>
</li>
</ol>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Integrating Quay 3.15 with Keycloak via OIDC centralizes authentication, simplifies user management, and allows you to leverage enterprise identity features. The key steps are straightforward: create a Keycloak client with the correct redirect URIs, configure the corresponding OIDC block in Quay’s config.yaml.</p>
</div>
<div class="paragraph">
<p>By switching the initial database-backed admin to an identity managed in Keycloak, you reduce the risk of &#34;orphaned&#34; local accounts and align Quay administration with your organization’s identity and access management strategy.</p>
</div>
</div>
</div>]]></content:encoded></item><item><title>Cert-Manager Policy Approver in OpenShift</title><link>https://blog.stderr.at/openshift-platform/security/certificates/2025-06-03-cert-manager-approver-policy/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/certificates/2025-06-03-cert-manager-approver-policy/</guid><pubDate>Tue, 03 Jun 2025 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>How to configure Cert-Manager Approver Policy in OpenShift</description><content:encoded><![CDATA[<div class="paragraph">
<p>One of the most commonly deployed operators in OpenShift environments is the <strong>Cert-Manager Operator</strong>. It automates the management of TLS certificates for applications running within the cluster, including their issuance and renewal.</p>
</div>
<div class="paragraph">
<p>The tool supports a variety of certificate issuers by default, including ACME, Vault, and self-signed certificates. Whenever a certificate is needed, Cert-Manager will automatically create a CertificateRequest resource that contains the details of the certificate. This resource is then processed by the appropriate issuer to generate the actual TLS certificate. The approval process in this case is usually fully automated, meaning that the certificate is issued without any manual intervention.</p>
</div>
<div class="paragraph">
<p>But what if you want to have more control? What if certificate issuance must follow strict organizational policies, such as requiring a specifc country code or organization name?
This is where the <strong>CertificateRequestPolicy</strong> resource, a resource provided by the Approver Policy, comes into play.</p>
</div>
<div class="paragraph">
<p>This article walks through configuring the <strong>Cert-Manager Approver Policy</strong> in OpenShift to enforce granular policies on certificate requests.</p>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Before you begin, ensure you have the following:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenShift 4.16 or higher with cluster-admin access</p>
</li>
<li>
<p>Cert-Manager Operator installed</p>
</li>
</ul>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The installation of Cert-Manager itself is discussed in the article: <a href="/gitopscollection/2024-07-04-managing-certificates-with-gitops/">Managing Certificates using GitOps approach</a>.
</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
The Cert-Manager Operator does not currently support the Approver Policy by default. You need to install the Approver Policy manually using a Helm Chart. There is a feature request to include the Approver Policy in the Cert-Manager Operator in the future.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_adding_approver_policy_chart_as_a_dependency">Adding Approver Policy Chart as a dependency</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Source: <a href="https://github.com/tjungbauer/openshift-clusterconfig-gitops/tree/main/clusters/management-cluster/cert-manager" rel="noopener" target="_blank">Cert-Manager Deployment</a></p>
</div>
<div class="paragraph">
<p>The above Chart contains the necessary resources to deploy the Cert-Manager itself and Cert-Manager Approver Policy in OpenShift.
To deploy the Approver Policy alongside Cert-Manager, add it as a dependency in your <strong>Chart.yaml</strong>:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">[...]
  - name: cert-manager-approver-policy
    version: v0.19.0
    repository: https://charts.jetstack.io
[...]</code></pre>
</div>
</div>
<div class="paragraph">
<p>This is the official Helm Chart for the Cert-Manager Approver Policy tool provided by Jetstack. The version used in this example is v0.19.0, but you can use a newer version if available.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configuration_of_the_helm_chart">Configuration of the Helm Chart</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The initial <a href="https://github.com/tjungbauer/openshift-clusterconfig-gitops/blob/main/clusters/management-cluster/cert-manager/values.yaml" rel="noopener" target="_blank">values.yaml</a> file was extended to:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>include the configuration for the Approver Policy Chart</p>
</li>
<li>
<p>the configuration for a <strong>CertificateRequestPolicy</strong> object</p>
</li>
<li>
<p>with some specific modifications to the CertManager resource itself</p>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_disabling_cert_managers_auto_approver">Disabling Cert-Manager’s Auto-Approver</h3>
<div class="paragraph">
<p>The first step we need to do is to disable the auto-approver of the Cert-Manager. If this is not done, there will be a race condition between the auto-approver and the Approver Policy, which will lead to unexpected results.
These changes are done by:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">cert-manager:
  certManager:
    enable_patch: true <i class="conum" data-value="1"></i><b>(1)</b>

    unsupportedConfigOverrides:
      controller:
        args:
          - &#39;--controllers=*,-certificaterequests-approver&#39; <i class="conum" data-value="2"></i><b>(2)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>This enables the patching of the CertManager resource, which tells the chart to overwrite (patch) the automatically generated CertManager resource with the custom configuration.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>This disables the auto-approver Controller of the Cert-Manager.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
As the name suggests, this is currently an unsupported configuration, but it is necessary to disable the auto-approver for the Cert-Manager. In the future versions of the Cert-Manager, this might change, and the auto-approver might be supported out of the box.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>In my case, the full CertManager resource looks like this:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: operator.openshift.io/v1alpha1
kind: CertManager
metadata:
  annotations:
  name: cluster
spec:
  controllerConfig:
    overrideArgs: <i class="conum" data-value="1"></i><b>(1)</b>
      - &#39;--dns01-recursive-nameservers-only&#39;
      - &#39;--dns01-recursive-nameservers=ns-362.awsdns-45.com:53,ns-930.awsdns-52.net:53&#39;
  logLevel: Normal
  managementState: Managed
  operatorLogLevel: Normal
  unsupportedConfigOverrides: <i class="conum" data-value="2"></i><b>(2)</b>
    controller:
      args:
        - &#39;--controllers=*,-certificaterequests-approver&#39;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Settings to support AWS Nameservers for DNS01 challenges.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>This disables the auto-approver Controller of the Cert-Manager.</td>
</tr>
</tbody></table>
</div>
</div>
<div class="sect2">
<h3 id="_configuration_of_the_approver_policy">Configuration of the Approver Policy</h3>
<div class="paragraph">
<p>The second step is to configure the Approver Policy chart. This chart will deploy the necessary resources, most importantly a Deployment that will start the Pods which will process the CertificateRequestPolicy resources later on.</p>
</div>
<div class="paragraph">
<p>My configuration for that chart looks like this (some default values are omitted for brevity):</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">cert-manager-approver-policy:

  crds: <i class="conum" data-value="1"></i><b>(1)</b>
    # This option decides if the CRDs should be installed
    # as part of the Helm installation.
    enabled: true
    # This option makes it so that the &#34;helm.sh/resource-policy&#34;: keep
    # annotation is added to the CRD. This will prevent Helm from uninstalling
    # the CRD when the Helm release is uninstalled.
    # WARNING: when the CRDs are removed, all cert-manager-approver-policy custom resources
    # (CertificateRequestPolicy) will be removed too by the garbage collector.
    keep: true

  # Number of replicas of approver-policy to run.
  replicaCount: 1 <i class="conum" data-value="2"></i><b>(2)</b>

  image: <i class="conum" data-value="3"></i><b>(3)</b>
    # Target image repository.
    repository: quay.io/jetstack/cert-manager-approver-policy
    # Kubernetes imagePullPolicy on Deployment.
    pullPolicy: IfNotPresent
    tag: v0.19.0

  app:

    # List of signer names that approver-policy will be given permission to
    # approve and deny. CertificateRequests referencing these signer names can be
    # processed by approver-policy. Defaults to an empty array, allowing approval
    # for all signers.
    approveSignerNames: <i class="conum" data-value="4"></i><b>(4)</b>
      - &#39;issuers.cert-manager.io/*&#39;
      - &#39;clusterissuers.cert-manager.io/*&#39;</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>This enables the installation of the CRDs that are required for the Approver Policy.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The number of replicas of the Approver Policy Deployment. In most cases, one replica is enough.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The image configuration for the Approver Policy. The image is pulled from the Jetstack Quay.io repository.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The list of signer names that the Approver Policy will be allowed to approve. In this case, it is configured to allow all issuers and clusterissuers.</td>
</tr>
</tbody></table>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The approveSignerNames are, if configured, an important setting, especially if you want to add custom (cluster)issuers. In such a case, you need to add the name of the custom issuer to this list. Otherwise the Approver Policy will not be able to approve the CertificateRequests for that issuer.
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_creating_a_certificaterequestpolicy_and_rolebinding">Creating a CertificateRequestPolicy and Role(Binding)</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The final step in our configuration is to define a <strong>CertificateRequestPolicy</strong> resource that will define the policy for the certificate requests. This resource will be processed by the Approver Policy and will determine if a certificate request is approved or denied based on the defined criteria.</p>
</div>
<div class="paragraph">
<p>The following example shows a CertificateRequestPolicy that will:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Allow certificate requests with any common name, DNS names, IP addresses, URIs, and email addresses.</p>
</li>
<li>
<p>Require DNS names to be set.</p>
</li>
<li>
<p>Require the subject to contain a specific organization (MyOrganization) and country code (AT).</p>
</li>
<li>
<p>Allow usages for server auth and client auth.</p>
</li>
<li>
<p>Set constraints for the certificate duration (1h-24h) and private key algorithm (RSA) and size (2048-4096).</p>
</li>
<li>
<p>Allow all issuers by using an empty selector.</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">role: cert-manager-policy:global-approver <i class="conum" data-value="1"></i><b>(1)</b>
serviceAccount: cert-manager <i class="conum" data-value="2"></i><b>(2)</b>
cert_manager_Namespace: cert-manager <i class="conum" data-value="3"></i><b>(3)</b>

policies:
  - name: my-approver-policy
    enabled: true

    allowed:

      commonName:
        required: false
        value: &#34;*&#34;
        validations: []
      dnsNames: <i class="conum" data-value="4"></i><b>(4)</b>
        required: true
        values:
          - &#34;*&#34;
        validations: []
      ipAddresses:
        required: false
        values: [&#34;*&#34;]
        validations: []
      uris:
        required: false
        values:
          - &#34;*&#34;
        validations: []
      emailAddresses:
        required: false
        values:
          - &#34;*&#34;
        validations: []

      # isCA: false
      subject:
        organizations: <i class="conum" data-value="5"></i><b>(5)</b>
          required: true
          values:
            - &#34;MyOrganization&#34;
          validations:
            - rule: self.matches(&#34;MyOrganization&#34;)
              message: Organization must be MyOrganization
        countries:
          required: true
          values:
            - AT
          validations:
            - rule: self.matches(&#34;AT&#34;)
              message: Country code must be AT
      usages:
        - &#34;server auth&#34;
        - &#34;client auth&#34;

    constraints: <i class="conum" data-value="6"></i><b>(6)</b>
      minDuration: 1h
      maxDuration: 24h
      privateKey:
        algorithm: RSA
        minSize: 2048
        maxSize: 4096

    selector:
      issuerRef: {} <i class="conum" data-value="7"></i><b>(7)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The role that is used to approve the certificate requests. This role must be created in the OpenShift cluster and must have the necessary permissions to approve certificate requests.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The service account that is used by the Approver Policy to process the certificate requests. This service account must have the necessary permissions to access the CertificateRequest resources.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The namespace where the Cert-Manager is deployed. This is usually the <code>cert-manager</code> namespace, but you can change it if you have a different namespace.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The DNS names are required to be set for the certificate request.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The subject must contain the organization MyOrganization and the country code AT.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The constraints for the certificate request, such as the minimum and maximum duration, private key algorithm, and size.</td>
</tr>
<tr>
<td><i class="conum" data-value="7"></i><b>7</b></td>
<td>The selector is empty, which means that the policy applies to all issuers. If you want to limit the policy to specific issuers, you can specify the issuerRef here.</td>
</tr>
</tbody></table>
</div>
<div class="sect2">
<h3 id="_rendered_certificaterequestpolicy_and_rolebinding">Rendered CertificateRequestPolicy and Role(Binding)</h3>
<div class="paragraph">
<p>The above configuration will create a CertificateRequestPolicy resource that looks like this:

<div class="expand">
    <div class="expand-label" style="cursor: pointer;" data-action="expand-toggle">
        <i style="font-size:x-small;" class="fas fa-chevron-right"></i>
        <span>
        
    	
    	<a>Expand me...</a>
    	
    	</span>
    </div>
    <div class="expand-content" style="display: none;">
        <div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">---
# Source: cert-manager/templates/ClusterRole-Approver-Policy-approving.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: &#34;cert-manager-policy:global-approver&#34;
  labels:
    helm.sh/chart: cert-manager-2.0.0
    app.kubernetes.io/name: cert-manager
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/managed-by: Helm
rules:
  - verbs:
      - use
    apiGroups:
      - policy.cert-manager.io
    resources:
      - certificaterequestpolicies
    resourceNames:
      - my-approver-policy
---
# Source: cert-manager/charts/cert-manager-approver-policy/templates/clusterrolebinding.yaml
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  labels:
    app.kubernetes.io/name: cert-manager-approver-policy
    helm.sh/chart: cert-manager-approver-policy-v0.19.0
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/version: &#34;v0.19.0&#34;
    app.kubernetes.io/managed-by: Helm
  name: cert-manager-approver-policy
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cert-manager-approver-policy
subjects:
- kind: ServiceAccount
  name: cert-manager-approver-policy
  namespace: default
---
# Source: cert-manager/templates/CertificateRequestPolicy.yaml
apiVersion: policy.cert-manager.io/v1alpha1
kind: CertificateRequestPolicy
metadata:
  name: my-approver-policy
  annotations:
    argocd.argoproj.io/sync-wave: &#34;10&#34;
  labels:
    helm.sh/chart: cert-manager-2.0.0
    app.kubernetes.io/name: cert-manager
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/managed-by: Helm
spec:
  allowed:
    commonName:
      required: false
      value: &#34;*&#34;
      validations: []
    dnsNames:
      required: true
      values:
        - &#34;*&#34;
      validations: []
    emailAddresses:
      required: false
      values:
        - &#34;*&#34;
      validations: []
    ipAddresses:
      required: false
      values:
        - &#34;*&#34;
      validations: []
    uris:
      required: false
      values:
        - &#34;*&#34;
      validations: []
    isCA: false
    subject:
      organizations:
        required: true
        values:
          - &#34;MyOrganization&#34;
        validations:
          - rule: &#34;self.matches(\&#34;MyOrganization\&#34;)&#34;
            message: &#34;Organization must be MyOrganization&#34;
      countries:
        required: true
        values:
          - &#34;AT&#34;
        validations:
          - rule: &#34;self.matches(\&#34;AT\&#34;)&#34;
            message: &#34;Country code must be AT&#34;
      organizationalUnits:
        required: false
        values: [&#34;*&#34;]
        validations: []
      localities:
        required: false
        values: [&#34;*&#34;]
        validations: []
      provinces:
        required: false
        values: [&#34;*&#34;]
        validations: []
      streetAddresses:
        required: false
        values: [&#34;*&#34;]
        validations: []
      postalCodes:
        required: false
        values: [&#34;*&#34;]
        validations: []
      serialNumber:
        required: false
        value: &#34;*&#34;
        validations: []
    usages:
      - &#34;server auth&#34;
      - &#34;client auth&#34;
  constraints:
    minDuration: 1h
    maxDuration: 24h
    privateKey:
      algorithm: RSA
      minSize: 2048
      maxSize: 4096
  selector:
    issuerRef: {}</code></pre>
</div>
</div>

    </div>
</div></p>
</div>
<div class="paragraph">
<p>One important note is about the ClusterRole and ClusterRoleBinding that are created by the Helm Chart. The role looks like the following and is required to allow the Approver Policy to approve certificate requests. This small bit, puzzled me for a while:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">rules:
  - verbs:
      - use
    apiGroups:
      - policy.cert-manager.io
    resources:
      - certificaterequestpolicies
    resourceNames:
      - my-approver-policy</code></pre>
</div>
</div>
<div class="paragraph">
<p>With the above configuration we are good to go. The Helm Chart can be deployed to the OpenShift cluster (for example, using Argo CD), and the CertificateRequestPolicy will be created automatically.</p>
</div>
<div class="paragraph">
<p>A new Pod is running in the <strong>cert-manager</strong> namespace:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-console hljs" data-lang="console">❯ oc get pods -n cert-manager | grep approver
NAME                                            READY   STATUS    RESTARTS   AGE
cert-manager-approver-policy-xxxxx   1/1   Running   0   XXm <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The Pod <code>cert-manager-approver-policy-xxxxx</code> is the Pod that is responsible for processing the CertificateRequestPolicy resources.</td>
</tr>
</tbody></table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_testing_the_policy">Testing the Policy</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_test_1_valid_certificate_request">Test 1 - Valid Certificate Request</h3>
<div class="paragraph">
<p>Now it is time to test the policy. We need to create a Certificate and monitor the output of our approval pod.</p>
</div>
<div class="paragraph">
<p>As a reminder, the policy we created requires the following:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The subject must contain the organization MyOrganization</p>
</li>
<li>
<p>The subject must contain the country code AT.</p>
</li>
<li>
<p>The keysize must be at least 2048 bits. (max 4096 bits)</p>
</li>
<li>
<p>The duration must be between 1 hour and 24 hours.</p>
</li>
<li>
<p>The usage must be server auth or client auth.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Let’s create this example Certificate in the <code>myproject</code> namespace:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: test-certificate1
  namespace: myproject
spec:
  dnsNames:
    - test1.apps.ocp.aws.ispworld.at
  duration: 24h
  issuerRef:
    kind: ClusterIssuer
    name: letsencrypt-prod
  privateKey:
    algorithm: RSA
    encoding: PKCS1
    rotationPolicy: Always
  secretName: test1
  subject:
    organizations:
      - MyOrganization
    countries:
      - AT
  usages:
    - server auth</code></pre>
</div>
</div>
<div class="paragraph">
<p>In the log of the Approver Policy Pod, we should see the following output:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-console hljs" data-lang="console">time=2025-06-03T16:07:58.656Z level=DEBUG+3 msg=&#34;Approved by CertificateRequestPolicy: \&#34;my-approver-policy\&#34;&#34; logger=controller-manager/events type=Normal object=&#34;{Kind:CertificateRequest Namespace:myproject Name:test-certificate1-1 [...]}&#34; reason=Approved</code></pre>
</div>
</div>
<div class="paragraph">
<p>This indicates that the CertificateRequest was approved by the Approver Policy. The policy was able to validate the subject, keysize, duration, and usage of the certificate request and approved it accordingly.
The certificate has been created successfully in the <strong>myproject</strong> namespace, and the secret <strong>test1</strong> contains the TLS certificate and private key.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">❯ oc get secret test1 -n myproject -o yaml
apiVersion: v1
data:
  tls.crt: ...
  tls.key: ...
kind: Secret
metadata:
  labels:
    controller.cert-manager.io/fao: &#34;true&#34;
  name: test1
  namespace: myproject
type: kubernetes.io/tls</code></pre>
</div>
</div>
</div>
<div class="sect2">
<h3 id="_test_2_invalid_certificate_request">Test 2 - Invalid Certificate Request</h3>
<div class="paragraph">
<p>That was easy, but what happens if we create a CertificateRequest that does not meet the policy requirements? Let’s try to create a Certificate without the required organization or a wrong country code:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: test-certificate2
  namespace: myproject
spec:
  dnsNames:
    - test2.apps.ocp.aws.ispworld.at
  duration: 24h
  issuerRef:
    kind: ClusterIssuer
    name: letsencrypt-prod
  privateKey:
    algorithm: RSA
    encoding: PKCS1
    rotationPolicy: Always
  secretName: test2
  subject: <i class="conum" data-value="1"></i><b>(1)</b>
    countries:
      - XX
  usages:
    - server auth</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The subject does not contain the required organization MyOrganization and the country code is set to XX, which is not allowed by the policy.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>This will lead to the following error in the log of the Approver Policy Pod:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-console hljs" data-lang="console">time=2025-06-03T16:16:02.233Z level=DEBUG+3 msg=&#34;No policy approved this request: [my-approver-policy: [spec.allowed.subject.organizations.required: Required value: true, spec.allowed.subject.countries.values: Invalid value: []string{\&#34;XX\&#34;}: AT, spec.allowed.subject.countries.validations[0]: Invalid value: \&#34;XX\&#34;: Country code must be AT]]&#34; logger=controller-manager/events type=Warning object=&#34;{Kind:CertificateRequest Namespace:myproject Name:test-certificate2-1 ...&#34; reason=Denied</code></pre>
</div>
</div>
<div class="paragraph">
<p>It complains that the subject does not meet the policy requirements and therefore the CertificateRequest was denied.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_ok_we_have_a_policy_but_whats_next">Ok we have a policy, but whats next?</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The above example shows how the Cert-Manager Approver Policy can be configured and deployed, even if it is not yet supported by the Cert-Manager Operator. However, we only scratched the surface of what is possible with the Approver Policy.
You can create more complex policies that include additional validations, such as checking the validity of the DNS names, IP addresses, or URIs. You can also create policies that require specific email addresses or organizational units in the subject.</p>
</div>
<div class="paragraph">
<p>You can even create fine-grained policies that apply to specific issuers or namespaces by using the <code>selector</code> field in the CertificateRequestPolicy resource. This allows you to create policies that are tailored to your specific requirements and use cases.</p>
</div>
<div class="paragraph">
<p>The best references can be found here:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Official documentation: <a href="https://cert-manager.io/docs/policy/approval/approver-policy/" rel="noopener" target="_blank">Cert-Manager Approver Policy</a></p>
</li>
<li>
<p>Example Policies: <a href="https://github.com/cert-manager/approver-policy/tree/main/docs/examples" rel="noopener" target="_blank">Cert-Manager Approver Policy Examples</a></p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The Cert-Manager Approver Policy is a powerful tool that allows you to implement custom policies for certificate requests in OpenShift. It provides a way to control the issuance of TLS certificates based on specific criteria, such as the subject, key size, duration, and usage of the certificate.
While not yet officially supported by the Cert-Manager Operator, it can be easily integrated into your OpenShift environment using a Helm Chart. Future support is currently being discussed, and it is expected that the Approver Policy will be included in the Cert-Manager Operator in the future.</p>
</div>
</div>
</div>]]></content:encoded></item><item><title>Single log out from Keycloak and OpenShift</title><link>https://blog.stderr.at/openshift-platform/security/authentication/2025-05-22-keycloak-openshift-singlelogout/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/authentication/2025-05-22-keycloak-openshift-singlelogout/</guid><pubDate>Thu, 22 May 2025 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>How to configure Keycloak and OpenShift for Single Log Out</description><content:encoded><![CDATA[<div class="paragraph">
<p>The following 1-minute article is a follow-up to my <a href="/openshift/2025/05/step-by-step-using-keycloak-authentication-in-openshift/">previous article</a> about how to use Keycloak as an authentication provider for OpenShift. In this article, I will show you how to configure Keycloak and OpenShift for Single Log Out (SLO). This means that when you log out from Keycloak, you will also be logged out from OpenShift automatically. This requires some additional configuration in Keycloak and OpenShift, but it is not too complicated.</p>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The following prerequisites are required to follow this article:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenShift 4.16 or higher with cluster-admin privileges</p>
</li>
<li>
<p>Keycloak installed and configured, as described in the <a href="/openshift/2025/05/step-by-step-using-keycloak-authentication-in-openshift/">Step by Step - Using Keycloak Authentication in OpenShift</a></p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_keycloak_configuration">Keycloak Configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Configure the logout URL in Keycloak. This is done by adding a new <strong>Valid post logout redirect URIs</strong> to the Keycloak client configuration. In this case, we want to call the OpenShift logout URL.
Which is: <strong><a class="bare" href="https://oauth-openshift.apps.&lt;your-cluster-name&gt;/logout">https://oauth-openshift.apps.&lt;your-cluster-name&gt;/logout</a></strong></p>
</div>
<div class="paragraph">
<p>This is done in the client settings:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/set-logout-url.png" alt="Set Logout URL"/>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_openshift_configuration">OpenShift Configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now we need to configure OpenShift to use the logout URL. This is done by adding a new <strong>Post Logout Redirect URI</strong> to the OpenShift Console configuration.</p>
</div>
<div class="paragraph">
<p>Modify the existing Console resource named cluster and add the logoutRedirect parameter to the authentication section.
The important pieces of the logout URL are the <strong>client_id</strong> and the <strong>post_logout_redirect_uri</strong>. The client ID must be the same as the Keycloak client ID, and the post logout redirect URI must be the OpenShift logout URL.
(Also change the &lt;keycloakURL&gt; and &lt;realm&gt; to your Keycloak URL and realm name.)</p>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Actually, instead of <strong>client_id</strong>, the <strong>id_token_hint</strong> should be used. But OpenShift does not store the token, so we are using the client ID instead.
</td>
</tr>
</tbody></table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: config.openshift.io/v1
kind: Console
metadata:
  name: cluster
spec:
  authentication:
    logoutRedirect: &#39;https://&lt;keycloakURL&gt;/realms/&lt;realm&gt;/protocol/openid-connect/logout?client_id=&lt;realm&gt;&amp;post_logout_redirect_uri=https://console-openshift-console.apps.ocp.aws.ispworld.at&#39; <i class="conum" data-value="1"></i><b>(1)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The logout URL for OpenShift. This is the URL that will be called when you log out from Keycloak. The URL must contain the client ID and the post logout redirect URI (console of OpenShift).</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>Wait a few moments until the OpenShift Console Operator applies the new configuration.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_testing_the_configuration">Testing the configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now that the configuration is done, we can test the Single Log Out functionality.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>We are logged into OpenShift already as user <strong>testuser</strong></p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/logged-in.png" alt="Logged in to OpenShift"/>
</div>
</div>
</li>
<li>
<p>Now we log out from OpenShift using the <strong>Log out</strong> button in the upper right corner.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/logging-out.png" alt="Log out from OpenShift"/>
</div>
</div>
</li>
<li>
<p>This will redirect us to the Keycloak logout page where we need to confirm the logout.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/keycloak-logout.png?width=420" alt="Keycloak Logout"/>
</div>
</div>
</li>
<li>
<p>This will log us out from Keycloak and redirect us back to the OpenShift logout page.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/logged-out.png?width=420" alt="Logged out from OpenShift"/>
</div>
</div>
</li>
</ol>
</div>
<div class="paragraph">
<p>This is it. You are now logged out from both Keycloak and OpenShift. You can also check the Sessions in Keycloak to see that the session for the user is terminated.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>As promised, this was a short article about how to configure Keycloak and OpenShift for Single Log Out. This is a beneficial feature if you want to ensure that users are logged out from all applications when they log out from Keycloak. It is also a good security practice to ensure that users are logged out from all applications when they are done using them.</p>
</div>
</div>
</div>]]></content:encoded></item><item><title>Step by Step - Using Keycloak Authentication in OpenShift</title><link>https://blog.stderr.at/openshift-platform/security/authentication/2025-05-17-step-by-step-keycloak-and-openshift/</link><guid isPermaLink="true">https://blog.stderr.at/openshift-platform/security/authentication/2025-05-17-step-by-step-keycloak-and-openshift/</guid><pubDate>Sat, 17 May 2025 00:00:00 +0200</pubDate><dc:creator>Articles by Thomas Jungbauer</dc:creator><category>OpenShift</category><category>Security</category><description>Install and configure Keycloak in OpenShift for authentication</description><content:encoded><![CDATA[<div class="paragraph">
<p>I was recently asked about how to use Keycloak as an authentication provider for OpenShift. How to install Keycloak using the Operator and how to configure Keycloak and OpenShift so that users can log in to OpenShift using OpenID.
I have to admit that the exact steps are not easy to find, so I decided to write a blog post about it, describing each step in detail.
This time I will not use GitOps, but the OpenShift and Keycloak Web Console to show the steps, because before we put it into GitOps, we need to understand what is actually happening.</p>
</div>
<div class="paragraph">
<p>This article tries to explain every step required so that a user can authenticate to OpenShift using Keycloak as an Identity Provider (IDP) and that Groups from Keycloak are imported into OpenShift. This article does not cover a production grade installation of Keycloak, but only a test installation, so you can see how it works. For production, you might want to consider a proper database (maybe external, but at least with a backup), high availability, etc.).</p>
</div>
<div class="sect1">
<h2 id="_prerequisites">Prerequisites</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The following prerequisites are required to follow this article:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>OpenShift 4.16 or higher with cluster-admin privileges</p>
</li>
</ul>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_installing_keycloak_operator">Installing Keycloak Operator</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The very first step is to install the Keycloak Operator. This can be done using the OpenShift Web Console or the CLI or GitOps. I will show the steps using the OpenShift Web Console.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Installing the Keycloak Operator via GitOps can be seen in this <a href="https://github.com/tjungbauer/openshift-clusterconfig-gitops/tree/main/clusters/management-cluster/setup-rh-build-of-keycloak" rel="noopener" target="_blank">GitHub repository</a>. By the time you read this article, this repository will install and configure a Keycloak instance automatically using a local <strong>EXAMPLE</strong> Postgres database. It does not yet import any Realm or additional configuration, but I will try to add this in the future when time allows. Oh, and it is just a demo and not production ready, so please do not use it in production.
</td>
</tr>
</tbody></table>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Log in to the OpenShift Web Console as a user with cluster-admin privileges.</p>
</li>
<li>
<p>In the OpenShift Web Console, navigate to the Operators → OperatorHub.</p>
</li>
<li>
<p>In the OperatorHub, search for <strong>Red Hat build of Keycloak</strong> and select the Operator from the list.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/search-operator.png?width=320" alt="Search Keycloak Operator"/>
</div>
</div>
</li>
<li>
<p>Install the latest version of the Keycloak Operator.</p>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
You can keep the default settings for the installation, but I recommend using a specific namespace. In this example, I will use the namespace <code>keycloak</code> for the installation.
</td>
</tr>
</tbody></table>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/install-operator.png?width=840" alt="Install Keycloak Operator"/>
</div>
</div>
</li>
<li>
<p>Press the <strong>Install</strong> button to install the Keycloak Operator. After a few minutes, the Keycloak Operator should be installed and running in the OpenShift cluster. You can check the status of the Operator in the <strong>Installed Operators</strong> view.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/installed-operator.png" alt="Installed Keycloak Operator"/>
</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_create_a_local_example_postgres_database">Create a local example Postgres Database</h2>
<div class="sectionbody">
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Demo only! This is not production ready and should not be used in production.
</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>As a next step, we need to create a local Postgres database for Keycloak. Secrets are used to store the database credentials, and a simple StatefulSet is used to create the database. The database will be created in the same namespace as the Keycloak Operator.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>First, let’s create a Secret for the database credentials. In OpenShift select the <strong>keycloak</strong> namespace and navigate to the <strong>Secrets</strong> view. Create a new Secret with the following test configuration:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">kind: Secret
apiVersion: v1
metadata:
  name: keycloak-db-secret
  namespace: keycloak
stringData:
  password: thisisonly4testingNOT4prod <i class="conum" data-value="1"></i><b>(1)</b>
  username: testuser
type: Opaque</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The password for the database. This is just a test password and should not be used in production.</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Next, we need to create a StatefulSet for the Postgres database, again in the <strong>keycloak</strong> namespace.
Again, as I cannot mention that enough, this is just a test configuration and should not be used in production.</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgresql-db
  namespace: keycloak
spec:
  serviceName: postgresql-db-service
  selector:
    matchLabels:
      app: postgresql-db
  replicas: 1 <i class="conum" data-value="1"></i><b>(1)</b>
  template:
    metadata:
      labels:
        app: postgresql-db
    spec:
      containers:
        - name: postgresql-db
          image: postgres:15 <i class="conum" data-value="2"></i><b>(2)</b>
          volumeMounts:
            - mountPath: /data
              name: psql
          env: <i class="conum" data-value="3"></i><b>(3)</b>
            - name: POSTGRES_USER
              value: testuser
            - name: POSTGRES_PASSWORD
              value: thisisonly4testingNOT4prod
            - name: PGDATA
              value: /data/pgdata
            - name: POSTGRES_DB
              value: keycloak
  volumeClaimTemplates: <i class="conum" data-value="4"></i><b>(4)</b>
  - metadata:
      name: psql
    spec:
      accessModes: [ &#34;ReadWriteOnce&#34; ]
      storageClassName: &#34;gp3-csi&#34;
      resources:
        requests:
          storage: 10Gi</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The number of replicas for the database. In this example, we are using a single replica.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The image for the database, postgres version 15 in this example.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The environment variables for the database. The username and password are the same as in the Secret we created before, and <strong>clear text</strong></td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The volume for the database. In this example, the StatefulSet uses a volume claim template to create a volume with the size of 10 GB for the database. The volume is created using the <code>gp3-csi</code> storage class. You can use any other storage class that is available in your OpenShift cluster or even remove this line and use the default class instead.</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Finally, we need to create a Service for the database so that the Keycloak Operator can access the database. Again, in the <strong>keycloak</strong> namespace.</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: v1
kind: Service
metadata:
  name: postgres-db
  namespace: keycloak
spec:
  selector:
    app: postgresql-db <i class="conum" data-value="1"></i><b>(1)</b>
  type: LoadBalancer
  ports:
  - port: 5432
    targetPort: 5432</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The selector for the Service. This must match the label of the StatefulSet we created before.</td>
</tr>
</tbody></table>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_creating_a_keycloak_instance">Creating a Keycloak Instance</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now that the Keycloak Operator is installed and our example database is running, we can create a Keycloak instance.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>In the OpenShift Web Console, navigate to the <strong>Installed Operators</strong> view and select the Keycloak Operator. (Maybe you need to select the keycloak namespace first.)</p>
</li>
<li>
<p>In the Keycloak Operator view, create a new instance of <strong>Keycloak</strong> and switch to the <strong>YAML</strong> view.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/create-keycloak-instance.png?width=550" alt="Create Keycloak Instance"/>
</div>
</div>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
The fun part here is that the YAML example the Operator provides is actually <strong>wrong and does not work</strong>. Something that kept me busy for a while.
</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Replace the YAML with the following configuration:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: k8s.keycloak.org/v2alpha1
kind: Keycloak
metadata:
  name: keycloak <i class="conum" data-value="1"></i><b>(1)</b>
  namespace: keycloak
  labels:
    app: sso
spec:
  db: <i class="conum" data-value="2"></i><b>(2)</b>
    host: postgres-db
    passwordSecret:
      key: password
      name: keycloak-db-secret
    usernameSecret:
      key: username
      name: keycloak-db-secret
    vendor: postgres
  hostname: <i class="conum" data-value="3"></i><b>(3)</b>
    hostname: sso.apps.ocp.aws.ispworld.at
  http: <i class="conum" data-value="4"></i><b>(4)</b>
    tlsSecret: keycloak-certificate
  instances: 1 <i class="conum" data-value="5"></i><b>(5)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The name and the namespace of the Keycloak instance.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The database configuration. In this example, we are using a local Postgres database. You can also use an external database, but you need to configure the connection string accordingly.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Hostname of our Keycloak instance.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The TLS secret for the Keycloak instance. You need to create a TLS secret with the certificate and key for the hostname. This is where the example YAML is wrong. It tries to put <em>tlsSecret</em> under <em>spec</em>, but it should be under <em>http</em>.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The number of instances of Keycloak. In this example, we are using a single instance.</td>
</tr>
</tbody></table>
</div>
</li>
</ol>
</div>
<div class="sect2">
<h3 id="_what_about_the_ssl_certificate">What about the SSL Certificate?</h3>
<div class="paragraph">
<p>The Keycloak Operator does not create a certificate for the Keycloak instance. You need to create a certificate manually and store it in a secret. The Operator will use this secret to create the TLS certificate for the Keycloak instance.
In the example above we are referencing a secret called <code>keycloak-certificate</code> in the <code>keycloak</code> namespace. This secret was created using the <strong>Cert Manager Operator</strong>. For example, you can use the following configuration to create a certificate for the Keycloak instance.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: keycloak-certificate
  namespace: keycloak
spec:
  dnsNames:
    - sso.apps.ocp.aws.ispworld.at <i class="conum" data-value="1"></i><b>(1)</b>
  duration: 2160h0m0s
  issuerRef:
    kind: ClusterIssuer
    name: letsencrypt-prod <i class="conum" data-value="2"></i><b>(2)</b>
  privateKey:
    algorithm: RSA
    encoding: PKCS1
    rotationPolicy: Always
  secretName: keycloak-certificate <i class="conum" data-value="3"></i><b>(3)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The DNS name the Certificate is valid for. This should be the same as the hostname in the Keycloak instance.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The issuer for the certificate. In this example, we are using the <strong>LetsEncrypt</strong> ClusterIssuer.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The name of the secret where the certificate is stored. This should be the same as the TLS secret in the Keycloak instance.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>I strongly recommend using the <strong>Cert Manager Operator</strong> to automatically request and approve the certificate. However, if you do not have this automation in place, you can use a self-signed certificate. This certificate must be created manually and stored as a secret.
For example, you can use the following command to create a self-signed certificate and store it in a secret:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj &#34;/CN=test.keycloak.org/O=Test Keycloak./C=US&#34;

oc create secret -n keycloak tls keycloak-certificate2 --cert=tls.crt --key=tls.key</code></pre>
</div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_login_in_to_keycloak">Login in to Keycloak</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Once the Keycloak instance is created and all Pods (1) are running, you can log in to the Keycloak Admin Console using the following URL: <a class="bare" href="https://sso.apps.ocp.aws.ispworld.at">https://sso.apps.ocp.aws.ispworld.at</a>
This is the hostname we configured in the keycloak instance.</p>
</div>
<div class="paragraph">
<p>To authenticate, you need to fetch the initial password for the admin user. This password is stored in a secret called <strong>keycloak-initial-admin</strong></p>
</div>
<div class="paragraph">
<p>You can use the following command to fetch the password:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-bash hljs" data-lang="bash">oc extract secret/keycloak-initial-admin -n keycloak --to=-</code></pre>
</div>
</div>
<div class="paragraph">
<p>or you can use the OpenShift Web Console to view the secret.</p>
</div>
<div class="paragraph">
<p>Once authenticated, you should see the Keycloak Admin Console:</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/keycloak-initial-login.png" alt="Keycloak Admin Console"/>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
The first thing you should do is to change the password for the admin user. I trust you know how to do this :)
</td>
</tr>
</tbody></table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configure_keycloak_to_be_used_by_openshift">Configure Keycloak to be used by OpenShift</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The next steps are to configure Keycloak to be used as an Identity Provider (IDP) for OpenShift. This is done by creating a new Realm and a new Client in Keycloak. The following steps will show you the minimum configuration required to use Keycloak as an IDP for OpenShift. It does not cover all the options and features of Keycloak (and there are a lot), but it should be enough to get you started.</p>
</div>
<div class="paragraph">
<p>The full documentation for Keycloak can be found at <a href="https://docs.redhat.com/en/documentation/red_hat_build_of_keycloak/" rel="noopener" target="_blank">Keycloak Documentation</a>.</p>
</div>
<div class="sect2">
<h3 id="_create_a_new_realm_and_client">Create a new Realm and Client</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>In the Realm Dropdown (upper left corner) select <strong>Create new Realm</strong></p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/create-new-realm.png?width=420" alt="Create new Realm"/>
</div>
</div>
</li>
<li>
<p>Create a new Realm called <strong>openshift</strong> (Enabled, of course) and press <strong>Create</strong>.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/create-new-realm-openshift.png?width=1024" alt="Create new Realm OpenShift"/>
</div>
</div>
</li>
<li>
<p>Now, inside the Realm <strong>openshift</strong>, select <strong>Clients</strong> and press the <strong>Create client</strong> button.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/create-new-client.png?width=1024" alt="Create new Client"/>
</div>
</div>
</li>
<li>
<p>Create a new Client with the following configuration. Name it, for example, <strong>openshift</strong>.</p>
<div class="ulist">
<ul>
<li>
<p>Be sure the <strong>Client type</strong> is set to <strong>OpenID Connect</strong></p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/new-client-screen-1.png?width=1024" alt="Create new Client"/>
</div>
</div>
</li>
</ul>
</div>
</li>
<li>
<p>Enable <strong>Client authentication</strong>. The rest can be left as default.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/new-client-screen-2.png?width=1024" alt="Create new Client"/>
</div>
</div>
</li>
<li>
<p>Add the following redirect URL and Web origin and press <strong>Save</strong>.:</p>
<div class="ulist">
<ul>
<li>
<p>Redirect URL: <a class="bare" href="https://oauth-openshift.apps.&lt;your-cluster-name&gt;/oauth2callback/*">https://oauth-openshift.apps.&lt;your-cluster-name&gt;/oauth2callback/*</a> …​ redirecting everything under oauth2callback</p>
</li>
<li>
<p>Web origin: <a class="bare" href="https://oauth-openshift.apps.&lt;your-cluster-name&gt;">https://oauth-openshift.apps.&lt;your-cluster-name&gt;</a>;</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/new-client-screen-3.png?width=1024" alt="Create new Client"/>
</div>
</div>
</li>
</ul>
</div>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_create_a_new_user_and_a_group">Create a new User and a Group</h3>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>In the <strong>openshift</strong> Realm, select <strong>Groups</strong>, press the <strong>Create group</strong> button and create a group called, for example, <strong>openshift-users</strong>.</p>
</li>
<li>
<p>In the <strong>openshift</strong> Realm, select <strong>Users</strong> and press the <strong>Add user</strong> button. Be sure to join the group <strong>openshift-users</strong>.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/new-user.png?width=1024" alt="Create new User"/>
</div>
</div>
<div class="paragraph">
<p>No more configuration is needed for the (test) user at this point.</p>
</div>
</li>
<li>
<p>Set the password for the user. Select the user we have just created, select the <strong>Credentials</strong> tab and press <strong>Set password</strong>. Set the password to <strong>Temporary</strong> to force the user to change the password on the first login.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/new-user-password.png?width=1024" alt="Set password for new User"/>
</div>
</div>
</li>
</ol>
</div>
</div>
<div class="sect2">
<h3 id="_configure_a_group_mapper">Configure a Group Mapper</h3>
<div class="paragraph">
<p>The above configuration is enough to log in to OpenShift using Keycloak as an IDP (except that we need to configure OpenShift itself). However, we also want to import the groups from Keycloak into OpenShift. This configuration was not easy to find, and is done by creating a Group Mapper in Keycloak.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>In the <strong>openshift</strong> Realm, select <strong>Clients scopes</strong> and select the <strong>profile</strong> scope:</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/client-scopes.png?width=1024" alt="Client Scopes"/>
</div>
</div>
</li>
<li>
<p>Select the <strong>Mappers</strong> tab and Add a mapper <strong>By configuration</strong>:</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/client-scopes-mappers.png?width=1024" alt="Client Scopes Mappers"/>
</div>
</div>
</li>
<li>
<p>Select the <strong>Group Membership</strong> mapper.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/client-scopes-new-mapper.png?width=1024" alt="Client Scopes Create Group Membership Mapper"/>
</div>
</div>
</li>
<li>
<p>Configure the mapper with the following settings:</p>
<div class="ulist">
<ul>
<li>
<p>Mapper Type: <strong>Group Membership</strong></p>
</li>
<li>
<p>Name: <strong>openshift-groups</strong></p>
</li>
<li>
<p>Token Claim Name: <strong>groups</strong> → This is the name of the claim that will be used to map the groups from Keycloak to OpenShift.</p>
</li>
<li>
<p>Full group path: <strong>OFF</strong></p>
</li>
<li>
<p>Add to ID token: <strong>ON</strong></p>
</li>
<li>
<p>Add to access token: <strong>ON</strong></p>
</li>
<li>
<p>Add to userinfo: <strong>ON</strong></p>
<div class="admonitionblock caution">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Disable the <strong>Full groupo path</strong> option, otherwise the group name will be prefixed with a <strong>/</strong>. Moreover, be sure that you set the <strong>Token Claim Name</strong> correctly to the claim we will configure in OpenShift (groups).
</td>
</tr>
</tbody></table>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/client-scopes-new-mapper-2.png?width=1024" alt="Client Scopes Create Group Membership Mapper"/>
</div>
</div>
</li>
</ul>
</div>
</li>
</ol>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_configure_openshift_to_use_keycloak_as_an_idp">Configure OpenShift to use Keycloak as an IDP</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now that Keycloak is configured, we need to configure OpenShift to use Keycloak as an IDP. This is done by creating a new Identity Provider in OpenShift.
Before we do this, we need to create a new OAuth client secret for OpenShift in the Namespace <strong>openshift-config</strong> The secret will be used to authenticate OpenShift with Keycloak.
When we created the keycloak client, we enabled the <strong>Client authentication</strong> option. This created a client secret we need to use in OpenShift.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>In Keycloak, select the <strong>openshift</strong> client and select the <strong>Credentials</strong> tab and copy the <strong>Client secret</strong>.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/keycloak-client-secret.png?width=1024" alt="Keycloak Client Secret"/>
</div>
</div>
</li>
<li>
<p>Back in OpenShift, navigate to the <strong>openshift-config</strong> namespace and select the <strong>Secrets</strong> view. Create a new secret with the following configuration:</p>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">kind: Secret
apiVersion: v1
metadata:
  name: openid-client-secret
  namespace: openshift-config
stringData:
  clientSecret: &lt;you client secret from Keycloak&gt; <i class="conum" data-value="1"></i><b>(1)</b>
type: Opaque</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The client secret we copied from Keycloak. This is the secret we will use to authenticate OpenShift with Keycloak.</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>Now we need to create a new Identity Provider in OpenShift. In the OpenShift Web Console, navigate to the <strong>Administration</strong> → <strong>Cluster Settings</strong> → <strong>Configuration</strong> search for <strong>OAuth</strong> and select the YAML view.
Here the following must be created or added to an existing OAuth configuration:</p>
</li>
</ol>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code class="language-yaml hljs" data-lang="yaml">[...]
spec:
  identityProviders:
    - mappingMethod: claim
      name: rhsso <i class="conum" data-value="1"></i><b>(1)</b>
      openID:
        claims: <i class="conum" data-value="2"></i><b>(2)</b>
          email:
            - email
          groups:
            - groups
          name:
            - name
          preferredUsername:
            - preferred_username
        clientID: openshift <i class="conum" data-value="3"></i><b>(3)</b>
        clientSecret:
          name: openid-client-secret <i class="conum" data-value="4"></i><b>(4)</b>
        extraScopes: []
        issuer: &#39;https://sso.apps.ocp.aws.ispworld.at/realms/openshift&#39; <i class="conum" data-value="5"></i><b>(5)</b>
      type: OpenID <i class="conum" data-value="6"></i><b>(6)</b></code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tbody><tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The name of the Identity Provider. This is the name that will be displayed in the OpenShift login screen.</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>The claims that will be used to map the user to OpenShift. In this example, we are using the email, groups, name and preferred_username claims from Keycloak.</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>The client ID we created in Keycloak. This is the client ID that will be used to authenticate OpenShift with Keycloak.</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>The name of the secret we created in the <strong>openshift-config</strong> namespace.</td>
</tr>
<tr>
<td><i class="conum" data-value="5"></i><b>5</b></td>
<td>The issuer URL for Keycloak. It is &lt;hostname of keycloak&gt;/realms/&lt;realm name&gt;.</td>
</tr>
<tr>
<td><i class="conum" data-value="6"></i><b>6</b></td>
<td>The type of the Identity Provider. In this example, we are using OpenID Connect.</td>
</tr>
</tbody></table>
</div>
<div class="paragraph">
<p>The above configuration will trigger a restart of the authentication Pods in OpenShift. Wait until all Pods have been restarted and the Operator is running again.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/restart-oauth.png" alt="OpenShift OAuth Restart"/>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_test_the_configuration">Test the configuration</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Now it is time to test the configuration. Open a new browser window (or incognito window), navigate to the OpenShift login page and try to log in using Keycloak as an IDP <strong>rhsso</strong>.</p>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If you have multiple IDPs configured, it is important to select the correct IDP. <strong>rhsso</strong> in this example.
</td>
</tr>
</tbody></table>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>By selecting the <strong>rhsso</strong> Identity Provider, you should be redirected to the Keycloak login page.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/openshift-keycloak-login.png?width=1024" alt="OpenShift Login Page"/>
</div>
</div>
<div class="admonitionblock note">
<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If you selected <strong>Temporary</strong> for the password, you will now be asked to change the password on the first login.
</td>
</tr>
</tbody></table>
</div>
</li>
<li>
<p>After a successful login, you should see the OpenShift Web Console, and you should be logged in as the user you created in Keycloak.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/openshift-web-console.png?width=1024" alt="OpenShift Web Console"/>
</div>
</div>
</li>
<li>
<p>In OpenShift you will see the user created. In the Identities column you will see that it starts with <strong>rhsso</strong>, indicating that the user was authenticated using the <strong>rhsso</strong> Identity Provider.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/openshift-user.png" alt="OpenShift User"/>
</div>
</div>
</li>
<li>
<p>And finally, if you navigate to <strong>User Management</strong> → <strong>Groups</strong>, you should see the group <strong>openshift-users</strong> that was created in Keycloak.</p>
<div class="imageblock">
<div class="content">
<img src="/openshift-platform/security/authentication/images/keycloak/openshift-groups.png" alt="OpenShift Group"/>
</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_conclusion">Conclusion</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In this article, I have shown how to install and configure Keycloak in OpenShift for authentication. I have also shown how to configure Keycloak to be used as an Identity Provider for OpenShift and how to import groups from Keycloak into OpenShift.
The biggest two challenges were to find the correct callback URL and to configure the Group Mapper in Keycloak. The rest was pretty straightforward.</p>
</div>
<div class="paragraph">
<p>What’s next? With the groups now mapped into OpenShift, you can now create RoleBindings and ClusterRoleBindings to assign the appropriate roles to the users in Keycloak. This is quite nice, as I do not need to create Users manually in OpenShift anymore (previously used HTPasswd) but instead use Keycloak as the single source of truth for users and groups. All I need to configure is the RoleBindings and ClusterRoleBindings in OpenShift.</p>
</div>
<div class="paragraph">
<p>I hope this article was helpful and you learned something new. Remember, this is just a test configuration. In production you should use a proper database and keycloak setup (high Availability, backup, etc.).
If you have any questions or comments, please feel free to reach out to me on LinkedIn, Email or via GitHub issues.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_references">References</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="https://docs.redhat.com/en/documentation/red_hat_build_of_keycloak/" rel="noopener" target="_blank">Keycloak Documentation</a></p>
</li>
<li>
<p><a href="https://blog.badgerops.net/keycloak-open-shift/" rel="noopener" target="_blank">Keycloak &amp; Open Shift</a></p>
</li>
<li>
<p><a href="https://github.com/tjungbauer/openshift-clusterconfig-gitops/tree/main/clusters/management-cluster/setup-rh-build-of-keycloak" rel="noopener" target="_blank">Set up Keycloak using GitOps (No Realm/Client configuration yet)</a></p>
</li>
</ul>
</div>
</div>
</div>]]></content:encoded></item></channel></rss>