<?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/"><channel><title>Gatekeeper on Tarragon</title><link>https://tarrragon.github.io/blog/tags/gatekeeper/</link><description>Recent content in Gatekeeper on Tarragon</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Tarragon (CC BY 4.0)</copyright><lastBuildDate>Mon, 18 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tarrragon.github.io/blog/tags/gatekeeper/index.xml" rel="self" type="application/rss+xml"/><item><title>OPA Gatekeeper</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gatekeeper/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gatekeeper/</guid><description>&lt;p>OPA Gatekeeper 是 OPA 官方在 Kubernetes admission 層的落實、把 OPA 的 general-purpose policy engine 適配成 K8s-native admission controller。它跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/opa/" data-link-title="Open Policy Agent (OPA)" data-link-desc="CNCF general-purpose policy engine、Rego Datalog-like 語言、decoupled decision &amp;#43; enforcement、跨 K8s / API / Terraform / SQL 統一 policy">OPA&lt;/a> / &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/kyverno/" data-link-title="Kyverno" data-link-desc="K8s-native policy engine、YAML policy（非 Rego）、五類 rule（Validate / Mutate / Generate / Verify Images / Cleanup）、CNCF Incubating">Kyverno&lt;/a> / &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/conftest/" data-link-title="Conftest" data-link-desc="OPA CLI wrapper for static config policy check、Rego policy &amp;#43; 多 parser（Terraform / K8s / Dockerfile / JSON）、CI-time gate">Conftest&lt;/a> 的差異不在「policy 能不能寫」、而在 &lt;em>對接面 + 抽象層次 + 工具鏈定位&lt;/em> — Gatekeeper 是 OPA 在 K8s admission 的 first-class 落實、ConstraintTemplate + Constraint 兩層抽象把 Rego policy 變成 K8s CRD、Audit 補位 background scan、Mutation 2024 起進 stable。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>Gatekeeper 的核心定位是 &lt;em>Rego policy 在 K8s admission 層的 K8s-native 包裝&lt;/em>、不是另一個 policy engine。底層仍是 OPA、Rego 是同一套語言；上層加了兩個 K8s-specific 抽象 — &lt;em>ConstraintTemplate&lt;/em>（Rego policy + parameter schema 的 CRD 定義）跟 &lt;em>Constraint&lt;/em>（Template 的 instance、指定 match scope 與 parameter）。意義是同一份 Rego policy 寫一次、在不同 cluster / 不同 namespace 給不同 Constraint instance、不用改 Rego 本體。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/opa/" data-link-title="Open Policy Agent (OPA)" data-link-desc="CNCF general-purpose policy engine、Rego Datalog-like 語言、decoupled decision &amp;#43; enforcement、跨 K8s / API / Terraform / SQL 統一 policy">OPA&lt;/a>（純 sidecar）比、Gatekeeper 走 &lt;em>K8s-native + 兩層抽象&lt;/em>、犧牲 OPA 純 sidecar 的跨平台彈性（OPA 可同時管 K8s admission + API gateway + Terraform plan）、換來 K8s 內部 CRD + RBAC + GitOps 的一致體驗。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/kyverno/" data-link-title="Kyverno" data-link-desc="K8s-native policy engine、YAML policy（非 Rego）、五類 rule（Validate / Mutate / Generate / Verify Images / Cleanup）、CNCF Incubating">Kyverno&lt;/a> 比、Gatekeeper 走 &lt;em>Rego DSL&lt;/em>、Kyverno 走 &lt;em>YAML pattern matching&lt;/em> — team 已投資 OPA / Rego（API gateway / Terraform 已用 Rego）就走 Gatekeeper、純 K8s shop + 沒 Rego 包袱直接用 Kyverno 較省學習成本。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/conftest/" data-link-title="Conftest" data-link-desc="OPA CLI wrapper for static config policy check、Rego policy &amp;#43; 多 parser（Terraform / K8s / Dockerfile / JSON）、CI-time gate">Conftest&lt;/a> 比、Conftest 是 &lt;em>CI-time static config check&lt;/em>、Gatekeeper 是 &lt;em>runtime admission + audit&lt;/em>、兩者互補不互斥（CI 用 Conftest 擋 PR、admission 用 Gatekeeper 擋 deploy）。&lt;/p></description><content:encoded><![CDATA[<p>OPA Gatekeeper 是 OPA 官方在 Kubernetes admission 層的落實、把 OPA 的 general-purpose policy engine 適配成 K8s-native admission controller。它跟 <a href="/blog/backend/07-security-data-protection/vendors/opa/" data-link-title="Open Policy Agent (OPA)" data-link-desc="CNCF general-purpose policy engine、Rego Datalog-like 語言、decoupled decision &#43; enforcement、跨 K8s / API / Terraform / SQL 統一 policy">OPA</a> / <a href="/blog/backend/07-security-data-protection/vendors/kyverno/" data-link-title="Kyverno" data-link-desc="K8s-native policy engine、YAML policy（非 Rego）、五類 rule（Validate / Mutate / Generate / Verify Images / Cleanup）、CNCF Incubating">Kyverno</a> / <a href="/blog/backend/07-security-data-protection/vendors/conftest/" data-link-title="Conftest" data-link-desc="OPA CLI wrapper for static config policy check、Rego policy &#43; 多 parser（Terraform / K8s / Dockerfile / JSON）、CI-time gate">Conftest</a> 的差異不在「policy 能不能寫」、而在 <em>對接面 + 抽象層次 + 工具鏈定位</em> — Gatekeeper 是 OPA 在 K8s admission 的 first-class 落實、ConstraintTemplate + Constraint 兩層抽象把 Rego policy 變成 K8s CRD、Audit 補位 background scan、Mutation 2024 起進 stable。</p>
<h2 id="服務定位">服務定位</h2>
<p>Gatekeeper 的核心定位是 <em>Rego policy 在 K8s admission 層的 K8s-native 包裝</em>、不是另一個 policy engine。底層仍是 OPA、Rego 是同一套語言；上層加了兩個 K8s-specific 抽象 — <em>ConstraintTemplate</em>（Rego policy + parameter schema 的 CRD 定義）跟 <em>Constraint</em>（Template 的 instance、指定 match scope 與 parameter）。意義是同一份 Rego policy 寫一次、在不同 cluster / 不同 namespace 給不同 Constraint instance、不用改 Rego 本體。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/opa/" data-link-title="Open Policy Agent (OPA)" data-link-desc="CNCF general-purpose policy engine、Rego Datalog-like 語言、decoupled decision &#43; enforcement、跨 K8s / API / Terraform / SQL 統一 policy">OPA</a>（純 sidecar）比、Gatekeeper 走 <em>K8s-native + 兩層抽象</em>、犧牲 OPA 純 sidecar 的跨平台彈性（OPA 可同時管 K8s admission + API gateway + Terraform plan）、換來 K8s 內部 CRD + RBAC + GitOps 的一致體驗。跟 <a href="/blog/backend/07-security-data-protection/vendors/kyverno/" data-link-title="Kyverno" data-link-desc="K8s-native policy engine、YAML policy（非 Rego）、五類 rule（Validate / Mutate / Generate / Verify Images / Cleanup）、CNCF Incubating">Kyverno</a> 比、Gatekeeper 走 <em>Rego DSL</em>、Kyverno 走 <em>YAML pattern matching</em> — team 已投資 OPA / Rego（API gateway / Terraform 已用 Rego）就走 Gatekeeper、純 K8s shop + 沒 Rego 包袱直接用 Kyverno 較省學習成本。跟 <a href="/blog/backend/07-security-data-protection/vendors/conftest/" data-link-title="Conftest" data-link-desc="OPA CLI wrapper for static config policy check、Rego policy &#43; 多 parser（Terraform / K8s / Dockerfile / JSON）、CI-time gate">Conftest</a> 比、Conftest 是 <em>CI-time static config check</em>、Gatekeeper 是 <em>runtime admission + audit</em>、兩者互補不互斥（CI 用 Conftest 擋 PR、admission 用 Gatekeeper 擋 deploy）。</p>
<p>關鍵張力：<em>Rego 學習曲線</em> ↔ <em>跨平台 policy 一致性</em> 是 Gatekeeper 跟 Kyverno 最大的選擇分水嶺。純 K8s 場景 Kyverno YAML 寫起來快、但同樣的 image signature 規則若要在 Terraform plan / CI / admission 三處 enforce、Rego 寫一次跨三處比 YAML / Cue / Sentinel 多種語言混用乾淨。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>Gatekeeper 在 cluster policy stack 中承擔哪一段（admission validation / audit / mutation）、哪些要外接（<a href="/blog/backend/07-security-data-protection/vendors/opa/" data-link-title="Open Policy Agent (OPA)" data-link-desc="CNCF general-purpose policy engine、Rego Datalog-like 語言、decoupled decision &#43; enforcement、跨 K8s / API / Terraform / SQL 統一 policy">OPA</a> 純 sidecar 管非 K8s 對象、<a href="/blog/backend/07-security-data-protection/vendors/conftest/" data-link-title="Conftest" data-link-desc="OPA CLI wrapper for static config policy check、Rego policy &#43; 多 parser（Terraform / K8s / Dockerfile / JSON）、CI-time gate">Conftest</a> 補 CI-time）</li>
<li>ConstraintTemplate 跟 Constraint 兩層怎麼切（Template 由 platform team 維護、Constraint 給 app team 在 namespace 內 instantiate）</li>
<li>Audit / Mutation / External Data Provider 何時開、開了之後 cost 與 failure mode</li>
<li>何時用 Gatekeeper、何時改 Kyverno 或退回純 OPA 的取捨</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷 Gatekeeper deployment 是否健康、最少看四件事：</p>
<ul>
<li><strong>ConstraintTemplate 的 ownership</strong>：誰寫 Rego、誰 review、Template 是否走 Git（PR review + Gator CLI unit test）、是否有共用 library 避免每個 Template 重寫 K8s helper</li>
<li><strong>Audit coverage</strong>：除了 admission 攔截、Audit 是否定期 scan 已存在 resource（pre-Gatekeeper 部署的 legacy resource 違規）、<code>auditFromCache</code> 是否開、audit interval 是否合理（預設 60s、production 通常拉到 5-10min 避 API server 壓力）</li>
<li><strong>Failure mode 治理</strong>：Constraint <code>enforcementAction</code> 是 <code>deny</code> / <code>warn</code> / <code>dryrun</code>、Webhook failurePolicy 是 <code>Fail</code> / <code>Ignore</code>、<code>Fail</code> + Gatekeeper pod down 會擋全 cluster deploy</li>
<li><strong>跟 GitOps 的對接</strong>：ConstraintTemplate / Constraint 是否走 ArgoCD / Flux 部署、policy change 是否經 staging cluster 驗證、emergency exception 流程是否定義</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">Detection Coverage and Signal Governance</a> 在 admission 層的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>ConstraintTemplate（CT）— Rego policy + CRD 定義</strong>：CT 是 Gatekeeper 的核心抽象、由 Rego policy + parameter schema（OpenAPI v3）兩段組成。Template 寫好 apply 到 cluster 後、Gatekeeper 會生成同名 CRD（例 <code>K8sRequiredLabels</code>）、app team 就能用該 CRD 寫 Constraint。Template 由 platform team 維護、不該每個 app team 自己寫 Rego — 集中維護才能保證 helper / convention / unit test 一致。</p>
<p><strong>Constraint — Template 的 instance + match scope</strong>：Constraint 指定三件事 — <em>該套用哪個 Template</em>（kind）、<em>套用範圍</em>（match：kinds / namespaces / labelSelector / excludedNamespaces）、<em>parameter 值</em>（spec.parameters、對應 Template 的 schema）。同一個 Template 可以有多個 Constraint instance（production / staging 不同 threshold、不同 namespace 不同 required label set）。這層抽象的意義是 <em>policy logic 跟 environment-specific configuration 分開</em>。</p>
<p><strong>Audit — background scan 已存在 resource</strong>：除了 admission webhook 在 create / update 時攔、Audit controller 定期（預設 60s）掃整個 cluster 找違規 resource、結果寫到 Constraint status 的 <code>violations</code> 欄位。意義是 <em>legacy resource 在你 install Gatekeeper 之前就在那、admission 不會觸發、Audit 才會抓到</em>。<code>auditFromCache: true</code> 用 Gatekeeper 自己的 informer cache 不打 API server、適合大 cluster。</p>
<p><strong>Mutation — 2024+ stable</strong>：早期 Gatekeeper 只有 Validation、Mutation 在 v3.10+ 進 beta、2024 隨 v3.14+ 進 stable。Mutation 走獨立 CRD（<code>Assign</code> / <code>AssignMetadata</code> / <code>ModifySet</code>）、不走 ConstraintTemplate。常見用法：注入 <code>securityContext.runAsNonRoot: true</code>、補 default resource limit、加 organization label。Mutation 跟 Validation 都開的話、Mutation 先跑、Validation 看 mutated 後的結果。</p>
<p><strong>Sync Resources — cross-resource lookup</strong>：Rego policy 若要查 <em>別的 resource</em>（例：擋 Service 用了不存在的 Namespace）、要先 declare <code>Config</code> CRD 把該 resource type 加進 Gatekeeper 的 sync list、Gatekeeper 才會在 cache 裡有那個 resource 供 Rego 查。沒 sync 的 resource 不能跨 reference、是常見踩雷點。</p>
<p><strong>External Data Provider — query 外部 API 做 decision</strong>：Gatekeeper v3.10+ 引入 External Data Provider、Rego 可以 call 外部 HTTPS endpoint 取 runtime data 做 policy decision。典型用法：query image scan service（例 <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> server）確認 image 沒 CVE、query SBOM attestation service 確認 supply chain 完整、query custom IAM 確認 namespace owner 有權建立該 resource。要設 timeout + cache、外部 service down 不能擋全 cluster admission。</p>
<p><strong>Gator CLI — policy unit test</strong>：Gator 是 Gatekeeper 官方 CLI、本機跑 Template + Constraint 對 mock K8s manifest、不需 cluster。CI pipeline 跑 <code>gator test</code> 對每個 Template 跑 fixture、policy change 出 PR 時自動驗證 — 避免 production deploy 才發現 Template Rego bug 擋全 cluster。</p>
<p><strong>跟 GitOps 整合</strong>：ConstraintTemplate / Constraint / Mutation / Config CRD 都是純 YAML、走 ArgoCD / Flux 部署是標準作法。實務 layout：<code>gatekeeper-system</code> namespace 裝 Gatekeeper、<code>gatekeeper-policies</code> repo 放 Template 跟 baseline Constraint（platform team owned）、各 app namespace 的 Constraint instance 可以由 app team 在自己 repo 管理（透過 ArgoCD AppProject 限制 Constraint kind）。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>OPA Gatekeeper</th>
          <th>Kyverno</th>
          <th>OPA 純 sidecar</th>
          <th>Conftest</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>對接面</td>
          <td>K8s admission + Audit（K8s-only）</td>
          <td>K8s admission + Audit（K8s-only）</td>
          <td>任意 — API gateway / Terraform / K8s</td>
          <td>CI-time（static config check）</td>
      </tr>
      <tr>
          <td>Policy 語言</td>
          <td>Rego（OPA 同一套）</td>
          <td>YAML pattern matching（K8s-native）</td>
          <td>Rego</td>
          <td>Rego（OPA 同一套）</td>
      </tr>
      <tr>
          <td>抽象層次</td>
          <td>ConstraintTemplate + Constraint 兩層</td>
          <td>ClusterPolicy / Policy（單層）</td>
          <td>OPA policy bundle（無 K8s-specific 抽象）</td>
          <td>conftest test file（無 cluster 概念）</td>
      </tr>
      <tr>
          <td>Mutation</td>
          <td>支援（v3.14+ stable）</td>
          <td>支援（first-class、Kyverno 強項）</td>
          <td>不支援（需自寫 admission webhook）</td>
          <td>不適用</td>
      </tr>
      <tr>
          <td>Cross-resource</td>
          <td>Sync Resources（要 declare）</td>
          <td>Context API（內建）</td>
          <td>看自己 sidecar 怎麼寫</td>
          <td>看 CI 怎麼 load</td>
      </tr>
      <tr>
          <td>外部 data</td>
          <td>External Data Provider（v3.10+）</td>
          <td>Context API（image registry / ConfigMap）</td>
          <td>看自己 sidecar 怎麼寫</td>
          <td>不適用（純 static）</td>
      </tr>
      <tr>
          <td>學習曲線</td>
          <td>Rego 陡 + 兩層抽象多概念</td>
          <td>YAML 直觀、K8s-native idiom</td>
          <td>Rego 陡 + 自管 deployment</td>
          <td>Rego 陡 + CI integration</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>team 已投資 Rego / OPA、跨 K8s + 其他平台一致</td>
          <td>純 K8s shop、無 Rego 包袱、Mutation 是重點</td>
          <td>跨 K8s + API + Terraform 一致 policy 管理面</td>
          <td>PR 階段擋 manifest / IaC config</td>
      </tr>
      <tr>
          <td>退場成本</td>
          <td>高 — Template / Constraint / Rego 量多</td>
          <td>中 — YAML 較可移植</td>
          <td>中 — Rego 可搬到 Gatekeeper</td>
          <td>低</td>
      </tr>
  </tbody>
