-
Notifications
You must be signed in to change notification settings - Fork 457
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
feat: Make it possible to customize k8s resources #686
Conversation
@regisb while testing this with a new plugin, I noticed a case that we need to think about: If two plugins override the same Kubernetes resource. In my case, I have two plugins that are overriding the Caddy PVC size. The first one is overriding it to 5Gi, the second one to 7Gi. When I run # $(tutor config printroot)/env/k8s/override.yml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: caddy
labels:
app.kubernetes.io/component: volume
app.kubernetes.io/name: caddy
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: caddy
labels:
app.kubernetes.io/component: volume
app.kubernetes.io/name: caddy
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 7Gi
What should Tutor do in such a case? (@fghaas This is an example of the issues you mentioned in this comment) |
Also there is another issue here. Let's say we have 5 plugins that are changing 5 different properties of the same Kubernetes resource. One plugin changes its volume, one changes its label, one changes its docker image, and so on.
This is not really a desirable situation. The good thing about Tutor's current setup is that we can just read one file (for example |
I don't think that Tutor should be doing anything. It's not Tutor's job to decide which plugin is right. Instead, Tutor's job is to provide a consistent experience and ensure that users have the same result across multiple runs. (thus: load plugins in alphabetical order) Consider the alternative: what if multiple plugins override the same Tutor setting? Users will have to chase which plugin is setting each config value. The situation is worse.
Note that it's possible for developers to modify the order of patches. Actions support a
Yes, the definition of k8s resources will be spread over two files instead of just one. But it's easy enough to display a merged view using:
We could even add that command as Does this answer your questions? |
If I may interject, I don't quite agree with that premise, based on how Tutor behaves today. If someone's PLUGINS:
- foo
- bar ... then if Tutor truly didn't "decide which plugin is right", it's reasonable to expect that Could I ask how loading the plugins in alphabetical order, rather than the order in which they are listed in Footnotes
|
I disagree with this premise. If it did, then the order with which we enable plugins would be important. This would be a source of confusion. In order to debug other people's platforms, we would have to ask them to run |
Yes but right now absolutely nothing except one line of code indicates that it isn't. And a YAML sequence is an ordered series of zero or more nodes (emphasis mine; a mapping in contrast is unordered), so in my humble opinion it is perfectly reasonable to expect that the order in a sequence is preserved. |
Loading plugins in alphabetical order is one of the many design decisions on which I made a judgment call during development. While I stand by my choice, if you're interested I encourage you to open a new topic about this on the forum. Since this matter is only tangentially related to the current pull request, it would be better if we moved the conversation elsewhere. If we have this conversation, then I'd like to ask you to take into account the two arguments that I listed above:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh dammit I wrote these comments before the weekend and forgot to press "submit review"... Sorry about the delay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I think this is a great step forward. Just rebase your changes and we'll merge.
Currently there is no way for plugins to customize Kubernetes resources defined in Tutor deployment manifests. This change makes that possible by taking advantage of the strategic merge patching mechanism in `kustomization.yml`. Any resource definition in a `k8s-override` patch in a plugin will override the resource defined by Tutor, provided that their names match. Reference: overhangio#675
Thanks @regisb for the review. I rebased the PR now. |
Thanks for your patience @foadlind! |
@regisb Could you please lay out your suggestions here for using this functionality in a Maple environment? As far as I can tell there is currently no branch that would allow this to be backported and/or added to a future 13.x.x release. I imagine that, based on prior experience with Open edX, many users would be reluctant to upgrade For what it's worth, the particular change covered in this PR would be a clean cherry-pick onto the What do you think? |
Unfortunately I'm not willing to maintain releases older than the current one. If you need Tutor v13 with some of the v14 features, I suggest that you fork Tutor and cherry-pick the changes you need. |
Currently there is no way for plugins to customize Kubernetes resources
defined in Tutor deployment manifests.
This change makes that possible by taking advantage of the strategic
merge patching mechanism in
kustomization.yml
.Any resource definition in a
k8s-override
patch in a plugin willoverride the resource defined by Tutor, provided that their names match.
Based on this comment from @regisb in #675.