-
Notifications
You must be signed in to change notification settings - Fork 26
Exclude node from loadbalancer on servicing #661
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
base: master
Are you sure you want to change the base?
Conversation
| if err != nil { | ||
| return fmt.Errorf("Failed to marshal annotation %v = %v: %s", key, val, err) | ||
| } | ||
| _, err = client.CoreV1().Nodes().Patch(nodeName, types.MergePatchType, data) |
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.
We need to be super careful regarding the patch type. I thinks this shreds every lable, but the one given. (https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment) I think we need a strategic merge patch. ObjectMeta.Labels is not tagged with patchStrategy: merge, so that does not cover it.
So, either we fetch all the labels beforehand or generate a proper (non-merge) JSON Patch
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.
I tested it and it worked that way, eg.
labels:
beta.kubernetes.io/arch: amd64
beta.kubernetes.io/instance-type: c_c2_m2
beta.kubernetes.io/os: linux
ccloud.sap.com/nodepool: payload
failure-domain.beta.kubernetes.io/region: eu-nl-1
failure-domain.beta.kubernetes.io/zone: eu-nl-1b
kubernetes.io/arch: amd64
kubernetes.io/hostname: kks-jan-payload-s7xbf
kubernetes.io/os: linux
kubernikus.cloud.sap/template-version: "6"
node.kubernetes.io/exclude-from-external-load-balancers: "true"
node.kubernetes.io/instance-type: c_c2_m2
topology.cinder.csi.openstack.org/zone: eu-nl-1b
topology.kubernetes.io/region: eu-nl-1
topology.kubernetes.io/zone: eu-nl-1b
It seems only the label itself gets replaced. Otherwise we should have the same problem here I guess: https://github.com/sapcc/kubernikus/blob/master/pkg/util/node.go#L121-L141
| if err != nil { | ||
| return fmt.Errorf("Failed to marshal annotation %v = %v: %s", key, nil, err) | ||
| } | ||
| _, err = client.CoreV1().Nodes().Patch(nodeName, types.MergePatchType, data) |
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.
Same note regarding patch strategy.
No description provided.