Allow to set NodeSelector via spec.deployments.nodeSelector - #658
Conversation
Part of #5 This patch adds `spec.deployments.nodeSelector` to set nodeSelector on each deployment. For example, when the following CR is created, ``` apiVersion: operator.knative.dev/v1alpha1 kind: KnativeServing metadata: name: ks namespace: knative-serving spec: high-availability: replicas: 1 deployments: - name: webhook nodeSelector: foo: bar ``` The webhook deployment has `spec.template.spec.nodeSelector`. ``` $ kubectl get deploy -n knative-serving webhook -o jsonpath={.spec.template.spec.nodeSelector} {"foo":"bar"} ```
|
The following is the coverage report on the affected files.
|
markusthoemmes
left a comment
There was a problem hiding this comment.
Looks spot on to me!
/hold
For feedback from others.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: markusthoemmes, nak3 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
|
||
| func replaceNodeSelector(override *v1alpha1.DeploymentOverride, deployment *appsv1.Deployment) { | ||
| if len(override.NodeSelector) > 0 { | ||
| deployment.Spec.Template.Spec.NodeSelector = override.NodeSelector |
There was a problem hiding this comment.
This feature is fine.
My question is whether to overwrite or replace for the nodeselector.
NodeSelector is a key-value map, the same to Labels and Annotations.
For Labels and Annotations, we add the override into the existing map, but for NodeSelector, we replace the existing with the override. Why not keep the existing keys, that is not in override for NodeSelector?
For example,
If override is {"key1": "val1"}, there is an existing map {"key": "val"}, we will end up with {"key1": "val1"}, not {"key1": "val1", "key": "val"}. The existing "key" is gone.
There was a problem hiding this comment.
I don't think it's useful to merge node selectors. IIRC they're in an AND combination, so adding more would likely result in no nodes matching anymore. Plus: We don't have preset node selectors at all.
There was a problem hiding this comment.
Yes I made this by design because of the reason Markus mentioned.
There was a problem hiding this comment.
Then I am ok with this PR.
|
/hold cancel |
|
I will update the doc here https://knative.dev/docs/install/operator/configuring-serving-cr/#override-system-deployments |
|
/test pull-knative-operator-serving-upgrade-tests |
* Add `nodeSelector` to override system deployments by operator This patch adds docs for knative/operator#658. It adds `nodeSelector` to override system deployments by operator. * Fix broken format * Update docs/admin/install/operator/configuring-serving-cr.md Co-authored-by: Ashleigh Brennan <abrennan@redhat.com> * Update docs/admin/install/operator/configuring-serving-cr.md Co-authored-by: Ashleigh Brennan <abrennan@redhat.com> * Update docs/admin/install/operator/configuring-serving-cr.md Co-authored-by: Ashleigh Brennan <abrennan@redhat.com> * Update docs/admin/install/operator/configuring-serving-cr.md Co-authored-by: Ashleigh Brennan <abrennan@redhat.com> Co-authored-by: Ashleigh Brennan <abrennan@redhat.com>
…e#3789) * Add `nodeSelector` to override system deployments by operator This patch adds docs for knative/operator#658. It adds `nodeSelector` to override system deployments by operator. * Fix broken format * Update docs/admin/install/operator/configuring-serving-cr.md Co-authored-by: Ashleigh Brennan <abrennan@redhat.com> * Update docs/admin/install/operator/configuring-serving-cr.md Co-authored-by: Ashleigh Brennan <abrennan@redhat.com> * Update docs/admin/install/operator/configuring-serving-cr.md Co-authored-by: Ashleigh Brennan <abrennan@redhat.com> * Update docs/admin/install/operator/configuring-serving-cr.md Co-authored-by: Ashleigh Brennan <abrennan@redhat.com> Co-authored-by: Ashleigh Brennan <abrennan@redhat.com>
Part of #5
This patch adds
spec.deployments.nodeSelectorto set nodeSelector oneach deployment.
For example, when the following CR is created,
The webhook deployment has
spec.template.spec.nodeSelector./cc @houshengbo @markusthoemmes @matzew