A. B. Khan

Designing the ComplianceProfile operator — compliance is a reconcile loop with a different noun

The Mesh Series · Article 43 · Part H

Kubernetes operatorsCompliance evidencePolicy as code.NET & C#Supply-chain signingDORAKubernetesPCI DSS

Cover: Designing the ComplianceProfile operator

You have a PeerAuthentication that says STRICT. You have a Gatekeeper constraint that says every namespace must carry a default‑deny AuthorizationPolicy. You have Envoy access logs with SPIFFE identities, signed evidence packs with RFC 3161 timestamps, and a Loki retention floor set to the longest clock any regulator gave you. Forty‑two articles of primitives, each of which says something true about one control.

An assessor asks a different question. Not "is mTLS STRICT?" but "show me that PCI‑DSS Requirement 4 holds, continuously, and prove it." Not "is there a deny‑all?" but "demonstrate DORA Article 9(4)(c) across the payments estate." The primitives answer primitive‑shaped questions. The assessor asks framework‑shaped ones. Something has to translate, and today that something is a person with a spreadsheet, the night before.

One idea: compliance is a reconcile loop with a different noun

Kubernetes already has the pattern. A Deployment declares desired state — three replicas — and a controller compares it with actual state, acts on the difference, and writes a status you can read. Nobody sets status.availableReplicas by hand. It is computed, continuously, from what is observed.

Swap the noun. Desired state is a set of framework controls. Actual state is read from the primitives you already run. "Compliant" is a computed, signed status condition — not a number someone types into a GRC tool on a Friday. That is the whole design, and it is not a product. It is a custom resource and a controller, which is what every operator is.

Diagram: reconcile

The loop is ordinary. What makes it worth an article is five design decisions, each of which is where the obvious choice is wrong.

Why it matters: the state nobody models is the one every auditor finds

Start with the regulatory shape, because it dictates the technical one. DORA's Articles 6 to 10 describe the ICT risk framework as an ongoing programme — Article 10 makes detection and monitoring a continuous obligation, not an annual exercise. NIS2 Article 21(2) lists measures that must be maintained: cryptography (h), access control and asset management (i). SAMA grades maturity on whether a control operates continuously and is measured. CERT‑In sets a 180‑day floor on the evidence that proves any of it. Every one of those says the same thing in a different dialect: a point‑in‑time pass is not the question. The question is whether the control holds now, and whether you can prove it held then.

A reconcile loop is the only thing in your platform that already answers "now" on a schedule. That is why the operator pattern fits and a quarterly audit script does not.

Then the decision that earns the design: three verdicts, not two. Everyone models Satisfied and Drifting — the control holds, or the control does not. Nobody models the third state, and it is the one every assessor finds: the control is configured correctly, the YAML says STRICT, and there is no evidence that it ran. The access log for the namespace is empty because the Telemetry resource was never applied. The Gatekeeper audit has not written a status in nine days because the audit pod is crash‑looping. The signing job succeeded but the Rekor inclusion proof is missing. Configured, on, and unproven. A GRC checkbox calls that compliant. A reconcile loop that distinguishes no evidence from good evidence calls it Unproven, and surfaces it before the auditor does. Article 45 will make that state a first‑class alarm — DORA's RTS asks for measures to detect when logging itself fails, and Unproven is exactly that detection.

How it comes together: five decisions

1 — The CRD declares controls, not implementation. A ComplianceProfile says which frameworks it satisfies, which workloads it covers via a selector, and a list of controls. Each control names the framework clause it maps to and the primitive that proves it: istio.PeerAuthentication for transport encryption, gatekeeper.constraint for the default‑deny baseline, istio.ServiceEntry plus the egress mode for the dependency register (Article 36), with an evidence reference pointing at where the proof is written. It does not say how to enforce. Enforcement is the primitive's job and already exists.

2 — The controller reconciles controls, not replicas. For each control, observe the primitive's verdict, compare with the desired state, write a condition. Requeue every minute. There is no cleverness in the loop; the cleverness is in refusing to put any there.

3 — Compose, don't rebuild. The operator has no data plane. It does not inspect traffic, evaluate policy, or sign anything on its own authority. It reads the Gatekeeper constraint status that the audit controller already writes every 60 seconds (Article 21). It queries Loki for the identity‑labelled access‑log lines Article 24 and 26 already produce. It checks the cosign bundle and Rekor inclusion proof Article 27 already generates. Every verdict it reports is somebody else's verdict, re‑shaped. The moat — if there is one — is the assembly: the framework‑shaped view over primitive‑shaped facts. Build a second policy engine and you have built something to audit, not something that audits.