</table>
<p>選 Gatekeeper 的核心訴求：<em>team 已用 Rego（API gateway / Terraform plan / CI 已 OPA）+ 想把 same policy 延伸到 K8s admission + 看重 OPA ecosystem 一致性</em>。純 K8s shop 沒 Rego 包袱、又特別需要 Mutation 場景密集（PSP 廢除後重建、跨 namespace 統一 sidecar 注入）直接走 Kyverno 更省學習成本。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>Rego idioms for K8s admission</strong>：K8s admission review 物件結構是 <code>input.review.object</code>、Template 的 <code>violation</code> rule 走 <code>violation[{&quot;msg&quot;: msg}] { ... }</code> 形式。常見 idiom：<code>match.kinds</code> 跟 <code>match.namespaceSelector</code> 在 Constraint 層處理 scope、Rego 內只寫 <em>policy logic</em>；K8s helper（label 取值、container loop、init container 排除）抽到 shared library Template；錯誤訊息要帶 <code>input.review.object.metadata.name</code> 幫 app team 定位是哪個 resource 被擋。</p>
<p><strong>External Data Provider 的 production 治理</strong>：Provider 是獨立 service、Gatekeeper webhook 透過 HTTPS call、cache 在 Gatekeeper 內。要設 timeout（預設 3s、過時 ConstraintTemplate <code>failurePolicy</code> 決定 fail-open / fail-closed）、cache TTL、Provider 自身的 readiness / liveness。Provider down 不該擋全 cluster — 用 <code>failurePolicy: Ignore</code> 對 External Data Provider 例外、但記錄 metric alert。對應 <a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ Backdoor 2024</a> 的 SBOM attestation 查詢場景。</p>
<p><strong>Gator CLI 在 CI 的 pipeline 設計</strong>：<code>gator test</code> 對 fixture 跑、<code>gator verify</code> 跑 Template 自帶 test suite、<code>gator expand</code> 預覽 Mutation 結果。PR 流程：Template change → <code>gator verify</code> 跑 unit test → kind cluster 起 Gatekeeper apply Template + sample violation manifest → confirm 擋下來才 merge。</p>
<p><strong>跟 Styra DAS / Nirmata 整合</strong>：Gatekeeper OSS 本身沒 central management UI、多 cluster deployment 看 violation status 要自己拼。Styra DAS 是 OPA 商業 control plane、可以 push Template / Constraint 到多 cluster Gatekeeper、彙整 audit violation、做 policy impact analysis。Nirmata 走類似路線。OSS-only deployment 通常用 ArgoCD ApplicationSet + Prometheus exporter（gatekeeper-policy-manager / Open Policy Agent metrics）拼。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>Gatekeeper webhook timeout / 擋全 cluster admission</strong>：Rego policy 寫了 expensive operation（大量 cross-resource lookup、External Data Provider call without cache）— webhook timeout 預設 3s、超過就走 failurePolicy；改寫 Rego 用 indexed lookup、External Data Provider 加 cache、<code>failurePolicy: Ignore</code> for non-critical Template</li>
<li><strong>新 Template apply 後 admission 整個壞</strong>：Rego syntax / logic bug、production 才發現 — PR 必跑 <code>gator verify</code> + staging cluster 24-48hr soak、Constraint 先用 <code>enforcementAction: dryrun</code> 觀察 violation count 才切 <code>deny</code></li>
<li><strong>Audit 跑很慢 / API server 壓力大</strong>：cluster resource 量大、Audit interval 預設 60s 太頻繁 — 拉長到 5-10min、<code>auditFromCache: true</code> 用 informer 不打 API server、大 cluster 開 <code>auditChunkSize</code> 分批處理</li>
<li><strong>legacy resource 不擋</strong>：admission webhook 只攔 create / update、<code>kubectl apply</code> 沒改動 spec 不觸發 — 用 Audit 抓 violation、配合手動 migration plan、不要期待 admission 自動修</li>
<li><strong>Mutation 跟 Validation 衝突</strong>：Mutation 加了 label、Validation 又擋說 label 不該存在 — Mutation 先跑、Validation 看 mutated 結果；設計 policy 時要對齊兩端、不能各自寫</li>
<li><strong>Sync 沒 declare、cross-resource policy 看不到對象</strong>：Rego <code>data.inventory.namespace[&quot;foo&quot;].v1.Pod</code> 回 undefined — <code>Config</code> CRD 加 sync targets、確認 Gatekeeper pod restart 後 cache 載入</li>
<li><strong>External Data Provider down 擋全 cluster</strong>：Provider service 自己掛、<code>failurePolicy: Fail</code> 整個 admission 壞 — Provider 走 <code>failurePolicy: Ignore</code> + metric alert、Provider 自身 HA 部署、cache TTL 拉長</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>純 K8s + 無 Rego 包袱 + Mutation 重點</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/kyverno/" data-link-title="Kyverno" data-link-desc="K8s-native policy engine、YAML policy（非 Rego）、五類 rule（Validate / Mutate / Generate / Verify Images / Cleanup）、CNCF Incubating">Kyverno</a></td>
      </tr>
      <tr>
          <td>跨 K8s + API gateway + Terraform</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/opa/" data-link-title="Open Policy Agent (OPA)" data-link-desc="CNCF general-purpose policy engine、Rego Datalog-like 語言、decoupled decision &#43; enforcement、跨 K8s / API / Terraform / SQL 統一 policy">OPA</a>（純 sidecar）</td>
      </tr>
      <tr>
          <td>CI-time / PR 階段擋 manifest</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/conftest/" data-link-title="Conftest" data-link-desc="OPA CLI wrapper for static config policy check、Rego policy &#43; 多 parser（Terraform / K8s / Dockerfile / JSON）、CI-time gate">Conftest</a></td>
      </tr>
      <tr>
          <td>Image scan 結果作為 policy 來源</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a>（feed External Data Provider）</td>
      </tr>
      <tr>
          <td>Runtime threat detection（syscall）</td>
          <td>Falco / Cilium Tetragon（屬 runtime detection、不在 admission 層）</td>
      </tr>
      <tr>
          <td>Multi-cluster policy 集中管理</td>
          <td>Styra DAS / Nirmata（OPA / Gatekeeper 商業 control plane）</td>
      </tr>
      <tr>
          <td>偵測 / SIEM</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/splunk/" data-link-title="Splunk" data-link-desc="業界 SIEM 標準、forwarder &#43; indexer &#43; search head 架構、SPL 為核心查詢語言、ingestion-based 計費跟偵測覆蓋率的 trade-off">Splunk</a> 或同類 SIEM</td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>Rego 完整語法 reference（unification、comprehension、partial evaluation）</li>
