Skip to content

fix: add Kyverno mutation for kagent declarative agent pod security#34

Merged
QuentinBisson merged 2 commits into
mainfrom
fix/kagent-declarative-agent-pod-security
Jun 8, 2026
Merged

fix: add Kyverno mutation for kagent declarative agent pod security#34
QuentinBisson merged 2 commits into
mainfrom
fix/kagent-declarative-agent-pod-security

Conversation

@QuentinBisson

@QuentinBisson QuentinBisson commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What

Adds a ClusterPolicy that mutates Deployments in the kagent namespace at admission time to add the four fields required by GS restricted-PSS Kyverno policies.

Why

kagent's upstream sub-agent chart templates (cilium-policy-agent, promql-agent, etc.) render Agent CRs without podSecurityContext/securityContext in spec.declarative.deployment. The kagent controller creates Deployments from those CRs without the required fields, which Kyverno blocks:

  • disallow-capabilities-strict — missing capabilities.drop: [ALL]
  • disallow-privilege-escalation — missing allowPrivilegeEscalation: false
  • require-run-as-nonroot — missing runAsNonRoot: true
  • restrict-seccomp-strict — missing seccompProfile.type: RuntimeDefault

The Agent CRD v1alpha2 does support these fields (spec.declarative.deployment.podSecurityContext / .securityContext), but the upstream templates don't wire them through values.

An upstream fix has been opened at kagent-dev/kagent#1977. This PR is a bridge until that releases and we bump the subchart version — at which point this ClusterPolicy can be dropped in favour of setting the values directly.

Approach

Kyverno +(key) anchors (add-if-absent) so existing Deployments in the kagent namespace that already carry correct security context (kagent-controller, kagent-ui, klaud-coding) are not touched.

The policy is conditional on kagent.enabled and respects kagent.namespaceOverride.

kagent's upstream sub-agent charts (cilium-policy-agent, promql-agent, etc.)
render Agent CRs without securityContext in spec.declarative.deployment. The
kagent controller therefore creates Deployments without the fields required by
GS restricted-PSS Kyverno policies, which blocks reconciliation.

Add a ClusterPolicy that mutates Deployments in the kagent namespace at
admission time, adding the four required fields using Kyverno's +(key) anchor
(add-if-absent) so existing values on other Deployments in that namespace are
not affected.
@QuentinBisson QuentinBisson marked this pull request as ready for review June 8, 2026 10:42
@QuentinBisson QuentinBisson requested a review from a team as a code owner June 8, 2026 10:42
@QuentinBisson QuentinBisson merged commit 04e6705 into main Jun 8, 2026
6 checks passed
@QuentinBisson QuentinBisson deleted the fix/kagent-declarative-agent-pod-security branch June 8, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant