-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Allow nodename to be != hostname, use AWS instance ID on AWS #9728
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c28cdfb
For kubelet, differentiate between the nodeName and the hostname
justinsb efaead8
Allow cloud providers to return a node identifier different from the …
justinsb c89b0cd
AWS: Use the instance id as the node name
justinsb 77e1bd3
NodeName != HostName: Fixes for contrib/mesos
justinsb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -565,8 +565,30 @@ func SimpleKubelet(client *client.Client, | |
// Eventually, #2 will be replaced with instances of #3 | ||
func RunKubelet(kcfg *KubeletConfig, builder KubeletBuilder) error { | ||
kcfg.Hostname = nodeutil.GetHostname(kcfg.HostnameOverride) | ||
|
||
if kcfg.NodeName == "" { | ||
// Query the cloud provider for our node name, default to Hostname | ||
nodeName := kcfg.Hostname | ||
if kcfg.Cloud != nil { | ||
var err error | ||
instances, ok := kcfg.Cloud.Instances() | ||
if !ok { | ||
return fmt.Errorf("failed to get instances from cloud provider") | ||
} | ||
|
||
nodeName, err = instances.CurrentNodeName(kcfg.Hostname) | ||
if err != nil { | ||
return fmt.Errorf("error fetching current instance name from cloud provider: %v", err) | ||
} | ||
|
||
glog.V(2).Infof("cloud provider determined current node name to be %s", nodeName) | ||
} | ||
|
||
kcfg.NodeName = nodeName | ||
} | ||
|
||
eventBroadcaster := record.NewBroadcaster() | ||
kcfg.Recorder = eventBroadcaster.NewRecorder(api.EventSource{Component: "kubelet", Host: kcfg.Hostname}) | ||
kcfg.Recorder = eventBroadcaster.NewRecorder(api.EventSource{Component: "kubelet", Host: kcfg.NodeName}) | ||
eventBroadcaster.StartLogging(glog.Infof) | ||
if kcfg.KubeClient != nil { | ||
glog.V(4).Infof("Sending events to api server.") | ||
|
@@ -625,17 +647,17 @@ func makePodSourceConfig(kc *KubeletConfig) *config.PodConfig { | |
// define file config source | ||
if kc.ConfigFile != "" { | ||
glog.Infof("Adding manifest file: %v", kc.ConfigFile) | ||
config.NewSourceFile(kc.ConfigFile, kc.Hostname, kc.FileCheckFrequency, cfg.Channel(kubelet.FileSource)) | ||
config.NewSourceFile(kc.ConfigFile, kc.NodeName, kc.FileCheckFrequency, cfg.Channel(kubelet.FileSource)) | ||
} | ||
|
||
// define url config source | ||
if kc.ManifestURL != "" { | ||
glog.Infof("Adding manifest url: %v", kc.ManifestURL) | ||
config.NewSourceURL(kc.ManifestURL, kc.Hostname, kc.HTTPCheckFrequency, cfg.Channel(kubelet.HTTPSource)) | ||
config.NewSourceURL(kc.ManifestURL, kc.NodeName, kc.HTTPCheckFrequency, cfg.Channel(kubelet.HTTPSource)) | ||
} | ||
if kc.KubeClient != nil { | ||
glog.Infof("Watching apiserver") | ||
config.NewSourceApiserver(kc.KubeClient, kc.Hostname, cfg.Channel(kubelet.ApiserverSource)) | ||
config.NewSourceApiserver(kc.KubeClient, kc.NodeName, cfg.Channel(kubelet.ApiserverSource)) | ||
} | ||
return cfg | ||
} | ||
|
@@ -656,6 +678,7 @@ type KubeletConfig struct { | |
FileCheckFrequency time.Duration | ||
HTTPCheckFrequency time.Duration | ||
Hostname string | ||
NodeName string | ||
PodInfraContainerImage string | ||
SyncFrequency time.Duration | ||
RegistryPullQPS float64 | ||
|
@@ -715,6 +738,7 @@ func createAndInitKubelet(kc *KubeletConfig) (k KubeletBootstrap, pc *config.Pod | |
pc = makePodSourceConfig(kc) | ||
k, err = kubelet.NewMainKubelet( | ||
kc.Hostname, | ||
kc.NodeName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need similar change in |
||
kc.DockerClient, | ||
kubeClient, | ||
kc.RootDirectory, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why do we still want to keep hostname? why not replace hostname with nodename completely? but still keep hostname_override flag? and marked it to be deprecated? then introducing another one called nodename_override, and it not specified, make it equals to hostname_override?
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 think you are breaking ppl using hostname_override now. Should we treat the value of flag hostname_override as node_name here?
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 don't think I am breaking hostname_override, except maybe on AWS, where if it is broken I want to break it :-)
The logic is this: we build Hostname, just as before: hostname from the OS, but can be overridden by hostname_override. If we have a CloudProvider, we ask it to determine the node-name, but all the implementations apart from AWS simply echo back the maybe-overridden hostname.
That is why we pass hostname in to CurrentNodeName. It is admittedly a weird argument to pass in - it feels a little out of place. Maybe it would be cleaner if we didn't pass in anything, but only changed the nodeName if CurrentNodeName returned non-empty? But then that makes the function even more specialized. I think post V1 we will want a function which returns the CurrentNode() (see https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/kubelet/kubelet.go#L721-L735)
hostname (& hostname_override) do determine the SSL self-signed cert subject, so I think we have to keep this.
I do agree that we will likely end up with a nodename_override (or just nodename?) but I'm hoping that maybe we can avoid it - that it will only be needed on bare-metal, and on bare-metal the hostname is the logical identifier for nodes.
This is possibly optimistic, but I'd rather avoid introducing another flag until we have someone that needs it!
If you'd prefer, I can create nodename_override, but I don't think anyone will have to use it today.
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.
[EDIT]
incontrib/mesos/pkg/executor/service/service.go
setkcfg.NodeName = kcfg.Hostname
.ignore prior statement
also, some unit tests may need updating in
contrib/mesos/pkg/executor/executor_test.go
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.
@justinsb I agreed we shouldn't need nodename_override. The only reason I suggested it above is that I thought we could completely remove hostname* term from our source base, and I think it is very misleading. But you are right that today we need it for SSL cert.