Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v14] charts/teleport-cluster: configurable podSecurityContext #40950

Merged
merged 5 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/pages/reference/helm-reference/teleport-cluster.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,23 @@ See [the GitHub PR](https://github.com/gravitational/teleport/pull/36251) for te
memory: 2Gi
```

## `podSecurityContext`

| Type | Default value |
|----------|---------------|
| `object` | `{}` |

[Kubernetes reference](https://kubernetes.io/docs/concepts/security/pod-security-standards/)

The `podSecurityContext` applies to the main Teleport pods.

`values.yaml` example:

```yaml
podSecurityContext:
fsGroup: 65532
```

## `securityContext`

| Type | Default value |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
clusterName: helm-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
clusterName: helm-lint
podSecurityContext:
fsGroup: 99
fsGroupChangePolicy: OnRootMismatch
runAsGroup: 99
runAsNonRoot: true
runAsUser: 99
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ spec:
{{- end }}
{{- if $auth.priorityClassName }}
priorityClassName: {{ $auth.priorityClassName }}
{{- end }}
{{- if $auth.podSecurityContext }}
securityContext: {{- toYaml $auth.podSecurityContext | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "teleport-cluster.auth.serviceAccountName" . }}
terminationGracePeriodSeconds: {{ $auth.terminationGracePeriodSeconds }}
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ spec:
{{- end }}
{{- if $proxy.priorityClassName }}
priorityClassName: {{ $proxy.priorityClassName }}
{{- end }}
{{- if $proxy.podSecurityContext }}
securityContext: {{- toYaml $proxy.podSecurityContext | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "teleport-cluster.proxy.serviceAccountName" . }}
terminationGracePeriodSeconds: {{ $proxy.terminationGracePeriodSeconds }}
29 changes: 29 additions & 0 deletions examples/chart/teleport-cluster/tests/auth_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,35 @@ tests:
- matchSnapshot:
path: spec.template.spec

- it: should set podSecurityContext when set in values
template: auth/deployment.yaml
values:
- ../.lint/pod-security-context.yaml
asserts:
- equal:
path: spec.template.spec.securityContext.fsGroup
value: 99
- equal:
path: spec.template.spec.securityContext.fsGroupChangePolicy
value: OnRootMismatch
- equal:
path: spec.template.spec.securityContext.runAsGroup
value: 99
- equal:
path: spec.template.spec.securityContext.runAsNonRoot
value: true
- equal:
path: spec.template.spec.securityContext.runAsUser
value: 99

- it: should not set podSecurityContext when is empty object (default value)
template: auth/deployment.yaml
values:
- ../.lint/pod-security-context-empty.yaml
asserts:
- isNull:
path: spec.template.spec.securityContext

- it: should set securityContext when set in values
template: auth/deployment.yaml
values:
Expand Down
29 changes: 29 additions & 0 deletions examples/chart/teleport-cluster/tests/proxy_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,35 @@ tests:
- matchSnapshot:
path: spec.template.spec

- it: should set podSecurityContext when set in values
template: proxy/deployment.yaml
values:
- ../.lint/pod-security-context.yaml
asserts:
- equal:
path: spec.template.spec.securityContext.fsGroup
value: 99
- equal:
path: spec.template.spec.securityContext.fsGroupChangePolicy
value: OnRootMismatch
- equal:
path: spec.template.spec.securityContext.runAsGroup
value: 99
- equal:
path: spec.template.spec.securityContext.runAsNonRoot
value: true
- equal:
path: spec.template.spec.securityContext.runAsUser
value: 99

- it: should not set podSecurityContext when is empty object (default value)
template: proxy/deployment.yaml
values:
- ../.lint/pod-security-context-empty.yaml
asserts:
- isNull:
path: spec.template.spec.securityContext

- it: should set securityContext when set in values
template: proxy/deployment.yaml
values:
Expand Down
5 changes: 5 additions & 0 deletions examples/chart/teleport-cluster/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,11 @@
"type": "object",
"default": {}
},
"podSecurityContext": {
"$id": "#/properties/podSecurityContext",
"type": "object",
"default": {}
},
"securityContext": {
"$id": "#/properties/securityContext",
"type": "object",
Expand Down
4 changes: 4 additions & 0 deletions examples/chart/teleport-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,10 @@ resources: {}
# limits:
# memory: "2Gi"

# Pod security context for any pods created by the chart
podSecurityContext: {}
# fsGroup: 65532

# Security context to add to the container
securityContext: {}
# runAsUser: 99
Expand Down
Loading