metrics-server icon indicating copy to clipboard operation
metrics-server copied to clipboard

Migrate from Pod Security Policy to SecurityContext

Open pierluigilenoci opened this issue 2 years ago • 25 comments

What would you like to be added:

Pod Security Policies are deprecated and will be removed in Kubernetes v1.25.

Migration to another alternative is necessary. To date there are some alternative solutions:

A solution that is ecumenical and covers all the aforementioned alternatives is the use of Security Context directly in the manifest of the chart.

A possible solution would be to implement all the major alternatives within the chart but it is certainly a more onerous job.

Why is this needed:

For the reasons already explained above.

/kind feature

pierluigilenoci avatar Jul 21 '22 07:07 pierluigilenoci

@stevehipwell could you please take a look?

pierluigilenoci avatar Aug 08 '22 10:08 pierluigilenoci

@pierluigilenoci are you suggesting that the security context for the pod and primary container need updating or are you asking for something else? AFAIK the security admission control is namespace based so out of the scope of a chart, but the chart should be following best practices and potentially offer a non-mutating PSP version to use as a pre-migration step.

stevehipwell avatar Aug 08 '22 11:08 stevehipwell

@stevehipwell I suggest adding the securityContext as default in the chart so that the software runs as restrictively as possible and limiting the use of the PSP only if the K8s version is < 1.25.

For example, this is completely missing:

capabilities:
  drop:
    - ALL

pierluigilenoci avatar Aug 08 '22 14:08 pierluigilenoci

@pierluigilenoci I think the security context needs to come form the Metrics Server maintainers, the Helm chart copies what's in the manifest and also provides the ability to set the pod security policy in addition. AFAIK this change isn't required to enable pod admission, it just means that it needs to be configured correctly (as it will need to be for multiple other pods running in kube-system). I do agree that the PSP resources should be gated on the K8s version, I'll open a PR to do this.

@serathius do you have any plans to change the manifest security policy configuration?

stevehipwell avatar Aug 08 '22 17:08 stevehipwell

@stevehipwell obviously, the request must be evaluated by the maintainers and implemented in the chart only after it is approved.

I would also like to have the opinion of @serathius about it.

pierluigilenoci avatar Aug 09 '22 13:08 pierluigilenoci

@pierluigilenoci the chart usually tracks the installation manifest, so changes would be expected there first which would then be implemented as the defaults in the chart. This issue is currently labelled for the chart but I think it's really about Metrics Server in general.

stevehipwell avatar Aug 09 '22 13:08 stevehipwell

@stevehipwell do you think it might make sense to create a new issue for this more general aspect?

pierluigilenoci avatar Aug 09 '22 14:08 pierluigilenoci

@stevehipwell do you think it might make sense to create a new issue for this more general aspect?

@pierluigilenoci that might be a good idea, maybe pitched more about reducing default permissions ready for pod security admission? This issue could then be renamed to track getting any changes into Helm?

stevehipwell avatar Aug 09 '22 15:08 stevehipwell

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Nov 07 '22 15:11 k8s-triage-robot

/remove-lifecycle stale

pierluigilenoci avatar Nov 15 '22 16:11 pierluigilenoci

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Feb 13 '23 16:02 k8s-triage-robot

/remove-lifecycle stale

pierluigilenoci avatar Feb 19 '23 10:02 pierluigilenoci

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar May 20 '23 11:05 k8s-triage-robot

/remove-lifecycle stale

pierluigilenoci avatar May 22 '23 08:05 pierluigilenoci

@stevehipwell, I lost track of this issue and never created the follow-up one; sorry.

pierluigilenoci avatar May 22 '23 08:05 pierluigilenoci

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 20 '24 23:01 k8s-triage-robot

/remove-lifecycle stale

pierluigilenoci avatar Jan 22 '24 09:01 pierluigilenoci

https://github.com/kubernetes-sigs/metrics-server/pull/1471

at the very least we should avoid making psps in 1.25 and above

treksler avatar Apr 16 '24 23:04 treksler

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jul 16 '24 00:07 k8s-triage-robot

/remove-lifecycle stale

pierluigilenoci avatar Jul 16 '24 12:07 pierluigilenoci

@pierluigilenoci PSP is disabled for K8s versions where it's no longer supported. For the Helm chart the pod and container security contexts are both configurable. Could you expand on the actual changes you'd like to see?

stevehipwell avatar Jul 16 '24 12:07 stevehipwell

We talked about it almost two years ago: https://github.com/kubernetes-sigs/metrics-server/issues/1063#issuecomment-1209504970

pierluigilenoci avatar Jul 16 '24 12:07 pierluigilenoci

@pierluigilenoci I read that comment again but your most recent comment was that you hadn't followed up on this.

As the replacement for PSPs are Pod Security Standards you might be best off documenting how the Metrics Server defaults don't work with them and what you think the defaults should be changed to.

stevehipwell avatar Jul 16 '24 13:07 stevehipwell