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

fix: Put KubeletExtraArgs in double quotes for Windows #1082

Conversation

yveslaroche
Copy link
Contributor

@yveslaroche yveslaroche commented Nov 3, 2020

PR o'clock

Description

Put KubeletExtraArgs in double quotes for Windows, it is already double quoted in the Bash script. This allows for variable substitution within the string e.g.

kubelet_extra_args = "node.kubernetes.io/lifecycle=$(Invoke-WebRequest -Uri http://169.254.169.254/latest/meta-data/instance-life-cycle | Select-Object -ExpandProperty Content)"

Checklist

Copy link

@bogdan-alov bogdan-alov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@barryib
Copy link
Member

barryib commented Nov 3, 2020

Is this different from #1046 ? Because the double quote in linux introduce a bug for multiple taints support. See FAQ update for variable substitution in linux. Does it work for windows ?

See also #1004

@barryib
Copy link
Member

barryib commented Nov 4, 2020

/ping @yveslaroche and @bogdanalov-sw

@yveslaroche
Copy link
Contributor Author

I have successfully tested applying multiple labels and taints for both Linux and Windows nodes using double quotes in the bootstrap scripts with the examples below.

# Linux
kubelet_extra_args = "--node-labels=node.kubernetes.io/role=worker,node.kubernetes.io/lifecycle=$(curl -s http://169.254.169.254/latest/meta-data/instance-life-cycle) --register-with-taints=somekey=somevalue:NoSchedule,anotherkey=anothervalue:NoSchedule"

# Windows
kubelet_extra_args = "--node-labels=node.kubernetes.io/role=windows,node.kubernetes.io/lifecycle=$(Invoke-WebRequest -Uri http://169.254.169.254/latest/meta-data/instance-life-cycle | Select-Object -ExpandProperty Content) --register-with-taints=os=windows:NoSchedule,anotherkey=anothervalue:NoSchedule"

In addition, I tested the taints applied in #1004. In this case the node won't register, but if I change the name of one of the keys to something else, it works. Hence, I believe the problem is applying two taints with the same key and effect, but different values.

@barryib
Copy link
Member

barryib commented Nov 4, 2020

By reading this awslabs/amazon-eks-ami#179 it sounds like we should use '' (single quotes) to surround kubelet_extra_args and "" (double quotes) to surround arguments.

Something like: '--register-with-taints="os=windows:NoSchedule,anotherkey=anothervalue:NoSchedule"'

I haven’t test it yet, but I'm going to dig a bit.

When we use single quotes for KubeletExtraAgrs, in linux, you should escape variable:

$ echo 'my name is ${USER}'
my name is ${USER}

$ echo 'my name is '${USER}''
my name is foo

In addition, I tested the taints applied in #1004. In this case the node won't register, but if I change the name of one of the keys to something else, it works. Hence, I believe the problem is applying two taints with the same key and effect, but different values.

I think you can normally provide multiple taints with the same key (by example key1=value1:NoSchedule and key1=value1:NoExecute) https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/

@yveslaroche
Copy link
Contributor Author

@barryib

I think you can normally provide multiple taints with the same key (by example key1=value1:NoSchedule and key1=value1:NoExecute)
Yes, but that's a different effect that's set which is allowed. Setting the same key and effect, but with a different value multiple times is not allowed. If you apply it manually you'd get:

error: node ip-xx-xx-xx-xx.us-west-2.compute.internal already has env taint(s) with same effect(s)

@barryib
Copy link
Member

barryib commented Nov 4, 2020

@barryib

I think you can normally provide multiple taints with the same key (by example key1=value1:NoSchedule and key1=value1:NoExecute)
Yes, but that's a different effect that's set which is allowed. Setting the same key and effect, but with a different value multiple times is not allowed. If you apply it manually you'd get:

error: node ip-xx-xx-xx-xx.us-west-2.compute.internal already has env taint(s) with same effect(s)

Sorry for the typo. I was thinking about key1=value1:NoSchedule and key1=value2:NoSchedule. I'll make some tests also.

@barryib
Copy link
Member

barryib commented Nov 4, 2020

@yveslaroche just made some tests and I can confirm your point.

It is already quoted in the Bash script. This allows for variable substitution within the string e.g.
kubelet_extra_args = "node.kubernetes.io/lifecycle=$(Invoke-WebRequest -Uri http://169.254.169.254/latest/meta-data/instance-life-cycle | Select-Object -ExpandProperty Content)"
@yveslaroche yveslaroche force-pushed the windows-kubelet-extra-args-quotes branch from 9b830a5 to ac63a2d Compare November 5, 2020 10:54
@stale
Copy link

stale bot commented Feb 10, 2021

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
To track this PR (even if closed), please open a corresponding issue if one does not already exist.

@stale stale bot added the stale label Feb 10, 2021
@stale
Copy link

stale bot commented Mar 12, 2021

This PR has been automatically closed because it has not had recent activity since being marked as stale.
Please reopen when work resumes.

@stale stale bot closed this Mar 12, 2021
@sebas-w
Copy link

sebas-w commented May 27, 2021

Are we able to reopen this? What additional items were needed to get this merged? @barryib

@barryib
Copy link
Member

barryib commented May 27, 2021

I don't use windows at all, so the point is how this different from #1082 (comment) ? There is already a PR to put back single quote for linux workers #1046.

I need people to test this.

@barryib barryib reopened this May 27, 2021
@stale stale bot removed the stale label May 27, 2021
@stale
Copy link

stale bot commented Aug 25, 2021

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
To track this PR (even if closed), please open a corresponding issue if one does not already exist.

@antonbabenko
Copy link
Member

Thanks @yveslaroche !

v17.8.0 has been just released.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants