Skip to content

fix(agents): add podSecurityContext and securityContext to all agent charts#1977

Open
QuentinBisson wants to merge 3 commits into
kagent-dev:mainfrom
QuentinBisson:fix/agent-charts-pod-security-context
Open

fix(agents): add podSecurityContext and securityContext to all agent charts#1977
QuentinBisson wants to merge 3 commits into
kagent-dev:mainfrom
QuentinBisson:fix/agent-charts-pod-security-context

Conversation

@QuentinBisson

@QuentinBisson QuentinBisson commented Jun 8, 2026

Copy link
Copy Markdown

What

Adds podSecurityContext and securityContext values to all 10 declarative agent charts and wires them through to spec.declarative.deployment in the rendered Agent CR.

Why

All agent chart templates currently only render imagePullSecrets and resources in the deployment section. The kagent controller creates Deployments from those Agent CRs, and those Deployments lack the fields required by Kubernetes restricted Pod Security Standards:

  • capabilities.drop: [ALL]
  • allowPrivilegeEscalation: false
  • runAsNonRoot: true
  • seccompProfile.type: RuntimeDefault

On clusters enforcing restricted PSS via Kyverno or OPA, all declarative agent Deployments are blocked at admission.

The Agent CRD v1alpha2 already supports spec.declarative.deployment.podSecurityContext and spec.declarative.deployment.securityContext. The templates just weren't passing them through.

Changes

Each of the 10 agent charts (argo-rollouts, cilium-debug, cilium-manager, cilium-policy, helm, istio, k8s, kgateway, observability, promql) gets the same change:

values.yaml (new defaults, empty so existing deployments are unaffected):

podSecurityContext: {}
securityContext: {}

templates/agent.yaml (render only when set):

{{- with .Values.podSecurityContext }}
podSecurityContext:
  {{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
  {{- toYaml . | nindent 8 }}
{{- end }}

Usage

Callers can now pass the required fields:

cilium-policy:
  podSecurityContext:
    runAsNonRoot: true
    seccompProfile:
      type: RuntimeDefault
  securityContext:
    allowPrivilegeEscalation: false
    capabilities:
      drop: [ALL]
    seccompProfile:
      type: RuntimeDefault

…charts

All declarative agent charts render Agent CRs without security context fields
in spec.declarative.deployment. The kagent controller therefore creates
Deployments that fail admission on clusters enforcing Kubernetes restricted
Pod Security Standards (e.g. via Kyverno or OPA).

Add podSecurityContext and securityContext values to each chart (defaulting
to empty, so existing deployments are unaffected) and wire them through the
template using {{- with }} so they are only emitted when set.

Signed-off-by: QuentinBisson <quentin@giantswarm.io>
@github-actions github-actions Bot removed the bug Something isn't working label Jun 8, 2026
@QuentinBisson QuentinBisson force-pushed the fix/agent-charts-pod-security-context branch from c11e44a to a8b4b62 Compare June 8, 2026 10:43
@github-actions github-actions Bot added the bug Something isn't working label Jun 8, 2026
@QuentinBisson QuentinBisson marked this pull request as ready for review June 8, 2026 10:46
Copilot AI review requested due to automatic review settings June 8, 2026 10:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds configurable pod/container security context options to multiple agent Helm charts so deployments can set Kubernetes security hardening settings via values.

Changes:

  • Introduced podSecurityContext and securityContext in agent chart values.yaml files.
  • Rendered those values into each agent manifest template under spec.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
helm/agents/promql/values.yaml Adds security context value keys for the promql agent chart.
helm/agents/promql/templates/agent.yaml Renders new security context values into the promql agent manifest.
helm/agents/observability/values.yaml Adds security context value keys for the observability agent chart.
helm/agents/observability/templates/agent.yaml Renders new security context values into the observability agent manifest.
helm/agents/kgateway/values.yaml Adds security context value keys for the kgateway agent chart.
helm/agents/kgateway/templates/agent.yaml Renders new security context values into the kgateway agent manifest.
helm/agents/k8s/values.yaml Adds security context value keys for the k8s agent chart.
helm/agents/k8s/templates/agent.yaml Renders new security context values into the k8s agent manifest.
helm/agents/istio/values.yaml Adds security context value keys for the istio agent chart.
helm/agents/istio/templates/agent.yaml Renders new security context values into the istio agent manifest.
helm/agents/helm/values.yaml Adds security context value keys for the helm agent chart.
helm/agents/helm/templates/agent.yaml Renders new security context values into the helm agent manifest.
helm/agents/cilium-policy/values.yaml Adds security context value keys for the cilium-policy agent chart.
helm/agents/cilium-policy/templates/agent.yaml Renders new security context values into the cilium-policy agent manifest.
helm/agents/cilium-manager/values.yaml Adds security context value keys for the cilium-manager agent chart.
helm/agents/cilium-manager/templates/agent.yaml Renders new security context values into the cilium-manager agent manifest.
helm/agents/cilium-debug/values.yaml Adds security context value keys for the cilium-debug agent chart.
helm/agents/cilium-debug/templates/agent.yaml Renders new security context values into the cilium-debug agent manifest.
helm/agents/argo-rollouts/values.yaml Adds security context value keys for the argo-rollouts agent chart.
helm/agents/argo-rollouts/templates/agent.yaml Renders new security context values into the argo-rollouts agent manifest.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread helm/agents/promql/templates/agent.yaml Outdated
Comment on lines +220 to +227
{{- with .Values.podSecurityContext }}
podSecurityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
Comment thread helm/agents/promql/templates/agent.yaml Outdated
Comment on lines +220 to +227
{{- with .Values.podSecurityContext }}
podSecurityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
…omql template

Signed-off-by: QuentinBisson <quentin@giantswarm.io>
Reduces each agent.yaml from 14 lines of repeated deployment boilerplate
to a single include, and centralises imagePullSecrets, podSecurityContext,
securityContext, and resources rendering in one place per chart.

Signed-off-by: QuentinBisson <quentin@giantswarm.io>
@QuentinBisson QuentinBisson force-pushed the fix/agent-charts-pod-security-context branch from c2957b2 to 797e96c Compare June 9, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants