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

Config to prevent podSpec alteration from plugin #357

Merged
merged 1 commit into from
Jul 31, 2024
Merged

Conversation

DrJosh9000
Copy link
Contributor

@DrJosh9000 DrJosh9000 commented Jul 29, 2024

What

Add a prohibit-kubernetes-plugin option, usable as either a flag or config option, which causes jobs to fail if they contain plugins: - kubernetes: ....

Why

This is an easy way to lock down a k8s cluster and prevent users from doing such things as:

  • using podSpec or podSpecPatch to specify undesirable container images, override the container entrypoint, etc
  • using extraVolumeMounts to mount undesirable volumes
  • using env, envFrom, or gitEnvFrom to map and leak unintended secrets
  • disabling or enabling the checkout container, override git flags in an undesirable way,

etc etc

How

The main change is to introduce the prohibit-kubernetes-plugin flag and config value, and then use it throughout the scheduler.

Because this balances things out of favour of a k8sPlugin-centric interpretation of celestial mechanics, some useful refactors were in order:

  • Build now takes a pointer to the podSpec it is supposed to be building, so that we can change which one we're building from Create. BuildFailureJob doesn't have to set k8sPlugin.PodSpec in order to build a special podspec.
  • Labels and annotations are set on kjob first, instead of set in k8sPlugin and then moved to kjob.
  • jobWrapper is now buildInputs. It has no methods (they're moved to worker) and is intended to contain only the relevant parts of CommandJob needed by Build or BuildFailureJob. The goal is to make the data flow (what data is need by which operation) clearer.

@DrJosh9000 DrJosh9000 force-pushed the push-ysrlsunqwszx branch 4 times, most recently from a0132c7 to 02a6b0f Compare July 29, 2024 08:14
@DrJosh9000 DrJosh9000 marked this pull request as draft July 29, 2024 08:15
@DrJosh9000 DrJosh9000 force-pushed the push-ysrlsunqwszx branch 9 times, most recently from b0bfb69 to 6daebf0 Compare July 30, 2024 05:35
@DrJosh9000 DrJosh9000 marked this pull request as ready for review July 30, 2024 05:46
@DrJosh9000 DrJosh9000 requested a review from a team July 30, 2024 05:46
Copy link
Contributor

@wolfeidau wolfeidau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 🚀 🎉

@DrJosh9000 DrJosh9000 merged commit 3dec44c into main Jul 31, 2024
1 check passed
@DrJosh9000 DrJosh9000 deleted the push-ysrlsunqwszx branch July 31, 2024 00:11
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.

2 participants