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

Ingress only exposes internal node ip #50

Closed
groob opened this issue Dec 11, 2016 · 8 comments · Fixed by #65
Closed

Ingress only exposes internal node ip #50

groob opened this issue Dec 11, 2016 · 8 comments · Fixed by #65
Labels

Comments

@groob
Copy link

groob commented Dec 11, 2016

I tried installing this version of the ingress controller today and noticed that the Address listed was

kubectl describe ing monitoring                                                                                                              Name:  			monitoring
Namespace:     	    default
Address:       		10.142.0.4
Default backend:       	default-http-backend:80 (10.0.0.21:8080)

Which is the internal node IP.

I made the following change, which resolves the issue for me, but I'm not sure it's the correct fix

diff --git a/core/pkg/ingress/status/status.go b/core/pkg/ingress/status/status.go
index 77b05d8..3a00aa7 100644
--- a/core/pkg/ingress/status/status.go
+++ b/core/pkg/ingress/status/status.go
@@ -206,12 +206,10 @@ func (s *statusSync) getRunningIPs() ([]string, error) {

        ips := []string{}
        for _, pod := range pods.Items {
-               ipAddr := k8s.GetNodeIP(s.Client, pod.Spec.NodeName)
-               if !strings.StringInSlice(ipAddr, ips) {
-                       ips = append(ips, ipAddr)
+               if !strings.StringInSlice(pod.Status.HostIP, ips) {
+                       ips = append(ips, pod.Status.HostIP)
                }
        }
-
        return ips, nil
 }

edit: this diff should be reversed I believe. I accidentally switch the branch..master order.

@bprashanth
Copy link
Contributor

The kubernetes node object should have an ExternalIPs field, which i expect we'd be using to populate the status (haven't checked). If we are, then it's wrongfully populated, if we aren't, we should.

https://github.com/kubernetes/kubernetes/blob/master/pkg/api/types.go#L2236

@bprashanth
Copy link
Contributor

I meant to link to https://github.com/kubernetes/kubernetes/blob/master/pkg/api/types.go#L2618
What platform are you on?

@groob
Copy link
Author

groob commented Dec 11, 2016

I'm on GCP, but using the nginx controller.

@groob
Copy link
Author

groob commented Dec 11, 2016

https://github.com/kubernetes/ingress/blob/697cf2d8c352b461447cf1a7f265702d3e6be530/core/pkg/k8s/main.go#L57 uses NodeExternalIP but the status does not appear to be populating it.

@bprashanth
Copy link
Contributor

what does kubectl get no -o yaml | grep -i external -B 10 (or something to that effect) show?

@groob
Copy link
Author

groob commented Dec 16, 2016

@bprashanth
I see

  status:
    addresses:
    - address: 10.142.0.4
      type: InternalIP
    - address: 104.196.192.60
      type: ExternalIP

when getting node output.

The InternalIP is what shows up in the ingress.

@groob
Copy link
Author

groob commented Dec 16, 2016

I realized the diff I showed in the bug report is reversed. This is the actual change I made to fix my issue:

diff --git a/core/pkg/ingress/status/status.go b/core/pkg/ingress/status/status.go
index 3a00aa7..77b05d8 100644
--- a/core/pkg/ingress/status/status.go
+++ b/core/pkg/ingress/status/status.go
@@ -206,10 +206,12 @@ func (s *statusSync) getRunningIPs() ([]string, error) {

        ips := []string{}
        for _, pod := range pods.Items {
-               if !strings.StringInSlice(pod.Status.HostIP, ips) {
-                       ips = append(ips, pod.Status.HostIP)
+               ipAddr := k8s.GetNodeIP(s.Client, pod.Spec.NodeName)
+               if !strings.StringInSlice(ipAddr, ips) {
+                       ips = append(ips, ipAddr)
                }
        }
+
        return ips, nil
 }

@aledbf
Copy link
Member

aledbf commented Dec 16, 2016

@groob I was fixing an issue with the status address for AWS and I saw this.
I took the liberty to copy your code to also return the correct address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants