Skip to content

Exclude node from loadbalancer on servicing#661

Open
jknipper wants to merge 3 commits intomasterfrom
add_exclude_lb_label
Open

Exclude node from loadbalancer on servicing#661
jknipper wants to merge 3 commits intomasterfrom
add_exclude_lb_label

Conversation

@jknipper
Copy link
Copy Markdown
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
Comment thread pkg/util/node.go
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
Copy Markdown
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
Copy Markdown
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

Comment thread pkg/util/node.go
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
Copy Markdown
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