<li>Gatekeeper helm chart / installation 細節（看官方 docs）</li>
<li>Open Policy Agent 在 service mesh / API gateway 的 sidecar 部署模式（看 <a href="/blog/backend/07-security-data-protection/vendors/opa/" data-link-title="Open Policy Agent (OPA)" data-link-desc="CNCF general-purpose policy engine、Rego Datalog-like 語言、decoupled decision &#43; enforcement、跨 K8s / API / Terraform / SQL 統一 policy">OPA</a> 頁）</li>
<li>Pod Security Admission（K8s 內建、跟 Gatekeeper 互補但不是 Gatekeeper 一部分）</li>
<li>Multi-cluster policy bundle 的 OCI registry 分發（屬 <a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性</a> 邊界）</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>Gatekeeper 在 07 案例庫沒有直接 vendor-level 事件、但 supply chain 跟 admission policy 相關 case 都是 Gatekeeper 落實位置的對照：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 Gatekeeper 的關係（對照啟示）</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/solarwinds-2020-sunburst/" data-link-title="7.R7.2.1 SolarWinds 2020：更新鏈被濫用" data-link-desc="合法更新流程遭植入後，攻擊者如何長期潛伏與橫向擴散">SolarWinds 2020 Sunburst</a></td>
          <td>ConstraintTemplate 配 cosign image signature verify、擋未簽 / 簽章不符 image 進 cluster；Audit 補位掃既有 deployment 找未簽 image</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/log4shell-cve-2021-44228-component-chain/" data-link-title="7.R7.2.7 Log4Shell 2021：共用元件風險與修補鏈" data-link-desc="共用元件漏洞如何同步影響多服務，並迫使團隊建立依賴治理 workflow">Log4Shell CVE-2021-44228</a></td>
          <td>Gatekeeper External Data Provider 接 <a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> server、admission 階段查 image 是否有 critical CVE 直接擋</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/xz-backdoor-2024-open-source-supply-chain/" data-link-title="7.R7.2.4 XZ Backdoor 2024：開源供應鏈長期滲透" data-link-desc="開源維護鏈遭滲透後，為何會直接影響廣泛 Linux 發行流程">XZ Backdoor 2024</a></td>
          <td>External Data Provider 可 query SBOM attestation 服務做 policy decision、不只看 image hash 而看 component provenance 鏈</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性 (section)</a></td>
          <td>Gatekeeper 是 OPA ecosystem 在 K8s admission 的官方落實、artifact trust gate 從 CI（Conftest）延伸到 runtime（Gatekeeper）的閉環</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/supply-chain-integrity-and-artifact-trust/" data-link-title="7.12 供應鏈完整性與 Artifact 信任" data-link-desc="定義 build provenance、artifact 信任與交付鏈風險問題">7.12 供應鏈完整性與 Artifact Trust</a>、<a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">7.13 偵測覆蓋率與訊號治理</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/opa/" data-link-title="Open Policy Agent (OPA)" data-link-desc="CNCF general-purpose policy engine、Rego Datalog-like 語言、decoupled decision &#43; enforcement、跨 K8s / API / Terraform / SQL 統一 policy">OPA</a>、<a href="/blog/backend/07-security-data-protection/vendors/kyverno/" data-link-title="Kyverno" data-link-desc="K8s-native policy engine、YAML policy（非 Rego）、五類 rule（Validate / Mutate / Generate / Verify Images / Cleanup）、CNCF Incubating">Kyverno</a>、<a href="/blog/backend/07-security-data-protection/vendors/conftest/" data-link-title="Conftest" data-link-desc="OPA CLI wrapper for static config policy check、Rego policy &#43; 多 parser（Terraform / K8s / Dockerfile / JSON）、CI-time gate">Conftest</a></li>
<li>下游：<a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a>（image scan 結果 feed External Data Provider）、<a href="/blog/backend/07-security-data-protection/vendors/spire/" data-link-title="SPIRE" data-link-desc="SPIFFE Runtime Environment、attested workload identity、short-lived SVID &#43; Trust Bundle、跨組織 federation">SPIRE</a>（workload identity 跟 admission policy 互補）</li>
<li>跨類：<a href="/blog/backend/07-security-data-protection/vendors/splunk/" data-link-title="Splunk" data-link-desc="業界 SIEM 標準、forwarder &#43; indexer &#43; search head 架構、SPL 為核心查詢語言、ingestion-based 計費跟偵測覆蓋率的 trade-off">Splunk</a>（admission violation event 進 SIEM correlation）</li>
<li>跨模組：<a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a>（policy violation → IR routing）</li>
<li>官方：<a href="https://open-policy-agent.github.io/gatekeeper/">OPA Gatekeeper Documentation</a></li>
</ul>
]]></content:encoded></item></channel></rss>