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

Kubelet shouldn't require apiserver to populate host ip of pods #6558

Closed
bprashanth opened this issue Apr 8, 2015 · 32 comments · Fixed by #27508
Closed

Kubelet shouldn't require apiserver to populate host ip of pods #6558

bprashanth opened this issue Apr 8, 2015 · 32 comments · Fixed by #27508
Assignees
Labels
priority/backlog Higher priority than priority/awaiting-more-evidence. sig/node Categorizes an issue or PR as relevant to SIG Node.

Comments

@bprashanth
Copy link
Contributor

Currently we query the apiserver for the node (indirectly: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/kubelet/kubelet.go#L1710) before populating hostip on a pod. I believe this is because the node controller is responsible for calling into the cloud provider and populating the ip address on a node:
https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/cloudprovider/controller/nodecontroller.go#L391

This is disappointing for 2 reasons:

  1. It makes using ips to identify nodes harder (Figure out the most reliable way to identify a node #6557).
  2. Doesn't separate concerns sufficiently. If the reflector fails to watch nodes reliably pods won't get a hostip.
@bprashanth bprashanth added team/master sig/node Categorizes an issue or PR as relevant to SIG Node. labels Apr 8, 2015
@roberthbailey
Copy link
Contributor

Also see #6087.

@ghost
Copy link

ghost commented Apr 10, 2015

I would argue that if we're unable to watch nodes reliably, we have many other problems. That seems like something we need to fix, rather than work around.

@bprashanth
Copy link
Contributor Author

watch is watch, a separation of concerns between the kubelet (which is running on the node that has the hostip) and the apiserver is a different problem imo.

@davidopp davidopp added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Apr 12, 2015
@davidopp
Copy link
Member

After discussion, we decided to just remove host IP from PodStatus. (It will still be available from "kubectl get nodes" if someone needs it.)

@bgrant0607 does that sound OK with you?

@roberthbailey
Copy link
Contributor

I'm working on making the nodes register themselves rather than having the node controller do it for them (see roberthbailey@dcec615 which should turn into a PR later this week). Will that assuage your concerns here?

@davidopp
Copy link
Member

I hadn't looked at your PR. We discussed having Kubelet pull ths information from the cloud provider but thought it might not be a good idea due to (1) requiring Kubelet to understand the details of all the cloud providers, and (2) making very hard to rate limit the calls into the cloud provider.

I could imagine an approach where we still use NodeController to get the node address, but the node still initiates the registration into the cluster. Not sure whether that's a good idea, though.

@lavalamp

@bgrant0607
Copy link
Member

Kubelet won't necessarily (and really shouldn't) have the credentials necessary to contact the cloud provider.

I don't remember why HostIP was added to PodStatus, and I would favor removing it, except that it would be a breaking change. You could ask on google-containers@ whether anyone is relying upon it.

HostIP is tricky, as hosts may have multiple addresses, in general, which is why NodeAddresses is now an array.

@roberthbailey
Copy link
Contributor

On GCE / AWS do you even need credentials to determine your external IP? I thought you got it from the metadata server running locally without needing to hit an Auth'd API endpoint.

@bgrant0607
Copy link
Member

HostIP wasn't the external IP AFAIK. It's not well defined what it is, which is one reason it should be eliminated.

Yes, one should be able to get the host IP from metadata, but the cloudprovider library doesn't currently do that.

@lavalamp
Copy link
Member

I'm also in favor of removing HostIP from pods. But I don't agree with the reason in the OP (that sometimes it'll be blank when kubelet hasn't heard from apiserver)-- I think that's par for the course.

@davidopp
Copy link
Member

@roberthbailey Should we schedule a meeting to discuss whether it's reasonable for Kubelets to pull their IPs directly from the cloud provider? What is the alternative -- a new API endpoint on the master where unregistered nodes can query their IP address from NodeController? Do nodes really need their IP address when they register with the master?

@roberthbailey
Copy link
Contributor

That sounds like a good idea (I think we can likely clear this up with a quick meeting rather than going back and forth for days in github comments).

@bgrant0607
Copy link
Member

We all agreed that we should remove HostIP from pods.

Nodes do not need to provide their address(es) when they register. It's not part of the spec. They could provide whatever hostnames and/or addresses they can get through normal Linux mechanisms and/or could contact a local metadata server, but I don't think that's necessary, since the node controller will update the addresses once the node is registered, unless we want to support scenarios with no cloud provider and no external node database. In any case, we shouldn't discuss self-registration in this issue. There are other issues that cover that topic.

@davidopp
Copy link
Member

OK, so this issue just boils down to removing HostIP from PodStatus, and we'll discuss the rest in #6949 ?

@ikehz
Copy link
Contributor

ikehz commented Jan 29, 2016

Ping on this. e2e "Pods should get a host IP [Conformance]" is currently disabled everywhere. Bumping this to P1 and flake.

@ikehz ikehz added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. kind/flake Categorizes issue or PR as related to a flaky test. and removed priority/backlog Higher priority than priority/awaiting-more-evidence. labels Jan 29, 2016
@davidopp
Copy link
Member

Today Kubelet fills PodStatus.HostIP in generatePodStatus() in kubelet.go
Master (e.g. NodeController) is not involved.

Currently the test waits two minutes for a pod to get a HostIP

hostIPTimeout := 2 * time.Minute

Considering that we have proposed to remove this field completely, I think we should just bump up the timeout a bit and see if that fixes the test.

Any other thoughts?

I have also sent out email to the appropriate mailing lists to see if anyone is using PodStatus.HostIP, since we would like to get rid of it, as discussed upthread.

@davidopp
Copy link
Member

cc/ @dchen1107

@davidopp
Copy link
Member

BTW the title of this issue says "Kubelet shouldn't require apiserver to populate host ip of pods." But it wasn't clear to me where the dependency on the API server is (unfortunately @bprashanth 's original comment points to a very old revision to kubelet.go so I'm not sure which line he was referring to). The work of finding the HostIP seems to be done by Kubelet.GetHostIP() / Kubelet.GetNode() which assumes Kubelet.nodeInfo is filled in -- is that the dependency? I couldn't find where that gets filled in.

@dchen1107 would be great if you could shed some light.

@bprashanth
Copy link
Contributor Author

I haven't looked at this code recently but nodinfo appears to still be retrieved from a cache populated via apiserver watch:

nodeInfo := &predicates.CachedNodeInfo{nodeLister}

@davidopp
Copy link
Member

Ah yes, that looks right, thanks @bprashanth
(well, "right" in the sense of "that's where it gets populated," not in the sense of "it makes sense that kubelet is using code defined in the scheduler predicates for this"...)

@bprashanth while you're here, do you have a suggestion of the best course of action? Long-term we want to get rid of PodStatus.HostIP, but short-term we need to do something about this test. How can we make populating the cache more reliable? Or should we just increase the timeout on the test? Or something else?

@bprashanth
Copy link
Contributor Author

It looks like the kubelet already has the node address: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet.go#L2663, so assuming no one else is going to change the ip, we could just store it in the kubelet and add it for every pod? Unsure if this is a safe assumption.

@bprashanth
Copy link
Contributor Author

I also haven't debugged this new set of test failures, so I'm not sure if it's failing for the same reason

@bprashanth
Copy link
Contributor Author

Unsure if this is a safe assumption.

... to make on all clouds

@davidopp
Copy link
Member

There isn't a new set of failures - Ike just noticed that the test is disabled, from when this issue was originally opened.

@dchen1107 @yujuhong could one of you comment on whether Prashanth's suggestion
#6558 (comment)
sounds reasonable?

@dchen1107
Copy link
Member

I didn't parse through the entire issue since a lot of information is stale. Yes David is right, we moved to the logic of filling hostIP of Pod from apiserver to kubelet long time ago. Recording to the comment of Prashanth: #6558 (comment):

Some users might have node with multiple network interfaces, and want to hostIP with specific one
by updating Node object.

@bprashanth
Copy link
Contributor Author

Fwiw I think we should turn the test on and handle things as they come up. I think the major source of flake was handled when we did: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/kubelet.go#L2663

@bgrant0607
Copy link
Member

With respect to the long-term future of HostIP: I'm in favor of documenting the field as deprecated and asking users to contact us with their use case if they need it (in the API field documentation).

As long as the field exists, I agree we should test that it's set correctly.

@davidopp
Copy link
Member

davidopp commented Feb 2, 2016

@ihmccreery in this comment #6558 (comment)
you wrote "Ping on this. e2e "Pods should get a host IP [Conformance]" is currently disabled everywhere. Bumping this to P1 and flake."

What made you say it is disabled? I looked at Jenkins and it seems to be running it:
http://kubekins.dls.corp.google.com/job/kubernetes-e2e-gce/10795/testReport/(root)/Kubernetes%20e2e%20suite/Pods_should_get_a_host_IP__Conformance_/history/

I looked in hack/jenkins/e2e.sh and didn't see any special handling of [Conformance]. There is an env var CONFORMANCE_TEST_SKIP_REGEX in hack/gingko-e2e.sh but it doesn't seem to be set anywhere. So I don't see anything that should be causing this test to not be run.

(As always there's a high likelihood I'm misunderstanding something.)

@davidopp
Copy link
Member

davidopp commented Feb 2, 2016

Sorry, I'm totally blind, the Jenkins history I linked to clearly shows it is being skipped.

But I'm still not sure what is causing it to be skipped.

@ikehz
Copy link
Contributor

ikehz commented Feb 2, 2016

Sorry I wasn't clear; it's being skipped because it was marked pending via PIt. Let's agree to use [Flaky] and [Feature:.+] labels in the future for clarity's sake.

@thockin
Copy link
Member

thockin commented Feb 2, 2016

Also see #15169 for use cases of "I need to know my local node" and possible fixes.

@davidopp
Copy link
Member

davidopp commented Feb 2, 2016

I'm going to remove the flake label, since #20510 has been merged and that was the suggestion here #6558 (comment). We can re-add the label if it flakes again. I'm not closing the issue, because we want to deprecate the field longer-term.

@davidopp davidopp removed the kind/flake Categorizes issue or PR as related to a flaky test. label Feb 2, 2016
@davidopp davidopp added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Feb 15, 2016
k8s-github-robot pushed a commit that referenced this issue Jun 26, 2016
Automatic merge from submit-queue

Kubelet can retrieve host IP even when apiserver has not been contacted

fixes #26590, fixes #6558

Right now the kubelet expects to get the hostIP from the kubelet's local nodeInfo cache. However, this will be empty if there is no api-server (or the apiServer has not yet been contacted).

In the case of static pods, this change means the downward api can now be used to populate hostIP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/backlog Higher priority than priority/awaiting-more-evidence. sig/node Categorizes an issue or PR as relevant to SIG Node.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants