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,220 points
718 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
• 52,350 points

Related Questions In Kubernetes

0 votes
1 answer

I am not able to set static IP for my ubuntu VM.... I am referring Kubernetes installation!

Hey, check this out for the steps ...READ MORE

answered Sep 28, 2020 in Kubernetes by Vishwanath Deshpande

edited Oct 6, 2021 by Sarfaraz 754 views
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
• 7,060 points
12,063 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
• 52,350 points
1,261 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
• 52,350 points
2,123 views
+1 vote
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
15,477 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,035 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
• 52,350 points
1,730 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP