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

Exclude node from loadbalancer on servicing #661

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jknipper
Copy link
Collaborator

No description provided.

@jknipper jknipper changed the title Exclude node from loadbalancer on servicing [WIP] Exclude node from loadbalancer on servicing Jun 10, 2022
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)
Copy link
Contributor

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

Copy link
Collaborator Author

@jknipper jknipper Jun 17, 2022

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)
Copy link
Contributor

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.

@jknipper jknipper requested a review from auhlig as a code owner June 17, 2022 13:04
@jknipper jknipper changed the title [WIP] Exclude node from loadbalancer on servicing Exclude node from loadbalancer on servicing Jun 17, 2022
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