helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

[kube-prometheus-stack] support for prometheusOperator.admissionWebhooks.patch.containerSecurityContext

Open r0bj opened this issue 2 years ago • 7 comments

Is your feature request related to a problem ?

When namespace is protected by restricted Pod Security Standard [1] there is a need to add some securityContext to the containers. It is possible to add required containerSecurityContext to prometheus-operator itself:

containerSecurityContext:
  allowPrivilegeEscalation: false
  capabilities:
    drop:
    - ALL

However it's not possible to add it to admissionWebhooks containers. There is only pod level securityContext (prometheusOperator.admissionWebhooks.patch.securityContext) but it's not enough. Certain securityContext parameters can only be applied at container level (e.g. allowPrivilegeEscalation, capabilities).

[1] https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted

Describe the solution you'd like.

Add support for admission webhook containers securityContext, e.g.: prometheusOperator.admissionWebhooks.patch.containerSecurityContext similar to how we can do it with prometheus-operator containers. Alternatively as less flexible solution we can add restricted Pod Security Standard compatible parameters as a static manifest:

containers:
- name: create
  securityContext:
    allowPrivilegeEscalation: false
    capabilities:
      drop:
      - ALL

Describe alternatives you've considered.

None

Additional context.

No response

r0bj avatar Jun 01 '22 03:06 r0bj

Hello,

I have the same issue, i want to apply an immutable infrastructure strategy (readOnlyRootFilesystem on containers) but .Values.prometheusOperator.containerSecurityContext is not deployed into prometheusOperator .

cf. https://github.com/prometheus-community/helm-charts/blob/kube-prometheus-stack-35.5.1/charts/kube-prometheus-stack/values.yaml#L1708 cf. https://github.com/prometheus-community/helm-charts/blob/kube-prometheus-stack-35.5.1/charts/kube-prometheus-stack/templates/prometheus-operator/admission-webhooks/job-patch/job-createSecret.yaml#L33-L46

MalibuKoKo avatar Jun 03 '22 08:06 MalibuKoKo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Jul 07 '22 00:07 stale[bot]

It's still valid.

r0bj avatar Jul 07 '22 01:07 r0bj

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Aug 10 '22 04:08 stale[bot]

It's still valid.

r0bj avatar Aug 10 '22 04:08 r0bj

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Sep 16 '22 01:09 stale[bot]

bump

r0bj avatar Sep 16 '22 02:09 r0bj

Just chiming in this is an important feature for regulated industries to be able to achieve compliance when using these charts per CIS EKS 4.6.2.

awhitepl avatar Sep 28 '22 19:09 awhitepl

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Oct 29 '22 02:10 stale[bot]

bump

r0bj avatar Oct 29 '22 02:10 r0bj

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Nov 28 '22 04:11 stale[bot]

bump

r0bj avatar Nov 28 '22 04:11 r0bj

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

stale[bot] avatar Dec 31 '22 22:12 stale[bot]

bump

joebowbeer avatar Dec 31 '22 23:12 joebowbeer

Container's securityContext for both create and patch container can be set through values

prometheusOperator:
  admissionWebhooks:
    createSecretJob:
      securityContext: {}
    patchWebhookJob:
      securityContext: {}

Introduced in kube-prometheus-stack-39.11.0.

zeritti avatar Jan 07 '23 00:01 zeritti

@zeritti Thanks.

r0bj avatar Jan 07 '23 00:01 r0bj