Unable to curl ingress from inside of the machine: 404

12/29/2018

The cluster is running on a Ubuntu 18.06 machine (VPS). It's using a metal load balancer in front.

So, what did I try so far:

  • curl 192.168.0.12:8080/system/ipaddr works fine! (curl the pod)
  • curl 10.97.125.155:31001/system/ipaddr works fine! (curl the service)
  • curl 192.168.1.240/articleservice/system/ipaddr FAILS -> 404

Logs of the ingress-nginx:

I1229 20:05:59.688397       9 event.go:221] Event(v1.ObjectReference{Kind:"Ingress", Namespace:"default", Name:"articleservice-ingress", UID:"28fef789-0ba5-11e9-a12a-0050563e015b", APIVersion:"extensions/v1beta1", ResourceVersion:"630309", FieldPath:""}): type: 'Normal' reason: 'CREATE' Ingress default/articleservice-ingress
W1229 20:05:59.688797       9 controller.go:826] Service "default/articleservice" does not have any active Endpoint.
173.249.46.84 - [173.249.46.84] - - [29/Dec/2018:20:22:07 +0000] "GET /articleservice/getAllArticles HTTP/1.1" 404 153 "-" "curl/7.61.0" 354 0.000 [-] - - - - 0dad96ea6a6be639cd62544c7871a52e

Below you see the output of the description for the pod, service and the ingress.




Output of kubectl describe pod articleservice

  Name:               articleservice-deployment-5d78cc95f-jfctl
    Namespace:          default
    Priority:           0
    PriorityClassName:  <none>
    Node:               server.net/173.249.46.84
    Start Time:         Sat, 29 Dec 2018 21:06:05 +0100
    Labels:             app=articleservice
                        pod-template-hash=5d78cc95f
    Annotations:        cni.projectcalico.org/podIP: 192.168.0.12/32
    Status:             Running
    IP:                 192.168.0.12
    Controlled By:      ReplicaSet/articleservice-deployment-5d78cc95f
    Containers:
      articleservice:
        Container ID:   docker://04d9fd926966fd5a45829776a0d5d85198a6920e0f98d8d8b3cb4802897f66f0
        Image:          elps/articleservice:1.0.8
        Image ID:       docker-pullable://elps/articleservice@sha256:813c36c53d2b5199baa7223d4f348c5ab181cb8b233d4b47be801079cad6b743
        Ports:          8080/TCP, 5005/TCP
        Host Ports:     0/TCP, 0/TCP
        State:          Running
          Started:      Sat, 29 Dec 2018 21:06:18 +0100
        Ready:          True
        Restart Count:  0
        Environment:
          ARTICLE_SERVICE_HOST:   <set to the key 'articleservice-host' of config map 'articleservice-configmap'>   Optional: false
          ARTICLE_SERVICE_PORT:   <set to the key 'articleservice-port' of config map 'articleservice-configmap'>   Optional: false
          ARTICLE_SERVICE_PATH:   <set to the key 'articleservice-path' of config map 'articleservice-configmap'>   Optional: false
          CART_SERVICE_HOST:      <set to the key 'cartservice-host' of config map 'articleservice-configmap'>      Optional: false
          CART_SERVICE_PORT:      <set to the key 'cartservice-port' of config map 'articleservice-configmap'>      Optional: false
          CART_SERVICE_PATH:      <set to the key 'cartservice-path' of config map 'articleservice-configmap'>      Optional: false
          CATALOG_SERVICE_HOST:   <set to the key 'catalogservice-host' of config map 'articleservice-configmap'>   Optional: false
          CATALOG_SERVICE_PORT:   <set to the key 'catalogservice-port' of config map 'articleservice-configmap'>   Optional: false
          CATALOG_SERVICE_PATH:   <set to the key 'catalogservice-path' of config map 'articleservice-configmap'>   Optional: false
          CUSTOMER_SERVICE_HOST:  <set to the key 'customerservice-host' of config map 'articleservice-configmap'>  Optional: false
          CUSTOMER_SERVICE_PORT:  <set to the key 'customerservice-port' of config map 'articleservice-configmap'>  Optional: false
          CUSTOMER_SERVICE_PATH:  <set to the key 'customerservice-path' of config map 'articleservice-configmap'>  Optional: false
          MYSQL_HOST:             <set to the key 'database-host' of config map 'articleservice-configmap'>         Optional: false
          MYSQL_DB:               <set to the key 'database-name' of config map 'articleservice-configmap'>         Optional: false
          MYSQL_USER:             <set to the key 'database-user' in secret 'articleservice-secret'>                Optional: false
          MYSQL_PASSWORD:         <set to the key 'database-password' in secret 'articleservice-secret'>            Optional: false
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-zp5k9 (ro)
    Conditions:
      Type              Status
      Initialized       True 
      Ready             True 
      ContainersReady   True 
      PodScheduled      True 
    Volumes:
      default-token-zp5k9:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-zp5k9
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                     node.kubernetes.io/unreachable:NoExecute for 300s

Output of kubectl describe service articleservice

Name:                     articleservice
Namespace:                default
Labels:                   <none>
Annotations:              <none>
Selector:                 app=articleservice
Type:                     NodePort
IP:                       10.97.125.155
Port:                     web  31001/TCP
TargetPort:               8080/TCP
NodePort:                 web  31001/TCP
Endpoints:                192.168.0.12:8080
Port:                     debug  5005/TCP
TargetPort:               5005/TCP
NodePort:                 debug  32001/TCP
Endpoints:                192.168.0.12:5005
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

Output of kubectl describe ingress articleservice-ingress

Name:             articleservice-ingress
Namespace:        default
Address:          192.168.1.240
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  elpsit.com  
              /articleservice   articleservice:31001 (<none>)
Annotations:
  nginx.ingress.kubernetes.io/rewrite-target:  /
Events:
  Type    Reason  Age   From                      Message
  ----    ------  ----  ----                      -------
  Normal  CREATE  25m   nginx-ingress-controller  Ingress default/articleservice-ingress
  Normal  UPDATE  25m   nginx-ingress-controller  Ingress default/articleservice-ingress
-- elp
kubernetes
nginx-ingress

1 Answer

12/30/2018

As @Matthew L Daniel already mentioned: I need to define the ingress host like this:

curl -vH 'host: elpsit.com' http://192.168.1.240/articleservice/system/ipaddr

-- elp
Source: StackOverflow