Ingress-Nginx w/ Kubernetes not getting IP address

10/25/2018

I am new to Kubernetes and am attempting to get Ingress-Nginx to work on my local k8s cluster.

I have it installed and running:

$ kubectl get pods --namespace=ingress-nginx
  NAME                                       READY   STATUS    RESTARTS   AGE
  nginx-ingress-controller-76f97b74b-bbb6h   1/1     Running   0          13h

Then I created two nginx services (wanted to test name-based routing):

$ kubectl get svc
  NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
    kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP        20h
    nginx        NodePort    10.102.188.253   <none>        80:32025/TCP   36m
    nginx2       NodePort    10.109.43.89     <none>        80:32458/TCP   35m

And I created my ingress:

$ kubectl get ingress -o yaml
apiVersion: v1
items:
- apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    creationTimestamp: 2018-10-25T12:27:44Z
    generation: 1
    name: test
    namespace: default
    resourceVersion: "98114"
    selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/test
    uid: 5fbc2e9e-d851-11e8-995f-2ae1e5e17bac
  spec:
    rules:
    - host: test-ingress.chbresser.com
      http:
        paths:
        - backend:
            serviceName: nginx
            servicePort: 80
    - host: test-ingress2.chbresser.com
      http:
        paths:
        - backend:
            serviceName: nginx2
            servicePort: 80
  status:
    loadBalancer: {}
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

From my understanding that is all I was supposed to do, but its not getting an IP address:

$ kubectl get ingress
  NAME   HOSTS                                                    ADDRESS   PORTS   AGE
    test   test-ingress.chbresser.com,test-ingress2.chbresser.com             80      33m

What step did I miss? Why am I not getting an IP?

Edit:

kubectl logs nginx-ingress-controller-76f97b74b-bbb6h --namespace=ingress-nginx:

W1025 05:44:10.003587       9 queue.go:130] requeuing &ObjectMeta{Name:sync status,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{},Annotations:map[string]string{},OwnerReferences:[],Finalizers:[],ClusterName:,Initializers:nil,}, err services "ingress-nginx" not found
-- CHBresser
kubernetes
nginx

2 Answers

5/30/2019

I use Bare-metal and get IP address by using --report-node-internal-ip-address=true flag in ingress-controller.

Here is my ingress-controller yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata: 
  name: nginx-ingress-controller
spec: 
  replicas: 1
  revisionHistoryLimit: 3
  template: 
    metadata: 
      labels: 
        k8s-app: ingress-nginx
    spec: 
      containers: 
        - args: 
            - /nginx-ingress-controller
            - "--default-backend-service=default/my-app"
            - "--report-node-internal-ip-address=true"
          env: 
            - name: POD_NAME
              valueFrom: 
                fieldRef: 
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom: 
                fieldRef: 
                  fieldPath: metadata.namespace
          image: "quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.15.0"
          name: nginx-ingress-controller
          ports: 
            - containerPort: 80
              hostPort: 80
              name: http
              protocol: TCP

my ingress yaml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata: 
  name: my-app
  annotations: 
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: my-app.example.com
    http: 
     paths:
     - path: /
       backend:
        serviceName: my-app
        servicePort: 80

and result:

$ kubectl get ing
NAME     HOSTS   ADDRESS        PORTS   AGE
my-app   *       192.168.1.78   80      40h

$ kubectl get svc
NAME              TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
kubernetes        ClusterIP   10.96.0.1        <none>        443/TCP          8d
my-app            ClusterIP   10.110.152.216   <none>        80/TCP,443/TCP   8d

$ kubectl get po
NAME                                        READY   STATUS    RESTARTS   AGE
my-app-rc-d7lw9                             1/1     Running   0          8d
my-app-rc-spvjb                             1/1     Running   0          8d
my-app-rc-tvkrw                             1/1     Running   0          8d
nginx-ingress-controller-6c6c899467-d9sg6   1/1     Running   0          16m

for more detail , see this issues.

-- Sandy
Source: StackOverflow

10/25/2018

Can you check this issue if it is related to yours. You might have to upgrade your ingress controller.

git issue for ingress controller

Looking at your edit. It seems you have not applied service for your nginx controller and hence it is not able to find the related srvc .

Check if there is a srvc under namespace ingress-nginx by running below command

kubectl get svc -n ingress-nginx

If it isnt present ,apply the provider specific service.

for example, below one for bare-metal provider

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml

-- Shashank Pai
Source: StackOverflow