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

Azure: support node label keys having underscores #5116

Merged

Conversation

bpineau
Copy link
Contributor

@bpineau bpineau commented Aug 22, 2022

Azure VMSS tags allowed character set isn't the exact same as the Kubernetes labels' character set. In particular "/" aren't supported as VMSS tags, but are allowed for Kubernetes labels. To support reflecting label values containing "/" to VMSS tags, the cluster-autoscaler evaluates underscores ("_") in VMSS tags keys as slashes ("/") in nodes labels keys.

But due to that substitution, a node label containing "_" (also a valid character for a k8s label) can't be reflected to VMSS tags (as it will be mis-read as a "/").

This PR takes inspiration from rfc6901's JSON escaping (rather hideous, but possibly familiar as it's used by kubectl-patch), by using ("~2") as a replacement for "_".

The tilde (~) character isn't allowed in k8s labels (and taints) keys so there's no possible ambiguities or regressions (a VMSS tag key having a "~" is currently evaluated to an impossible k8s label).

Labels and taints supported character sets:
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#taint

Which component this PR applies to?

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


Azure VMSS tags allowed character set isn't the exact same as the Kubernetes labels' character set.
In particular "/" aren't supported as VMSS tags, but are allowed for Kubernetes labels.
To support reflecting label values containing "/" to VMSS tags, the cluster-autoscaler evaluates underscores ("_") in VMSS tags keys as slashes ("/") in nodes labels keys.

But due to that substitution, a node label containing "_" (also a valid character for a k8s label) can't be reflected to VMSS tags (as it will be mis-read as a "/").

This PR takes inspiration from rfc6901's JSON escaping (rather hideous, but possibly familiar as it's used by kubectl-patch), by using ("~2") as a replacement for "_".

The tilde (~) character isn't allowed in k8s labels (and taints) keys so there's no possible ambiguities or regressions (a VMSS tag key having a ~ is currently evaluated to an impossible k8s label).

Labels and taints supported character sets:
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#taint
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 22, 2022
@bpineau
Copy link
Contributor Author

bpineau commented Sep 13, 2022

Hi @feiskyer @nilo19 @marwanad , could you have a look please?

@marwanad
Copy link
Member

The change looks good to me.

/cc @gandhipr for the final review/OK as I moved on from Azure.

@gandhipr
Copy link
Contributor

gandhipr commented Sep 14, 2022

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

@gandhipr: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@marwanad
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bpineau, gandhipr, marwanad

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 14, 2022
@k8s-ci-robot k8s-ci-robot merged commit cb1ba27 into kubernetes:master Sep 14, 2022
navinjoy pushed a commit to navinjoy/autoscaler that referenced this pull request Oct 26, 2022
…score-tags

Azure: support node label keys having underscores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants