-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
kubeadm: Let the --node-name
flag flow down to --hostname-override
for the kubelet
#64706
kubeadm: Let the --node-name
flag flow down to --hostname-override
for the kubelet
#64706
Conversation
/cc @kubernetes/sig-cluster-lifecycle-pr-reviews |
If --node-name is passed in to `kubeadm init`, `--hostname-override` will be passed to kubelet.
e2e2f84
to
b42564a
Compare
/test pull-kubernetes-e2e-gce |
--node-name
override option flow down to --hostname-override
for the kubelet
--node-name
override option flow down to --hostname-override
for the kubelet--node-name
flag flow down to --hostname-override
for the kubelet
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.
Code-wise I'm happy with this, but we have to clearly document the change in behavior we have here.
Earlier --node-name
let you change the SAN of the cert so it matches the name the kubelet decides to have by using autodetection.
Now we basically force the kubelet to have the node name you give to kubeadm.
Further, it seems --hostname-override
has no effect at all when using at least in-tree cloud providers: #64661
/lgtm
/assign @timothysc
for the second approval
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.
generally I approve, but I have a question about usage and how this overlaps with your other patch, b/c people can muck it up pretty easily.
@@ -78,7 +79,12 @@ func buildKubeletArgMap(nodeRegOpts *kubeadmapi.NodeRegistrationOptions, registe | |||
kubeletFlags["resolv-conf"] = "/run/systemd/resolve/resolv.conf" | |||
} | |||
|
|||
// TODO: Pass through --hostname-override if a custom name is used? | |||
// Make sure the node name we're passed will work with Kubelet | |||
if nodeRegOpts.Name != "" && nodeRegOpts.Name != nodeutil.GetHostname("") { |
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.
given that the most common thing folks do is use fully qualified domain names I'm almost wondering if we should force tolower on the names similar to your other 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 just tested this, and it appears this already happens automatically:
ubuntu@ip-172-31-84-104:~$ sudo /tmp/kubeadm init -v 1 --pod-network-cidr=192.168.0.0/16 --node-name ALLCAPS.horse
ubuntu@ip-172-31-84-104:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
allcaps.horse Ready master 44s v1.11.0-beta.0
I don't particularly know how, but I think this is a nonissue either way.
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.
The nodeutil.GetHostname()
func lowercases automatically:
// GetHostname returns OS's hostname if 'hostnameOverride' is empty; otherwise, return 'hostnameOverride'.
func GetHostname(hostnameOverride string) string {
hostname := hostnameOverride
if hostname == "" {
nodename, err := os.Hostname()
if err != nil {
glog.Fatalf("Couldn't determine hostname: %v", err)
}
hostname = nodename
}
return strings.ToLower(strings.TrimSpace(hostname))
}
/milestone v1.11 |
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.
thanks @liztio!
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: fabriziopandini, liztio, luxas 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 |
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process @fabriziopandini @liztio @luxas @timothysc Pull Request Labels
|
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
Kubeadm-initialised kubelet uses provided hostname if present
If --node-name is passed in to
kubeadm init
,--hostname-override
will bepassed to kubelet. This prevents timeout errors for
kubeadm init
.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes kubernetes/kubeadm#846
Special notes for your reviewer:
Depends on #64624 to work fully, but can safely merged before hand.
Release note: