-
Notifications
You must be signed in to change notification settings - Fork 15
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
Proposal: use corev1.PodSpec for the PodTemplate field #172
Comments
I beileve it's rather a good idea. But we should keep in mind for future releases to think twice if there is something to be a possible breaking change. I vote for |
I am waiting for some work-around of it or idea how to prevent - maybe admission controller and validation of fields? |
A scenario like this is fundamentally unpreventable, because there is no way of knowing if the user accidentally had a container with the same name as ours, or if he actually wanted to override some fields on our sidecar. |
@lllamnyp it's not true, as you can disallow the applying of incorrect object to k8s API - with admission controller. It is the same mechanics as nginx ingress disallow multiple Ingresses with the same pair host - path. |
what does it mean? You are referring to fields not implemented in out version of PodSpec? They are not "not working", they are "not implemented" or "non existing" in our spec, so it would be clearly understandable from |
I want to support the idea that the An operator is primarily a similar controller that is just more knowledgeable about the logic of stateful application it operates. It knows how to properly deploy and scale it. It should assist the user, but not restrict them from potential mishaps. Moreover, if a user intends to break the deployment, they will find a way to do so regardless if we restrict certain parameters. Also I'm convinced that the same common predictable logic sould ve used for merging parameters across all such |
Examples with Currently you have two states:
This is a bad approach - it violates encapsulation, contains hidden execution logic, and can lead to many errors. I believe the idea of using podSpec is redundant. The operator shouldn't allow the user to configure the entire pod specification because it is unnecessary for them. The operator's primary responsibility is to ensure the cluster's operation and restrict the user from attempting to disrupt this work, which is the opposite of the current situation. As a result, with this approach, the ability to use default values and validations in CRDs will be lost, leading to the need for additional code development. |
@sergeimonakhov totally agree with you.
If you (i.e. user) need it, you always can write your own mutation controller (for instance, based on Kyverno). |
@gecube Say, a user has spec:
containers:
- name: our-future-sidecar
# some fields with overrides What was the user's intent? Did he want to add a sidecar with a name that conflicts with a potential sidecar that was implemented by us? Or did he deliberately want to override our sidecar? |
I completely agree that the code as is isn't great. There's a lot of custom merging logic that is error prone and the |
All deleted code will be brought back into the tests to verify that strategic patching works correctly when merging arrays within an array, overwriting fields, and in other corner cases... |
Tests for the current custom merging logic already exist, so no code will be "brought back" per se, but you are right that some tests will be rewritten. Still, wouldn't you much rather have some basic tests that verify that you are correctly using an external library function, rather than a super-detailed suite of tests for a custom function that you rolled yourself? Now I do believe that not having podTemplate at all is also a good choice, but that's out of scope for this issue. |
I'm closing this issue as implemented in #175 |
Proposal
I suggest we consider using the k8s core type
corev1.PodSpec
instead of our own implementation for overrides in the pod template generated by the operator:Pros:
EtcdCluster.spec.podTemplate.spec
to work, whereas they won't.Merging logic
Right now we merge the pod template with the final result in a manner like
This can be reduced to
This has the advantage of correctly merging list values, letting users add or override fields under keys such as
containers
,env
,volumes
, and so on.Cons:
Further remarks
EtcdClusterSpec
, since we already anticipate common use-cases for them. This would free most users from ever having to set thepodTemplate
field to a non-nil value.The text was updated successfully, but these errors were encountered: