Skip to content

Helm charts:: Security Contexts#6125

Draft
pasindutennage-da wants to merge 1 commit into
mainfrom
pasindutennage-da/fix/5825
Draft

Helm charts:: Security Contexts#6125
pasindutennage-da wants to merge 1 commit into
mainfrom
pasindutennage-da/fix/5825

Conversation

@pasindutennage-da

@pasindutennage-da pasindutennage-da commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@pasindutennage-da pasindutennage-da marked this pull request as draft June 25, 2026 14:03
@pasindutennage-da pasindutennage-da marked this pull request as ready for review June 25, 2026 14:33

@moritzkiefer-da moritzkiefer-da 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.

The change itself looks fairly reasonable. But there is a very large number of configuration flags on security contexts and security contexts on various levels. They did mention this explicitly but their message sounds fairly ambigous and they may just have used this an example. Can we check with them what they expect?

@martinflorian-da

martinflorian-da commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

I think there are two parts here:

  1. What are reasonable defaults that we would (eventually) like everyone to have.
  2. What is a cheap way to allow arbitrary customizations.

For 1. we need some research; did we do that somewhere?

For 2. I'm not sure if this PR goes in the right direction. Why not just allow overriding the securityContext: field completely? Then people can configure whatever they want, whenever they want.

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.

Can we use something other than docs? We know the docs are going away soon

@canton-network canton-network deleted a comment from github-actions Bot Jun 26, 2026
@pasindutennage-da

Copy link
Copy Markdown
Contributor Author

@martinflorian-da

For 2. I'm not sure if this PR goes in the right direction. Why not just allow overriding the securityContext: field completely? Then people can configure whatever they want, whenever they want.

I agree with your point. We can let one override securityContext, however, we (I) should make sure that whatever they put inside that object is supported in our helm charts; else, it will break.

What I would do is; define securityContext in schema as an object with our selected subset (not just allowPrivilegeEscalation) of allowed options. Then in Helm helper, I will set only those supported options.

@moritzkiefer-da

Copy link
Copy Markdown
Contributor

however, we (I) should make sure that whatever they put inside that object is supported in our helm charts; else, it will break.

I wouldn't try to enforce this in the schema. Trying to figure out all the various options that may be safe is a lost cause and some options may be safe in some usecase but not others. Just set the ones that are always valid by default and let people overwrite with whatever they want.

@martinflorian-da

Copy link
Copy Markdown
Contributor

Totally agree with @moritzkiefer-da ; for the defaults it's IMO fine enough if we ensure validity via our cluster testing. For everything else - up to the users to pick the right strings. If they want to override this it's reasonable to assume they have some idea what they are doing.

@pasindutennage-da

Copy link
Copy Markdown
Contributor Author

@martinflorian-da @moritzkiefer-da

I will allow overriding the containerSecurityContext field, so users can put whatever they want. We will set a few defaults that won't break our deployments.

Full list of securitycontext: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.36/#securitycontext-v1-core

Defaults

allowPrivilegeEscalation: false (controls whether a process can gain more privileges than its parent

privileged: false (container does not run in privileged mode)

runAsNonRoot: true (ensures the container must run as a non-root user) -- cluster_test will say if this breaks some postgress pods

Testing

I will update the tests to verify both the default state (no overrides) and the arbitrary overrides. Just extending my current 2 test per chart strcuture.

To define these default securitycontext, we can either put them in values-template.yaml, or directly in the Helm _helpers.tpl . Which one do you think is clearer?

@moritzkiefer-da

Copy link
Copy Markdown
Contributor

any reason not to set something like

  seccompProfile:
    type: RuntimeDefault

and maybe switch to explicit capabilities whitelists?

it seems like runAsUser, runAsGroup and fsGroup are also set quite frequently from a quick search but I also can't come up with all that clear of a reason why it meaningfully improves things over runAsNonRoot: false so fine to skip for now.

To define these default securitycontext, we can either put them in values-template.yaml, or directly in the Helm _helpers.tpl . Which one do you think is clearer?

I think I prefer values-templates. Then you also get automatic merging with user-supplied values.

Note that there is also both a pod and a container security context. I think we want to set both.

@pasindutennage-da

Copy link
Copy Markdown
Contributor Author

@moritzkiefer-da @martinflorian-da

I made the changes for scan helm chart. To make sure that we are on the same page, can you please have a look and see if scan helm chart (only scan helm chart for now) supports all the security contexts?

The remaining work is to just duplicate this across all helm charts, and I will do it next.

@moritzkiefer-da moritzkiefer-da 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.

thx, it looks good in configurability, the big question ofc is if it really works so definitely make sure to test this

Comment thread cluster/helm/splice-scan/templates/scan.yaml
Comment thread cluster/helm/splice-scan/values-template.yaml Outdated
Comment thread cluster/helm/splice-scan/values-template.yaml Outdated
@martinflorian-da martinflorian-da marked this pull request as draft June 29, 2026 12:05
@pasindutennage-da pasindutennage-da force-pushed the pasindutennage-da/fix/5825 branch from 8572f64 to 0ac0cb3 Compare June 29, 2026 16:04
[ci]

Signed-off-by: pasindutennage-da <pasindu.tennage@digitalasset.com>

Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
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.

4 participants