Commit 3fb24a8
fix(agents): add podSecurityContext and securityContext to all agent charts (kagent-dev#1977)
## 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):
```yaml
podSecurityContext: {}
securityContext: {}
```
`templates/agent.yaml` (render only when set):
```yaml
{{- with .Values.podSecurityContext }}
podSecurityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
```
## Usage
Callers can now pass the required fields:
```yaml
cilium-policy:
podSecurityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
seccompProfile:
type: RuntimeDefault
```
---------
Signed-off-by: QuentinBisson <quentin@giantswarm.io>
Co-authored-by: Eitan Yarmush <eitan.yarmush@solo.io>1 parent 440d5fe commit 3fb24a8
30 files changed
Lines changed: 210 additions & 61 deletions
File tree
- helm/agents
- argo-rollouts
- templates
- cilium-debug
- templates
- cilium-manager
- templates
- cilium-policy
- templates
- helm
- templates
- istio
- templates
- k8s
- templates
- kgateway
- templates
- observability
- templates
- promql
- templates
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 190 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 163 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
| 435 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments