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
luxas
left a comment
There was a problem hiding this comment.
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
timothysc
left a comment
There was a problem hiding this comment.
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.
|
|
||
| // 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.
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.
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.
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 |
fabriziopandini
left a comment
There was a problem hiding this comment.
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 DetailsNeeds 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-overridewill 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: