Kubernetes ingress IP is set to docker0 ip

0 votes

I'm trying to use the kubernetes ingress resource on bare metal with no cloud provider.

I created an ingress resource:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx
spec:
  rules:
  - host: foobar.com
    http:
      paths:
      - path: /foo
        backend:
          serviceName: echoheaders-x
          servicePort: 80
      - path: /
        backend:
          serviceName: frontend
          servicePort: 80

however, when I view the ingress, I get this IP:

[root@kubemaster]# kubectl get ing
NAME      HOSTS       ADDRESS      PORTS     AGE
nginx     foobar.com   172.17.0.1   80        12m

That IP address seems to correspond with the docker0 IP address on all my kubelet nodes.

Is there a way to set this IP? 

Here's my nginx-controller yaml:

---
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx-ingress-controller
  labels:
    k8s-app: nginx-ingress-lb
spec:
  replicas: 1
  selector:
    k8s-app: nginx-ingress-lb
  template:
    metadata:
      labels:
        k8s-app: nginx-ingress-lb
        name: nginx-ingress-lb
    spec:
      terminationGracePeriodSeconds: 60
      containers:
      - image: gcr.io/google_containers/nginx-ingress-controller:0.8.3
        name: nginx-ingress-lb
        imagePullPolicy: Always
        readinessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
        livenessProbe:
          httpGet:
            path: /healthz
            port: 10254
            scheme: HTTP
          initialDelaySeconds: 10
          timeoutSeconds: 1
        # use downward API
        env:
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: POD_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
        ports:
        - containerPort: 80
          hostPort: 80
        - containerPort: 443
          hostPort: 443
        # we expose 18080 to access nginx stats in url /nginx-status
        # this is optional
        - containerPort: 18080
          hostPort: 18080
        args:
        - /nginx-ingress-controller
        - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
        - --nginx-configmap=$(POD_NAMESPACE)/nginx-ingress-controller
Sep 10, 2018 in Kubernetes by lina
• 8,200 points
57 views

1 answer to this question.

0 votes

The issue here was the kubelet configuration. By default, the kubelet will listen on 0.0.0.0 and because docker0 is the first available address, it grabbed docker0's IP.

I added the following to the kubelet config:

--address=<actualip> --node-ip=<actualip>

And it registered correctly.

answered Sep 10, 2018 by Kalgi
• 51,830 points

Related Questions In Kubernetes

0 votes
2 answers

Deny access to some specific paths while using kubernetes ingress

Try to create two Ingresses first by default ...READ MORE

answered Sep 21, 2018 in Kubernetes by Nilesh
• 6,960 points
3,056 views
0 votes
1 answer

Filter source ip in kubernetes ingress in GCE

This feature currently works only with nginx. Example ...READ MORE

answered Sep 7, 2018 in Kubernetes by Kalgi
• 51,830 points
343 views
0 votes
2 answers

Not able to expose port 80 on the host, kubernetes ingress

I was facing the same error. The nginix ...READ MORE

answered Sep 11, 2018 in Kubernetes by Kalgi
• 51,830 points
134 views
0 votes
1 answer

Issue with Kubernetes ingress routing to Nextjs applications

You’re using nginx ingress controller which does ...READ MORE

answered Sep 11, 2018 in Kubernetes by Kalgi
• 51,830 points
360 views
0 votes
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
5,510 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 11, 2019 in Kubernetes by Kalgi
• 51,830 points

reshown Apr 12, 2019 by Kalgi 1,507 views
0 votes
1 answer

Kubernetes: Ingress doesn't set IP address

You must set up an ingress controller ...READ MORE

answered Sep 12, 2018 in Kubernetes by Kalgi
• 51,830 points
425 views