4 — Retention is MAX across frameworks, and it lives in the profile. retention: { days, residency, store } carries Article 30's rule: the longest clock across every framework the profile satisfies, in the jurisdiction the strictest one names. For a profile satisfying PCI‑DSS and CERT‑In, the 180‑day in‑country floor wins over the shorter PCI clock. Article 42 priced that line; this is where it is declared once instead of in four config files.

5 — Observe and assert; never enforce. The operator writes status. It has read‑only RBAC on every primitive it watches and write access to nothing but its own status subresource. Compromise it and an attacker can corrupt the narration of your controls, not the controls. That is the correct blast radius for a component whose job is to be believed — and it is why the operator signs its own verdict with cosign (Article 27), so a status that was tampered with after the fact fails verification.

One honest paragraph before the config. This is a design, not a product. The project guidance that governs this series says the product stays small until a readiness review has a paying client asking for exactly this, and that is right: a ComplianceProfile nobody has asked for is architectural judgment, which is what Part H offers. Article 44 builds the controller anyway, in C#, because the design is only credible if it compiles.

Show the config: the CRD, then the loop

The resource. Note what is not in it: no policy logic, no thresholds, no enforcement. Only which control, which proving primitive, where the evidence goes, how long it is kept.

Code: crd

The loop, as a sketch in C# on .NET 10 — enough to show the three‑state verdict and the compose‑don't‑rebuild rule. Article 44 turns this into a real controller on KubeOps.

Code: reconcile

Security · Audit · Integration

Security: read‑only RBAC on every primitive, write only on its own status; a compromised operator corrupts the narration, not the controls, and a signed status makes even that detectable.

Audit: kubectl get complianceprofile is a framework‑shaped answer computed from primitive‑shaped facts, with an Unproven state that names the controls which are on but unevidenced — the finding an assessor would otherwise make for you.

Integration: Gatekeeper audit status (Article 21), identity‑labelled access logs (Articles 24/26), cosign bundles (Article 27) and the retention floor (Articles 30/42) are consumed, not duplicated; the CRD and its RBAC ship through GitOps (Article 31) so the merged PR is the change record for the compliance brain itself.

Alternatives, and when you'd pick them

Buy a GRC or CSPM platform. Vanta, Drata, Wiz and their peers are systems of record: they file evidence, track controls against frameworks, and generate the auditor's binder. Most of them do not produce evidence from your data plane — a human or an integration uploads it — and the records often live in a region you did not choose. Pick one as the index and the programme tracker. Do not expect it to know whether your PeerAuthentication held at 03:14; that is the operator's job, and the two compose: the operator produces, the GRC tool catalogues.

Build nothing; do it by hand. The honest default for a small team. A spreadsheet of controls, a quarterly walk through the primitives, screenshots in a folder. It works until a SAMA‑style maturity assessor asks for continuous evidence, or a DORA supervisor asks what the state was on a date. Then it is the spreadsheet the night before.

Read Kyverno policy reports or Gatekeeper constraint status directly. The closest alternative, and the one to take seriously. Those status blocks are control verdicts. If what you need is "does every namespace have a default‑deny," you already have it and should not build an operator to re‑wrap it. The operator earns its place only when the question is framework‑shaped across many primitives — "show me DORA Article 9 across the estate" — and when the Unproven state matters. Note that Kyverno 1.18 is steering users to CEL‑based ValidatingPolicy with ClusterPolicy heading for deprecation, so the report shape you read from is moving; pin the version.

From simple to standard, and what's next

The simple version is a CronJob that greps a few resources and writes a Slack message. The standard version is a CRD that declares controls and the primitives that prove them, a controller that observes, compares and reports on a schedule with three verdicts, a status that is computed and signed rather than set, read‑only RBAC everywhere except its own status, and a retention floor declared once. Nothing exotic. It is the Kubernetes reconcile loop pointed at a compliance framework, composed over primitives that already exist.

A sketch in C# is a sketch. Next, Article 44: building the Kubernetes operator in C# — KubeOps on .NET 10, the CRD generated from the type, and why "operators are Go territory" is a habit, not a rule.

An operator that reconciles replicas keeps your app running. An operator that reconciles controls keeps your auditor sitting down.


Next in the series: Art. 44, building the operator in C# (Part H). Earlier: Art. 42 (the retention floor priced), Art. 30 (retention = MAX, one surface many rulebooks), Art. 29 (provable, not compliant), Art. 28 (drift as a loop), Art. 27 (signed evidence), Art. 24/26 (the access log is the evidence), Art. 21 (a control you can bypass is a comment).

Key skills & topics in this article

Kubernetes operatorsCompliance evidencePolicy as code.NET & C#Supply-chain signingDORAKubernetesPCI DSS

  • #Kubernetes
  • #Operator
  • #Compliance
  • #DORA
  • #PCIDSS
  • #NIS2
  • #Istio
  • #Gatekeeper
  • #ServiceMesh
  • #RegTech

Also on LinkedIn.