@a5c-ai/krate 5.0.1-staging.f672fe79b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +29 -0
- package/README.md +183 -0
- package/bin/krate-demo.mjs +23 -0
- package/bin/krate-server.mjs +14 -0
- package/dist/krate-controller-ui.json +2407 -0
- package/dist/krate-lifecycle.json +201 -0
- package/dist/krate-runtime-snapshot.json +2955 -0
- package/dist/krate-summary.json +687 -0
- package/docs/README.md +61 -0
- package/docs/agents/README.md +83 -0
- package/docs/agents/acceptance-test-matrix.md +193 -0
- package/docs/agents/agent-mux-adapter-contract.md +167 -0
- package/docs/agents/agent-mux-source-map.md +310 -0
- package/docs/agents/agent-run-memory-import-spec.md +256 -0
- package/docs/agents/agent-stack-management-spec.md +421 -0
- package/docs/agents/api-contract-spec.md +309 -0
- package/docs/agents/artifacts-writeback-spec.md +145 -0
- package/docs/agents/chart-packaging-spec.md +128 -0
- package/docs/agents/ci-orchestration-spec.md +140 -0
- package/docs/agents/context-assembly-spec.md +219 -0
- package/docs/agents/controller-reconciliation-spec.md +255 -0
- package/docs/agents/crd-schema-spec.md +315 -0
- package/docs/agents/decision-log-open-questions.md +169 -0
- package/docs/agents/developer-implementation-checklist.md +329 -0
- package/docs/agents/dispatching-design.md +262 -0
- package/docs/agents/glossary.md +66 -0
- package/docs/agents/implementation-blueprint.md +324 -0
- package/docs/agents/implementation-rollout-slices.md +251 -0
- package/docs/agents/memory-context-integration-spec.md +194 -0
- package/docs/agents/memory-ontology-schema-spec.md +253 -0
- package/docs/agents/memory-operations-runbook.md +121 -0
- package/docs/agents/mvp-vertical-slice-spec.md +146 -0
- package/docs/agents/observability-audit-spec.md +265 -0
- package/docs/agents/operator-runbook.md +174 -0
- package/docs/agents/org-memory-api-payload-examples.md +333 -0
- package/docs/agents/org-memory-controller-sequence-spec.md +181 -0
- package/docs/agents/org-memory-e2e-fixture-plan.md +161 -0
- package/docs/agents/org-memory-ui-implementation-map.md +114 -0
- package/docs/agents/org-memory-vertical-slice-spec.md +168 -0
- package/docs/agents/org-resource-model-delta-spec.md +111 -0
- package/docs/agents/org-route-resource-model-spec.md +183 -0
- package/docs/agents/org-scoping-namespace-spec.md +114 -0
- package/docs/agents/rbac-secrets-management-spec.md +406 -0
- package/docs/agents/repository-page-integration-spec.md +255 -0
- package/docs/agents/resource-contract-examples.md +808 -0
- package/docs/agents/resource-relationship-map.md +190 -0
- package/docs/agents/security-threat-model.md +188 -0
- package/docs/agents/shared-memory-company-brain-spec.md +358 -0
- package/docs/agents/storage-migration-spec.md +168 -0
- package/docs/agents/subagent-orchestration-spec.md +152 -0
- package/docs/agents/system-overview.md +88 -0
- package/docs/agents/tools-mcp-skills-spec.md +189 -0
- package/docs/agents/traceability-matrix.md +79 -0
- package/docs/agents/ui-flow-spec.md +211 -0
- package/docs/agents/ui-ux-system-spec.md +426 -0
- package/docs/agents/workspace-lifecycle-spec.md +166 -0
- package/docs/architecture-spec.md +78 -0
- package/docs/components/control-plane.md +78 -0
- package/docs/components/data-plane.md +69 -0
- package/docs/components/hooks-events.md +67 -0
- package/docs/components/identity-rbac-policy.md +73 -0
- package/docs/components/kubevela-oam.md +70 -0
- package/docs/components/operations-publishing.md +81 -0
- package/docs/components/runners-ci.md +66 -0
- package/docs/components/web-ui.md +94 -0
- package/docs/external/README.md +47 -0
- package/docs/external/bidirectional-sync-design.md +134 -0
- package/docs/external/cicd-interface.md +64 -0
- package/docs/external/external-backend-controllers.md +170 -0
- package/docs/external/external-backend-crds.md +234 -0
- package/docs/external/external-backend-ui-spec.md +151 -0
- package/docs/external/external-backend-ux-flows.md +115 -0
- package/docs/external/external-object-mapping.md +125 -0
- package/docs/external/git-forge-interface.md +68 -0
- package/docs/external/github-integration-design.md +151 -0
- package/docs/external/issue-tracking-interface.md +66 -0
- package/docs/external/provider-capability-manifests.md +204 -0
- package/docs/external/provider-catalog.md +139 -0
- package/docs/external/provider-rollout-testing.md +78 -0
- package/docs/external/research-results.md +48 -0
- package/docs/external/security-auth-permissions.md +81 -0
- package/docs/external/sync-state-machines.md +108 -0
- package/docs/external/unified-external-backend-model.md +107 -0
- package/docs/external/user-facing-changes.md +67 -0
- package/docs/gaps.md +161 -0
- package/docs/install.md +94 -0
- package/docs/krate-design.md +334 -0
- package/docs/local-minikube.md +55 -0
- package/docs/ontology/README.md +32 -0
- package/docs/ontology/bounded-contexts.md +29 -0
- package/docs/ontology/events-and-hooks.md +32 -0
- package/docs/ontology/oam-kubevela.md +32 -0
- package/docs/ontology/operations-and-release.md +25 -0
- package/docs/ontology/personas-and-actors.md +32 -0
- package/docs/ontology/policies-and-invariants.md +33 -0
- package/docs/ontology/problem-space.md +30 -0
- package/docs/ontology/resource-contracts.md +40 -0
- package/docs/ontology/resource-taxonomy.md +42 -0
- package/docs/ontology/runners-and-ci.md +29 -0
- package/docs/ontology/solution-space.md +24 -0
- package/docs/ontology/storage-and-data-boundaries.md +29 -0
- package/docs/ontology/validation-matrix.md +24 -0
- package/docs/ontology/web-ui-excellent-flows.md +32 -0
- package/docs/ontology/workflows.md +39 -0
- package/docs/ontology/world.md +35 -0
- package/docs/product-requirements.md +62 -0
- package/docs/roadmap-mvp.md +87 -0
- package/docs/system-requirements.md +90 -0
- package/docs/tests/README.md +53 -0
- package/docs/tests/agent-qa-plan.md +63 -0
- package/docs/tests/browser-ui-tests.md +62 -0
- package/docs/tests/ci-quality-gates.md +48 -0
- package/docs/tests/coverage-model.md +64 -0
- package/docs/tests/e2e-scenario-tests.md +53 -0
- package/docs/tests/fixtures-test-data.md +63 -0
- package/docs/tests/observability-reliability-tests.md +54 -0
- package/docs/tests/product-test-matrix.md +145 -0
- package/docs/tests/qa-adoption-roadmap.md +130 -0
- package/docs/tests/qa-automation-plan.md +101 -0
- package/docs/tests/security-compliance-tests.md +57 -0
- package/docs/tests/test-framework-tools.md +88 -0
- package/docs/tests/test-suite-layout.md +121 -0
- package/docs/tests/unit-integration-tests.md +48 -0
- package/docs/todo-kyverno +714 -0
- package/docs/user-stories.md +78 -0
- package/examples/minikube-demo.yaml +190 -0
- package/examples/oam-application.yaml +23 -0
- package/examples/policy-kyverno-pr-title.yaml +18 -0
- package/package.json +63 -0
- package/scripts/build.mjs +29 -0
- package/scripts/setup-minikube.mjs +65 -0
- package/scripts/smoke.mjs +37 -0
- package/scripts/validate-doc-coverage.mjs +152 -0
- package/scripts/validate-package.mjs +93 -0
- package/scripts/validate-ui.mjs +207 -0
- package/src/agent-approval-controller.js +123 -0
- package/src/agent-context-bundles.js +242 -0
- package/src/agent-dispatch-controller.js +86 -0
- package/src/agent-mux-client.js +280 -0
- package/src/agent-permission-review.js +162 -0
- package/src/agent-stack-controller.js +296 -0
- package/src/agent-trigger-controller.js +108 -0
- package/src/api-controller.js +206 -0
- package/src/argocd-gitops.js +43 -0
- package/src/auth.js +265 -0
- package/src/component-catalog.js +41 -0
- package/src/control-plane.js +136 -0
- package/src/controller-client.js +38 -0
- package/src/controller-ui.js +538 -0
- package/src/data-plane.js +178 -0
- package/src/gitea-backend.js +95 -0
- package/src/handoff.js +98 -0
- package/src/hooks-events.js +63 -0
- package/src/http-server.js +151 -0
- package/src/identity-policy.js +86 -0
- package/src/index.js +30 -0
- package/src/kubernetes-controller.js +812 -0
- package/src/kubernetes-resource-gateway.js +48 -0
- package/src/operations.js +112 -0
- package/src/resource-model.js +203 -0
- package/src/runners-ci.js +48 -0
- package/src/runtime.js +196 -0
- package/src/web-ui.js +40 -0
- package/tests/agent-approval-controller.test.js +173 -0
- package/tests/agent-context-bundles.test.js +278 -0
- package/tests/agent-dispatch-controller.test.js +176 -0
- package/tests/agent-mux-client.test.js +204 -0
- package/tests/agent-permission-review.test.js +209 -0
- package/tests/agent-resources.test.js +212 -0
- package/tests/agent-stack-controller.test.js +221 -0
- package/tests/agent-trigger-controller.test.js +211 -0
- package/tests/deployment.test.js +395 -0
- package/tests/e2e/lifecycle.test.js +117 -0
- package/tests/krate.test.js +727 -0
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
# Todo: Kyverno integration
|
|
2
|
+
|
|
3
|
+
Research snapshot: 2026-05-11. Live GitHub API check showed `kyverno/kyverno` latest release `v1.18.0`, published 2026-04-29, Apache-2.0, default branch `main`, and project description `Unified Policy as Code`.
|
|
4
|
+
|
|
5
|
+
## Executive decision
|
|
6
|
+
|
|
7
|
+
Krate should integrate Kyverno as the default Kubernetes-native policy engine without replacing Kyverno, forking Kyverno, or inventing a Krate-only policy language.
|
|
8
|
+
|
|
9
|
+
Product shape:
|
|
10
|
+
|
|
11
|
+
- BYO-first: detect and use an existing Kyverno installation by default.
|
|
12
|
+
- Managed optional: optionally install Kyverno through Krate Helm/Argo CD for local demos and greenfield clusters.
|
|
13
|
+
- Krate-native UX: expose policies, audit results, exceptions, and remediation in terms of orgs, repos, PRs, runs, runner pools, deployments, hooks, and people.
|
|
14
|
+
- Kubernetes-native enforcement: let kube-apiserver admission call Kyverno for Krate CRDs and aggregated API resources.
|
|
15
|
+
- No bypasses: every mutating Krate path that should be policy-governed must write through Kubernetes API admission, not directly to Postgres, Gitea, or a private store.
|
|
16
|
+
|
|
17
|
+
## Why Kyverno fits Krate
|
|
18
|
+
|
|
19
|
+
Krate already treats Kubernetes as the backend for identity, RBAC, admission, audit, and declarative APIs. Kyverno fits because policies are Kubernetes resources, run through admission webhooks/background scans, and produce Kubernetes-native reports.
|
|
20
|
+
|
|
21
|
+
Good fit areas:
|
|
22
|
+
|
|
23
|
+
- Repository governance: visibility, naming, owner/team labels, required branch protection, default branch constraints.
|
|
24
|
+
- PR governance: descriptions, required reviewers, blocked WIP/draft merge, linked issue requirements, bypass approvals.
|
|
25
|
+
- Runner/CI governance: fork jobs must be untrusted, trusted jobs require approved service accounts, secret grants must match repo/ref/trust tier.
|
|
26
|
+
- Deployment governance: production environment gates, image verification, release metadata, OAM/KubeVela policy checks.
|
|
27
|
+
- Hooks governance: outbound webhooks require signing secrets, retry policy, endpoint allowlists, and replay limits.
|
|
28
|
+
- Identity governance: admin grants, repository permissions, identity mappings, and team ownership require auditable policies.
|
|
29
|
+
- Supply-chain governance: image validation for runner, controller, and deployment images.
|
|
30
|
+
|
|
31
|
+
Do not do:
|
|
32
|
+
|
|
33
|
+
- Do not use Kyverno to implement Git receive-pack hooks; keep those in `RefPolicy`/Gitea receive-pack policy because they must run in the Git write path.
|
|
34
|
+
- Do not mirror every `PolicyReport` row into a new Krate CRD initially; read reports directly and cache/index only if UI scale requires it.
|
|
35
|
+
- Do not bundle Kyverno as an always-on dependency for enterprise clusters; platform teams often already own it.
|
|
36
|
+
|
|
37
|
+
## Kyverno research baseline
|
|
38
|
+
|
|
39
|
+
Surfaces to integrate:
|
|
40
|
+
|
|
41
|
+
- `ValidatingPolicy` (`policies.kyverno.io/v1`): CEL-based admission validation; primary target for Krate PR, repo, runner, hook, and deployment invariants.
|
|
42
|
+
- `MutatingPolicy` (`policies.kyverno.io/v1`): CEL-based mutation for default labels, annotations, visibility defaults, run metadata, and org scoping.
|
|
43
|
+
- `GeneratingPolicy` (`policies.kyverno.io/v1`): derived resources such as default `BranchProtection`, `RefPolicy`, `RepositoryPermission`, namespace bootstrap, and runner defaults.
|
|
44
|
+
- `DeletingPolicy` (`policies.kyverno.io/v1`): cleanup for stale preview environments, expired invites, temporary runner resources, and generated-policy cleanup.
|
|
45
|
+
- `ImageValidatingPolicy` (`policies.kyverno.io/v1`): image signature and attestation validation for runner pods, deployment images, and controller image allowlists.
|
|
46
|
+
- Legacy `Policy` and `ClusterPolicy` (`kyverno.io/v1`): common in existing clusters and policy libraries; Krate must discover/display them, while new templates should prefer v1 CEL policy types.
|
|
47
|
+
- `PolicyException`: approved bypasses; Krate should wrap this in a user-friendly request/approval workflow.
|
|
48
|
+
- `PolicyReport` and `ClusterPolicyReport`: read-only compliance/audit source for violations and policy previews.
|
|
49
|
+
- Kyverno controllers: admission, background, reports, and cleanup controllers should be observed and surfaced as policy dependency health.
|
|
50
|
+
- Metrics/monitoring: scrape or read Kyverno metrics for health, latency, and violation trends.
|
|
51
|
+
|
|
52
|
+
Research sources:
|
|
53
|
+
|
|
54
|
+
- `https://github.com/kyverno/kyverno`
|
|
55
|
+
- `https://kyverno.io/docs/`
|
|
56
|
+
- `https://kyverno.io/docs/installation/`
|
|
57
|
+
- `https://kyverno.io/docs/policy-types/overview/`
|
|
58
|
+
- `https://kyverno.io/docs/policy-types/validating-policy/`
|
|
59
|
+
- `https://kyverno.io/docs/policy-types/mutating-policy/`
|
|
60
|
+
- `https://kyverno.io/docs/policy-types/generating-policy/`
|
|
61
|
+
- `https://kyverno.io/docs/policy-types/deleting-policy/`
|
|
62
|
+
- `https://kyverno.io/docs/policy-types/image-validating-policy/`
|
|
63
|
+
- `https://kyverno.io/docs/policy-reports/`
|
|
64
|
+
- `https://kyverno.io/docs/exceptions/`
|
|
65
|
+
- `https://kyverno.io/docs/monitoring/`
|
|
66
|
+
- `https://kyverno.io/docs/crds/`
|
|
67
|
+
|
|
68
|
+
## Product model
|
|
69
|
+
|
|
70
|
+
Use Krate words first and Kyverno words second:
|
|
71
|
+
|
|
72
|
+
| Krate UI term | Kubernetes/Kyverno object |
|
|
73
|
+
|---|---|
|
|
74
|
+
| Policy template | Curated Krate metadata plus Kyverno policy manifest |
|
|
75
|
+
| Policy binding | Krate resource that instantiates a template for org/repo/environment scope |
|
|
76
|
+
| Audit mode | Kyverno audit validation action |
|
|
77
|
+
| Enforce mode | Kyverno deny/enforce validation action |
|
|
78
|
+
| Violation | `PolicyReport`/`ClusterPolicyReport` result or admission denial |
|
|
79
|
+
| Exception request | Krate approval workflow that creates a Kyverno `PolicyException` |
|
|
80
|
+
| Policy pack | Versioned set of templates shipped by Krate or installed through GitOps |
|
|
81
|
+
| Remediation | Human guidance and optional patch/apply action |
|
|
82
|
+
|
|
83
|
+
Navigation additions:
|
|
84
|
+
|
|
85
|
+
- Org `Hooks & Policies`: policy center, templates, bindings, violations, exceptions, Kyverno health.
|
|
86
|
+
- Repo `Hooks`: repo-affecting policies next to Git hooks and outbound webhooks.
|
|
87
|
+
- PR detail: merge/checks sidebar shows policy gates, denials, warnings, and exception requests.
|
|
88
|
+
- Runs: job/run security card shows trust tier, service account, secret grant, image verification, and policy decisions.
|
|
89
|
+
- Deployments: release/environment policy gates and image verification.
|
|
90
|
+
- Insights: policy violation trends and Kyverno controller health.
|
|
91
|
+
- Advanced plans: raw Kyverno YAML, `kubectl` commands, and reports.
|
|
92
|
+
|
|
93
|
+
## Required Krate CRDs and API surface
|
|
94
|
+
|
|
95
|
+
Krate already has the right resource families: `Organization`, `OrgNamespaceBinding`, `User`, `Team`, `Invite`, `IdentityMapping`, `AuthProvider`, `Repository`, `RepositoryPermission`, `SSHKey`, `BranchProtection`, `RefPolicy`, `PullRequest`, `Issue`, `Review`, `Pipeline`, `Job`, `WebhookDelivery`, `WebhookSubscription`, `RunnerPool`, `View`, `Selector`, and KubeVela/OAM resources discovered from `core.oam.dev`.
|
|
96
|
+
|
|
97
|
+
Add minimal Krate CRDs for the policy experience:
|
|
98
|
+
|
|
99
|
+
### `PolicyProfile`
|
|
100
|
+
|
|
101
|
+
Purpose: org-level default policy posture. `Organization.spec.policyProfileRef` already anticipates this concept.
|
|
102
|
+
|
|
103
|
+
Spec:
|
|
104
|
+
|
|
105
|
+
- `organizationRef`: required.
|
|
106
|
+
- `displayName`: required.
|
|
107
|
+
- `mode`: `audit` | `enforce` | `mixed`.
|
|
108
|
+
- `templateRefs`: default templates/packs.
|
|
109
|
+
- `bindings`: default binding selectors by kind/repo/environment.
|
|
110
|
+
- `exceptionPolicy`: who can request/approve, max duration, required justification.
|
|
111
|
+
- `failurePolicy`: desired behavior when Kyverno is unavailable.
|
|
112
|
+
|
|
113
|
+
Status:
|
|
114
|
+
|
|
115
|
+
- `phase`: `Pending` | `Synced` | `Degraded`.
|
|
116
|
+
- `appliedPolicies`, `auditViolations`, `enforcedDenials`, `activeExceptions`.
|
|
117
|
+
- Conditions: `KyvernoDetected`, `PoliciesSynced`, `ReportsReadable`, `ExceptionsAllowed`.
|
|
118
|
+
|
|
119
|
+
### `PolicyTemplate`
|
|
120
|
+
|
|
121
|
+
Purpose: curated policy template metadata plus Kyverno manifest payload.
|
|
122
|
+
|
|
123
|
+
Spec:
|
|
124
|
+
|
|
125
|
+
- `organizationRef`: optional for platform templates, required for org-owned templates.
|
|
126
|
+
- `displayName`, `description`, `category`, `severity`.
|
|
127
|
+
- `targetKinds`: `PullRequest`, `Repository`, `Pipeline`, `Job`, `Application`, `WebhookSubscription`, etc.
|
|
128
|
+
- `parameters`: schema for form-mode UI.
|
|
129
|
+
- `kyverno`: manifest template, preferably v1 CEL policy types.
|
|
130
|
+
- `rollout`: allowed modes, default mode, preview support.
|
|
131
|
+
- `remediation`: markdown guidance and optional patch template.
|
|
132
|
+
|
|
133
|
+
Status:
|
|
134
|
+
|
|
135
|
+
- `phase`, `lastRenderedPolicy`, `validationErrors`, conditions.
|
|
136
|
+
|
|
137
|
+
### `PolicyBinding`
|
|
138
|
+
|
|
139
|
+
Purpose: bind a template/profile to org, repo, environment, or resource selectors and render Kyverno policy objects.
|
|
140
|
+
|
|
141
|
+
Spec:
|
|
142
|
+
|
|
143
|
+
- `organizationRef`: required.
|
|
144
|
+
- `templateRef`: required.
|
|
145
|
+
- `profileRef`: optional.
|
|
146
|
+
- `mode`: `audit` | `enforce`.
|
|
147
|
+
- `match`: selectors for repository, environment, branch, runner pool, resource kinds, labels.
|
|
148
|
+
- `parameters`: template parameter values.
|
|
149
|
+
- `generatedPolicyName`: optional stable override.
|
|
150
|
+
- `suspend`: boolean.
|
|
151
|
+
|
|
152
|
+
Status:
|
|
153
|
+
|
|
154
|
+
- `phase`: `Pending` | `Rendered` | `Applied` | `Degraded`.
|
|
155
|
+
- `policyRef`: Kyverno policy GVK/name/namespace.
|
|
156
|
+
- `preview`: resources that would currently fail.
|
|
157
|
+
- `lastViolationCount`, `lastDeniedAt`, `activeExceptions`.
|
|
158
|
+
- Conditions: `TemplateResolved`, `PolicyRendered`, `PolicyApplied`, `ReportsObserved`.
|
|
159
|
+
|
|
160
|
+
### `PolicyExceptionRequest`
|
|
161
|
+
|
|
162
|
+
Purpose: user-friendly approval flow for temporary bypasses, reconciled to Kyverno `PolicyException` after authorization.
|
|
163
|
+
|
|
164
|
+
Spec:
|
|
165
|
+
|
|
166
|
+
- `organizationRef`: required.
|
|
167
|
+
- `policyRef`, `ruleNames`.
|
|
168
|
+
- `resourceRef`: target Krate resource or selector.
|
|
169
|
+
- `repository`, `pullRequest`, `pipeline`, `job`: optional typed convenience fields.
|
|
170
|
+
- `requestedBy`, `justification`, `expiresAt`.
|
|
171
|
+
- `riskAcceptance`: required for enforce-mode exceptions.
|
|
172
|
+
|
|
173
|
+
Status:
|
|
174
|
+
|
|
175
|
+
- `phase`: `Requested` | `Approved` | `Denied` | `Expired` | `Applied`.
|
|
176
|
+
- `approvers`, `decision`, `policyExceptionRef`.
|
|
177
|
+
- Conditions: `ApprovalSatisfied`, `ExceptionApplied`, `ExpiredCleanup`.
|
|
178
|
+
|
|
179
|
+
Do not add initially:
|
|
180
|
+
|
|
181
|
+
- `PolicyViolation` CRD. Use `PolicyReport`/`ClusterPolicyReport` directly until scale demands an index.
|
|
182
|
+
- `KyvernoInstallation` CRD. Helm values and controller discovery are enough for now.
|
|
183
|
+
- A custom Krate policy language.
|
|
184
|
+
|
|
185
|
+
## Required labels and annotations
|
|
186
|
+
|
|
187
|
+
Labels on Krate resources:
|
|
188
|
+
|
|
189
|
+
- `krate.a5c.ai/org`: org slug.
|
|
190
|
+
- `krate.a5c.ai/namespace`: tenant namespace where applicable.
|
|
191
|
+
- `krate.a5c.ai/repository`: repository name when scoped.
|
|
192
|
+
- `krate.a5c.ai/environment`: `development` | `staging` | `production`.
|
|
193
|
+
- `krate.a5c.ai/trust-tier`: `trusted` | `untrusted` for runs/jobs.
|
|
194
|
+
- `krate.a5c.ai/surface`: `repo` | `pr` | `run` | `runner` | `deployment` | `hook` | `identity`.
|
|
195
|
+
|
|
196
|
+
Annotations on generated Kyverno policies:
|
|
197
|
+
|
|
198
|
+
- `krate.a5c.ai/policy-template`: template name/version.
|
|
199
|
+
- `krate.a5c.ai/policy-binding`: binding name.
|
|
200
|
+
- `krate.a5c.ai/profile`: profile name.
|
|
201
|
+
- `krate.a5c.ai/ui-path`: canonical Krate URL for viewing/editing.
|
|
202
|
+
- `policies.kyverno.io/title`: human title.
|
|
203
|
+
- `policies.kyverno.io/category`: Krate category.
|
|
204
|
+
- `policies.kyverno.io/severity`: `low` | `medium` | `high` | `critical`.
|
|
205
|
+
- `policies.kyverno.io/subject`: target resource family.
|
|
206
|
+
|
|
207
|
+
## Controller integration
|
|
208
|
+
|
|
209
|
+
### 1. Kyverno discovery controller
|
|
210
|
+
|
|
211
|
+
Owns:
|
|
212
|
+
|
|
213
|
+
- Detect Kyverno CRDs and API groups.
|
|
214
|
+
- Detect controller deployments in the configured namespace.
|
|
215
|
+
- Check RBAC for listing policies, reports, and exceptions.
|
|
216
|
+
- Publish discovery into the controller UI model.
|
|
217
|
+
|
|
218
|
+
Outputs:
|
|
219
|
+
|
|
220
|
+
- `model.policyEngine.kyverno.detected`.
|
|
221
|
+
- `model.policyEngine.kyverno.version` when available from labels/images.
|
|
222
|
+
- `model.policyEngine.kyverno.controllers`: admission/background/reports/cleanup health.
|
|
223
|
+
- UI degraded states when Kyverno is missing or unreadable.
|
|
224
|
+
|
|
225
|
+
### 2. Policy template renderer
|
|
226
|
+
|
|
227
|
+
Owns:
|
|
228
|
+
|
|
229
|
+
- Render `PolicyTemplate` + `PolicyBinding` into Kyverno policy YAML.
|
|
230
|
+
- Validate template parameters.
|
|
231
|
+
- Prefer v1 CEL policy types for new templates.
|
|
232
|
+
- Fall back to legacy `Policy`/`ClusterPolicy` only for compatibility templates.
|
|
233
|
+
|
|
234
|
+
Rules:
|
|
235
|
+
|
|
236
|
+
- Generated policies must be deterministic and GitOps-friendly.
|
|
237
|
+
- Names should be stable: `krate-{org}-{scope}-{template}` with truncation/hash.
|
|
238
|
+
- Audit mode must be default for new templates unless explicitly configured otherwise.
|
|
239
|
+
- Every generated policy must carry Krate labels and annotations.
|
|
240
|
+
|
|
241
|
+
### 3. Policy reconciler
|
|
242
|
+
|
|
243
|
+
Owns:
|
|
244
|
+
|
|
245
|
+
- Apply generated Kyverno policies when Krate owns the binding.
|
|
246
|
+
- Update `PolicyBinding.status` and `PolicyProfile.status`.
|
|
247
|
+
- Respect `suspend` and prune generated policies only when Krate owns them.
|
|
248
|
+
- Never mutate externally managed policies unless explicitly imported.
|
|
249
|
+
|
|
250
|
+
Failure behavior:
|
|
251
|
+
|
|
252
|
+
- Policy schema errors mark the binding degraded and show exact Kubernetes/Kyverno errors.
|
|
253
|
+
- Missing Kyverno CRDs block enforce-mode activation when `requireForEnforceMode=true`.
|
|
254
|
+
- Unreadable reports do not necessarily disable enforcement, but preview/report UI must be degraded.
|
|
255
|
+
|
|
256
|
+
### 4. Report and violation indexer
|
|
257
|
+
|
|
258
|
+
Owns:
|
|
259
|
+
|
|
260
|
+
- Watch/list `PolicyReport` and `ClusterPolicyReport`.
|
|
261
|
+
- Correlate report results with Krate org/repo/resource labels.
|
|
262
|
+
- Normalize reports into UI DTOs without creating new CRDs.
|
|
263
|
+
- Track background scan recency and report staleness.
|
|
264
|
+
|
|
265
|
+
DTO fields: `policyRef`, `rule`, `result`, `severity`, `message`, `resourceRef`, `org`, `repository`, `environment`, `surface`, `mode`, `firstSeen`, `lastSeen`, `backgroundScanAge`, `remediation`, `exceptionEligible`.
|
|
266
|
+
|
|
267
|
+
### 5. Exception workflow controller
|
|
268
|
+
|
|
269
|
+
Owns:
|
|
270
|
+
|
|
271
|
+
- Turn approved `PolicyExceptionRequest` resources into Kyverno `PolicyException` objects.
|
|
272
|
+
- Enforce approver rules from `PolicyProfile.spec.exceptionPolicy`.
|
|
273
|
+
- Add expiry, labels, and owner references where valid.
|
|
274
|
+
- Clean up expired exceptions or mark them expired when cleanup is unavailable.
|
|
275
|
+
|
|
276
|
+
Important rule: exceptions are product workflows, not ad hoc YAML edits. Raw `PolicyException` editing remains in Advanced plans for admins, but normal users request exceptions from PR/run/deployment screens.
|
|
277
|
+
|
|
278
|
+
### 6. Admission-safe mutation boundary
|
|
279
|
+
|
|
280
|
+
Required invariant: creating/updating/deleting any policy-governed Krate resource must go through Kubernetes API admission.
|
|
281
|
+
|
|
282
|
+
Audit these paths:
|
|
283
|
+
|
|
284
|
+
- `POST /api/orgs/[org]/resources`.
|
|
285
|
+
- Repository creation UI.
|
|
286
|
+
- Deployment creation UI.
|
|
287
|
+
- Runner pool changes.
|
|
288
|
+
- PR, issue, review, pipeline, and job creation when implemented in the aggregated API server.
|
|
289
|
+
- Internal controller writes that update status should use status subresources and must not bypass spec admission.
|
|
290
|
+
|
|
291
|
+
High-risk edge: aggregated API resources (`PullRequest`, `Issue`, `Review`, `Pipeline`, `Job`, `WebhookDelivery`) must be served through kube-apiserver aggregation or CRDs with admission enabled. If any path writes these directly to Postgres behind Next.js, Kyverno will not see the request.
|
|
292
|
+
|
|
293
|
+
## Helm and install plan
|
|
294
|
+
|
|
295
|
+
Current chart already has:
|
|
296
|
+
|
|
297
|
+
```yaml
|
|
298
|
+
externalDependencies:
|
|
299
|
+
kyverno:
|
|
300
|
+
enabled: false
|
|
301
|
+
policyNamespace: kyverno
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Expand to:
|
|
305
|
+
|
|
306
|
+
```yaml
|
|
307
|
+
externalDependencies:
|
|
308
|
+
kyverno:
|
|
309
|
+
mode: auto # auto | disabled | byo | managed
|
|
310
|
+
namespace: kyverno
|
|
311
|
+
policyNamespace: krate-system
|
|
312
|
+
requireForEnforceMode: true
|
|
313
|
+
discoverExisting: true
|
|
314
|
+
managed:
|
|
315
|
+
enabled: false
|
|
316
|
+
installMethod: argocd # argocd | helm-dependency | none
|
|
317
|
+
chartRepoURL: https://kyverno.github.io/kyverno/
|
|
318
|
+
chart: kyverno
|
|
319
|
+
targetRevision: "3.x"
|
|
320
|
+
releaseName: kyverno
|
|
321
|
+
values: {}
|
|
322
|
+
policyReporter:
|
|
323
|
+
enabled: false
|
|
324
|
+
mode: external # external | managed
|
|
325
|
+
namespace: policy-reporter
|
|
326
|
+
defaultPolicyPack:
|
|
327
|
+
enabled: true
|
|
328
|
+
mode: audit
|
|
329
|
+
installExamples: true
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Chart tasks:
|
|
333
|
+
|
|
334
|
+
- Add optional `argocd-kyverno-application.yaml` when `externalDependencies.kyverno.mode=managed` and Argo CD is enabled.
|
|
335
|
+
- Add controller RBAC for reading Kyverno policies, reports, cluster reports, exceptions, and Kyverno controller deployments.
|
|
336
|
+
- Add separate RBAC for writing Kyverno policies only when managed policy bindings are enabled.
|
|
337
|
+
- Add RBAC for writing `PolicyException` only through the exception controller.
|
|
338
|
+
- Add env vars to API/controllers/web: `KRATE_KYVERNO_MODE`, `KRATE_KYVERNO_NAMESPACE`, `KRATE_KYVERNO_POLICY_NAMESPACE`, `KRATE_KYVERNO_REQUIRE_FOR_ENFORCE_MODE`, `KRATE_KYVERNO_POLICY_REPORTER_ENABLED`, `KRATE_KYVERNO_DISCOVER_EXISTING`.
|
|
339
|
+
- Add README examples for disabled, BYO, and managed modes.
|
|
340
|
+
- Add local dev values for Docker Desktop/minikube that keep Kyverno optional but enable sample audit policies when installed.
|
|
341
|
+
|
|
342
|
+
Install modes:
|
|
343
|
+
|
|
344
|
+
- Disabled: no Kyverno dependency errors; UI shows policy engine empty state and native Krate `RefPolicy`/`BranchProtection` only.
|
|
345
|
+
- BYO: Krate detects existing Kyverno and reads policies/reports; write access is opt-in through RBAC.
|
|
346
|
+
- Managed: Krate owns a Kyverno Argo CD Application or Helm dependency; best for local demos and greenfield installs, with full values passthrough.
|
|
347
|
+
|
|
348
|
+
## API changes
|
|
349
|
+
|
|
350
|
+
Add controller API fields:
|
|
351
|
+
|
|
352
|
+
```json
|
|
353
|
+
{
|
|
354
|
+
"policyEngine": {
|
|
355
|
+
"kyverno": {
|
|
356
|
+
"mode": "byo",
|
|
357
|
+
"detected": true,
|
|
358
|
+
"namespace": "kyverno",
|
|
359
|
+
"version": "v1.18.0",
|
|
360
|
+
"controllers": [
|
|
361
|
+
{ "name": "admission-controller", "ready": true },
|
|
362
|
+
{ "name": "background-controller", "ready": true },
|
|
363
|
+
{ "name": "reports-controller", "ready": true },
|
|
364
|
+
{ "name": "cleanup-controller", "ready": true }
|
|
365
|
+
],
|
|
366
|
+
"permissions": {
|
|
367
|
+
"policies": { "list": true, "create": false, "patch": false },
|
|
368
|
+
"reports": { "list": true, "watch": true },
|
|
369
|
+
"exceptions": { "create": true }
|
|
370
|
+
},
|
|
371
|
+
"degraded": []
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Add routes:
|
|
378
|
+
|
|
379
|
+
- `GET /api/orgs/[org]/policies`: profiles, templates, bindings, Kyverno policies, and summary.
|
|
380
|
+
- `POST /api/orgs/[org]/policies/bindings`: create `PolicyBinding` from template/form.
|
|
381
|
+
- `GET /api/orgs/[org]/policy-reports`: normalized `PolicyReport`/`ClusterPolicyReport` results.
|
|
382
|
+
- `POST /api/orgs/[org]/policy-exception-requests`: request an exception.
|
|
383
|
+
- `POST /api/orgs/[org]/policy-exception-requests/[name]/approve`: approval action.
|
|
384
|
+
- `GET /api/watch/orgs/[org]/policyreports`: SSE stream over policy reports.
|
|
385
|
+
|
|
386
|
+
Keep raw resource routes working for admins: `/api/orgs/[org]/resources` can apply raw Kyverno resources when RBAC allows it, and Advanced plans must show raw YAML plus `kubectl` commands.
|
|
387
|
+
|
|
388
|
+
## UI plan
|
|
389
|
+
|
|
390
|
+
### Org Hooks & Policies page
|
|
391
|
+
|
|
392
|
+
Sections:
|
|
393
|
+
|
|
394
|
+
- Policy engine health: Kyverno detected/missing, controller readiness, report freshness, RBAC coverage.
|
|
395
|
+
- Policy profiles: org default posture, mode, violation count, bindings.
|
|
396
|
+
- Policy templates: curated cards with install/apply flow.
|
|
397
|
+
- Active bindings: template, scope, mode, recent violations, edit/suspend.
|
|
398
|
+
- Violations: filter by repo, resource kind, severity, result, mode.
|
|
399
|
+
- Exceptions: requested/approved/expired exceptions with audit trail.
|
|
400
|
+
- Advanced YAML: collapsed raw policy resources and commands.
|
|
401
|
+
|
|
402
|
+
Primary actions: `Add policy`, `Preview impact`, `Switch to enforce`, `Request exception`, `Open Kyverno YAML`, `Copy kubectl`.
|
|
403
|
+
|
|
404
|
+
### Repo Hooks tab
|
|
405
|
+
|
|
406
|
+
Add a `Policies` panel next to Git hooks and outbound webhooks:
|
|
407
|
+
|
|
408
|
+
- Policies affecting this repo.
|
|
409
|
+
- Branch/ref policies from Krate `RefPolicy` and `BranchProtection`.
|
|
410
|
+
- Kyverno admission policies affecting `PullRequest`, `Pipeline`, `Job`, `WebhookSubscription`, and deployment resources.
|
|
411
|
+
- Recent repo-scoped violations.
|
|
412
|
+
- `Add policy for this repo` and `Request exception` actions.
|
|
413
|
+
|
|
414
|
+
### PR detail
|
|
415
|
+
|
|
416
|
+
Policy gate card:
|
|
417
|
+
|
|
418
|
+
- `Allowed` / `Blocked` / `Audit warnings`.
|
|
419
|
+
- Required reviewer/description/linked issue checks.
|
|
420
|
+
- Direct links to policy/rule.
|
|
421
|
+
- Remediation copy.
|
|
422
|
+
- Exception request action.
|
|
423
|
+
- Merge button must respect actual API/admission result, not only UI state.
|
|
424
|
+
|
|
425
|
+
### Runs, runners, and deployments
|
|
426
|
+
|
|
427
|
+
Runs/runners show:
|
|
428
|
+
|
|
429
|
+
- Trust tier admitted.
|
|
430
|
+
- Runner pool policy matched.
|
|
431
|
+
- ServiceAccount selected.
|
|
432
|
+
- Secret grants allowed/denied.
|
|
433
|
+
- Image verification result for runner image and deployment image.
|
|
434
|
+
- Fork/untrusted policy result.
|
|
435
|
+
|
|
436
|
+
Deployments show:
|
|
437
|
+
|
|
438
|
+
- Environment policy profile.
|
|
439
|
+
- Image signature/attestation checks.
|
|
440
|
+
- Promotion rules.
|
|
441
|
+
- KubeVela/OAM policy conditions.
|
|
442
|
+
- Drift between desired policy and active resources.
|
|
443
|
+
|
|
444
|
+
### Empty and degraded states
|
|
445
|
+
|
|
446
|
+
If Kyverno is missing:
|
|
447
|
+
|
|
448
|
+
- Show: `Kyverno is not installed or not readable. Krate can still manage repositories, hooks, and native RefPolicy, but admission policy templates are unavailable.`
|
|
449
|
+
- Actions: `Install with Krate`, `Connect existing Kyverno`, `View install docs`.
|
|
450
|
+
|
|
451
|
+
If reports are missing but admission works:
|
|
452
|
+
|
|
453
|
+
- Show enforcement as active but preview/reporting as degraded.
|
|
454
|
+
- Disable `Preview impact` until report permissions are fixed.
|
|
455
|
+
|
|
456
|
+
If user lacks RBAC:
|
|
457
|
+
|
|
458
|
+
- Show exact `kubectl auth can-i` missing verbs/resources.
|
|
459
|
+
|
|
460
|
+
## Policy template backlog
|
|
461
|
+
|
|
462
|
+
MVP templates:
|
|
463
|
+
|
|
464
|
+
- `require-pr-description`: target `PullRequest`; audit first, enforce optional.
|
|
465
|
+
- `block-wip-pr-merge`: target `PullRequest`; deny mergeable transition when title has WIP/draft markers.
|
|
466
|
+
- `require-main-branch-protection`: target `Repository`/`BranchProtection`; require protected default branch.
|
|
467
|
+
- `fork-runs-untrusted`: target `Pipeline`/`Job`; fork refs must use untrusted runner pool and no secrets.
|
|
468
|
+
- `trusted-job-service-account`: target `Job`; privileged service accounts require trusted repo/ref and approval.
|
|
469
|
+
- `webhook-signing-required`: target `WebhookSubscription`; require signing secret and retry policy.
|
|
470
|
+
- `production-deployment-image-verified`: target KubeVela/deployment resources; require image verification for production.
|
|
471
|
+
|
|
472
|
+
Post-MVP templates:
|
|
473
|
+
|
|
474
|
+
- `require-repo-owner-team`.
|
|
475
|
+
- `limit-public-repositories`.
|
|
476
|
+
- `require-release-notes-for-prod`.
|
|
477
|
+
- `enforce-allowed-webhook-domains`.
|
|
478
|
+
- `deny-privileged-runner-images`.
|
|
479
|
+
- `require-commit-signing-for-protected-refs`.
|
|
480
|
+
- `expire-stale-preview-environments`.
|
|
481
|
+
- `cleanup-expired-invites`.
|
|
482
|
+
- `generate-default-branch-protection`.
|
|
483
|
+
- `generate-default-repository-permissions`.
|
|
484
|
+
|
|
485
|
+
## Example policy shapes
|
|
486
|
+
|
|
487
|
+
### Require PR description
|
|
488
|
+
|
|
489
|
+
Rendered as `ValidatingPolicy` for Krate PR resources:
|
|
490
|
+
|
|
491
|
+
```yaml
|
|
492
|
+
apiVersion: policies.kyverno.io/v1
|
|
493
|
+
kind: ValidatingPolicy
|
|
494
|
+
metadata:
|
|
495
|
+
name: krate-default-require-pr-description
|
|
496
|
+
labels:
|
|
497
|
+
krate.a5c.ai/org: default
|
|
498
|
+
krate.a5c.ai/surface: pr
|
|
499
|
+
annotations:
|
|
500
|
+
krate.a5c.ai/policy-template: require-pr-description@v1
|
|
501
|
+
spec:
|
|
502
|
+
validationActions:
|
|
503
|
+
- Audit
|
|
504
|
+
matchConstraints:
|
|
505
|
+
resourceRules:
|
|
506
|
+
- apiGroups: ["krate.a5c.ai"]
|
|
507
|
+
apiVersions: ["v1alpha1"]
|
|
508
|
+
operations: ["CREATE", "UPDATE"]
|
|
509
|
+
resources: ["pullrequests"]
|
|
510
|
+
validations:
|
|
511
|
+
- message: "Pull requests need a description before they can be reviewed."
|
|
512
|
+
expression: "has(object.spec.description) && size(object.spec.description.trim()) >= 20"
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### Fork runs must be untrusted
|
|
516
|
+
|
|
517
|
+
```yaml
|
|
518
|
+
apiVersion: policies.kyverno.io/v1
|
|
519
|
+
kind: ValidatingPolicy
|
|
520
|
+
metadata:
|
|
521
|
+
name: krate-default-fork-runs-untrusted
|
|
522
|
+
labels:
|
|
523
|
+
krate.a5c.ai/org: default
|
|
524
|
+
krate.a5c.ai/surface: run
|
|
525
|
+
spec:
|
|
526
|
+
validationActions:
|
|
527
|
+
- Deny
|
|
528
|
+
matchConstraints:
|
|
529
|
+
resourceRules:
|
|
530
|
+
- apiGroups: ["krate.a5c.ai"]
|
|
531
|
+
apiVersions: ["v1alpha1"]
|
|
532
|
+
operations: ["CREATE", "UPDATE"]
|
|
533
|
+
resources: ["pipelines", "jobs"]
|
|
534
|
+
validations:
|
|
535
|
+
- message: "Forked runs must use the untrusted trust tier."
|
|
536
|
+
expression: "!(has(object.spec.fork) && object.spec.fork) || object.spec.trustTier == 'untrusted'"
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### Generate default branch protection
|
|
540
|
+
|
|
541
|
+
Use `GeneratingPolicy` after the MVP once the controller path can safely own generated objects:
|
|
542
|
+
|
|
543
|
+
```yaml
|
|
544
|
+
apiVersion: policies.kyverno.io/v1
|
|
545
|
+
kind: GeneratingPolicy
|
|
546
|
+
metadata:
|
|
547
|
+
name: krate-default-branch-protection
|
|
548
|
+
spec:
|
|
549
|
+
matchConstraints:
|
|
550
|
+
resourceRules:
|
|
551
|
+
- apiGroups: ["krate.a5c.ai"]
|
|
552
|
+
apiVersions: ["v1alpha1"]
|
|
553
|
+
operations: ["CREATE"]
|
|
554
|
+
resources: ["repositories"]
|
|
555
|
+
generate:
|
|
556
|
+
- expression: "object.spec.visibility == 'public' ? [] : []"
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
The generation example is intentionally skeletal. Validate exact CEL object construction against Kyverno v1.18 before shipping.
|
|
560
|
+
|
|
561
|
+
## Observability
|
|
562
|
+
|
|
563
|
+
Krate should collect/display:
|
|
564
|
+
|
|
565
|
+
- Kyverno controller readiness.
|
|
566
|
+
- Admission review latency and rejection count.
|
|
567
|
+
- Policy/rule execution counts.
|
|
568
|
+
- Policy report result counts by org/repo/severity.
|
|
569
|
+
- Background scan age.
|
|
570
|
+
- Exception counts and expiry.
|
|
571
|
+
- Enforce-mode denial events from failed writes.
|
|
572
|
+
|
|
573
|
+
UI surfaces:
|
|
574
|
+
|
|
575
|
+
- Insights card: `Policy posture`.
|
|
576
|
+
- Hooks & Policies table: violation trends.
|
|
577
|
+
- Resource detail pages: policy conditions and admission events.
|
|
578
|
+
- Operations page: Kyverno dependency health and required RBAC.
|
|
579
|
+
|
|
580
|
+
## Security and RBAC
|
|
581
|
+
|
|
582
|
+
Principles:
|
|
583
|
+
|
|
584
|
+
- Krate UI must not decide authorization locally; use Kubernetes RBAC and admission results.
|
|
585
|
+
- Viewing reports can be broader than editing policies.
|
|
586
|
+
- Editing policies is platform/admin scope.
|
|
587
|
+
- Requesting an exception is narrower than approving one.
|
|
588
|
+
- Enforce-mode changes should require admin permission and preferably GitOps review.
|
|
589
|
+
- Policy-generated resources need clear owner labels and should be pruned only by the owner controller.
|
|
590
|
+
|
|
591
|
+
Suggested RBAC split:
|
|
592
|
+
|
|
593
|
+
- Developers: view repo-scoped policy status, view relevant violations, request exceptions.
|
|
594
|
+
- Repo admins: bind approved templates to repos in audit mode, request enforce promotion.
|
|
595
|
+
- Platform engineers: manage templates, profiles, enforce mode, Kyverno installation, approvals.
|
|
596
|
+
- Krate controller SA: list/watch reports; apply generated policies only in managed mode; create exceptions only from approved `PolicyExceptionRequest`.
|
|
597
|
+
|
|
598
|
+
## Testing plan
|
|
599
|
+
|
|
600
|
+
Unit tests:
|
|
601
|
+
|
|
602
|
+
- Render `PolicyTemplate` + `PolicyBinding` to deterministic Kyverno YAML.
|
|
603
|
+
- Validate audit vs enforce mode mapping.
|
|
604
|
+
- Normalize `PolicyReport` results to Krate UI DTOs.
|
|
605
|
+
- Convert approved `PolicyExceptionRequest` to Kyverno `PolicyException`.
|
|
606
|
+
- Confirm generated labels/annotations include org/repo/surface.
|
|
607
|
+
|
|
608
|
+
Chart tests:
|
|
609
|
+
|
|
610
|
+
- `helm lint charts/krate` with Kyverno disabled, BYO, and managed modes.
|
|
611
|
+
- Render RBAC for report-read-only vs policy-write modes.
|
|
612
|
+
- Render env vars into API/controllers/web deployments.
|
|
613
|
+
- Render optional Argo CD Application only in managed mode.
|
|
614
|
+
|
|
615
|
+
Local cluster tests:
|
|
616
|
+
|
|
617
|
+
- Install Krate with Kyverno disabled: UI shows empty state, no failing dependencies.
|
|
618
|
+
- Install Kyverno into Docker Desktop/minikube, set BYO mode, verify discovery.
|
|
619
|
+
- Apply audit `require-pr-description`, create violating PR, verify report appears.
|
|
620
|
+
- Switch to enforce, create violating PR, verify Kubernetes admission denial reaches UI.
|
|
621
|
+
- Request/approve exception, verify exception resource and UI state.
|
|
622
|
+
- Verify `/api/watch/orgs/default/policyreports` streams report updates.
|
|
623
|
+
|
|
624
|
+
End-to-end demo path:
|
|
625
|
+
|
|
626
|
+
1. `helm install krate` with BYO or managed Kyverno.
|
|
627
|
+
2. Create org and repository.
|
|
628
|
+
3. Apply `require-pr-description` in audit mode.
|
|
629
|
+
4. Create PR without description.
|
|
630
|
+
5. UI shows audit violation and remediation.
|
|
631
|
+
6. Switch policy to enforce.
|
|
632
|
+
7. Attempt same PR update and get admission-denied message.
|
|
633
|
+
8. Request temporary exception.
|
|
634
|
+
9. Approve exception as platform engineer.
|
|
635
|
+
10. PR action succeeds and exception appears in audit trail.
|
|
636
|
+
|
|
637
|
+
## Implementation phases
|
|
638
|
+
|
|
639
|
+
### Phase 0: design guardrails
|
|
640
|
+
|
|
641
|
+
- [ ] Decide exact file/API names for `PolicyProfile`, `PolicyTemplate`, `PolicyBinding`, and `PolicyExceptionRequest`.
|
|
642
|
+
- [ ] Confirm aggregated API resources are admission-governed before claiming PR/run policy enforcement.
|
|
643
|
+
- [ ] Decide whether managed Kyverno install uses Argo CD Application or Helm dependency for each environment.
|
|
644
|
+
- [ ] Decide first policy pack and default mode.
|
|
645
|
+
|
|
646
|
+
### Phase 1: discovery and read-only UX
|
|
647
|
+
|
|
648
|
+
- [ ] Add Kyverno resource definitions to Kubernetes discovery without making them Krate-owned resources.
|
|
649
|
+
- [ ] Extend controller snapshot with `policyEngine.kyverno`.
|
|
650
|
+
- [ ] Add Helm values/env vars for Kyverno mode/namespace/reporting.
|
|
651
|
+
- [ ] Add RBAC to list Kyverno policies/reports/exceptions in BYO mode.
|
|
652
|
+
- [ ] Add org Hooks & Policies health/read-only panels.
|
|
653
|
+
- [ ] Add policy report normalization and list route.
|
|
654
|
+
- [ ] Add policy report watch route.
|
|
655
|
+
- [ ] Add tests for missing Kyverno, unreadable reports, and detected Kyverno.
|
|
656
|
+
|
|
657
|
+
### Phase 2: policy templates and bindings
|
|
658
|
+
|
|
659
|
+
- [ ] Add CRDs for `PolicyProfile`, `PolicyTemplate`, `PolicyBinding`.
|
|
660
|
+
- [ ] Add resource model entries and chart CRDs.
|
|
661
|
+
- [ ] Add template renderer for v1 CEL policies.
|
|
662
|
+
- [ ] Add `require-pr-description`, `fork-runs-untrusted`, and `webhook-signing-required` templates.
|
|
663
|
+
- [ ] Add audit preview flow using existing/background reports.
|
|
664
|
+
- [ ] Add create/edit/suspend binding UI.
|
|
665
|
+
- [ ] Add raw YAML and `kubectl apply` affordances.
|
|
666
|
+
|
|
667
|
+
### Phase 3: enforce and exception workflows
|
|
668
|
+
|
|
669
|
+
- [ ] Add enforce-mode promotion flow with RBAC checks.
|
|
670
|
+
- [ ] Add `PolicyExceptionRequest` CRD.
|
|
671
|
+
- [ ] Add exception request/approval UI.
|
|
672
|
+
- [ ] Add exception reconciler to create Kyverno `PolicyException`.
|
|
673
|
+
- [ ] Add expiry cleanup/marking behavior.
|
|
674
|
+
- [ ] Add admission-denial parsing so UI shows policy/rule/message.
|
|
675
|
+
|
|
676
|
+
### Phase 4: managed installation and production hardening
|
|
677
|
+
|
|
678
|
+
- [ ] Add optional managed Kyverno Argo CD Application template.
|
|
679
|
+
- [ ] Add policy reporter integration option.
|
|
680
|
+
- [ ] Add Kyverno metrics summary to Insights and Operations pages.
|
|
681
|
+
- [ ] Add HA/readiness guidance to chart docs.
|
|
682
|
+
- [ ] Add local cluster conformance with Kyverno installed.
|
|
683
|
+
- [ ] Add production release gate: policy blocks a bad PR, report appears, exception flow works.
|
|
684
|
+
|
|
685
|
+
### Phase 5: advanced policy packs
|
|
686
|
+
|
|
687
|
+
- [ ] Add image verification templates for runner/deployment images.
|
|
688
|
+
- [ ] Add generating policies for default branch protection and repo permissions.
|
|
689
|
+
- [ ] Add cleanup policies for expired invites and stale preview environments.
|
|
690
|
+
- [ ] Add Policy Reporter links if installed.
|
|
691
|
+
- [ ] Add import flow for existing enterprise Kyverno policies.
|
|
692
|
+
|
|
693
|
+
## Open questions
|
|
694
|
+
|
|
695
|
+
- Should `PolicyTemplate` be a Krate CRD or shipped as ConfigMaps for easier GitOps review?
|
|
696
|
+
- Should managed Kyverno be installed by the Krate chart directly or by an Argo CD child Application only?
|
|
697
|
+
- Which users can promote audit policies to enforce in repo scope?
|
|
698
|
+
- How should Krate represent denied admission attempts when no resource is created and therefore no `PolicyReport` resource exists?
|
|
699
|
+
- Should Krate persist a lightweight event for enforce-mode denials for long-term audit search?
|
|
700
|
+
- Do we require Policy Reporter for nicer dashboards, or is native `PolicyReport` enough for MVP?
|
|
701
|
+
- How will multi-org clusters isolate policy report visibility when reports contain resource names from shared namespaces?
|
|
702
|
+
|
|
703
|
+
## Acceptance criteria for seamless integration
|
|
704
|
+
|
|
705
|
+
- Users can install Krate without Kyverno and are not broken.
|
|
706
|
+
- Users can connect an existing Kyverno install without reconfiguring their cluster policy stack.
|
|
707
|
+
- Platform engineers can add a policy from a Krate template, preview impact, run audit mode, and promote to enforce.
|
|
708
|
+
- Developers see policy failures exactly where they act: PRs, runs, deployments, and repo hooks/settings.
|
|
709
|
+
- Every UI policy action has raw YAML and `kubectl` transparency.
|
|
710
|
+
- Kyverno reports and exceptions are correlated to Krate org/repo/resource context.
|
|
711
|
+
- Enforce-mode denials are real Kubernetes admission denials, not client-side UI blocks.
|
|
712
|
+
- The Krate controller never bypasses Kyverno for spec-changing, policy-governed resources.
|
|
713
|
+
- Helm supports disabled, BYO, and managed Kyverno modes.
|
|
714
|
+
- Local cluster conformance proves a bad PR is denied and a policy violation appears in the UI.
|