question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible issues with Kubernetes Ingress, default backends, and lexicographic ordering

See original GitHub issue

Setup

I have been experimenting with the Linkerd Ingress controller. I am trying to deploy a sample calculator service. This service is composed of six services:

  • the gateway service for people to submit equation
  • the tokenizer service to split the equation into operators and digits
  • four generic operator services

Based this blog post, I have tried modeling an ingress object for each service much like the world-v1 and world-v2 (world.v2). This gives the illusion that each service is owned by a team and such a team would want to deploy a newer version of their service. In this case, the default and “v2” (.spec.rules.host) version are actually the same thing.

All Ingress objects look like the following:

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: "addition-operator"
  namespace: "team-addition-operator"
  annotations:
    kubernetes.io/ingress.class: "linkerd"
  labels:
    app: "addition-operator"
    environment: "preprod"
spec:
  backend:
    serviceName: "addition-operator"
    servicePort: "my-http"
  rules:
  - host: "addition-operator"
    http:
      paths:
      - backend:
          serviceName: "addition-operator"
          servicePort: "my-http"

Having one ingress controller (really, a pod in a daemonset) reading many Ingress objects each with their own non-host “default” backend doesn’t make much sense, so I have omitted the .spec.backend in most of the Ingress Objects. However, I did leave the .spec.backend pointed in the gateway’s Ingress object.

Ingress Objects in alphabetical order:

  • addition-operator
  • division-operator
  • gateway (only this has a .spec.backend)
  • multiplication-operator
  • subtraction-operator
  • tokenizer

Actual Behavior

Note: curl’s default proxy port is 1080. I have added this to my Linkerd Daemonset’s Ports and ConfigMap’s servers section.

core@w2 ~ $ curl --proxy localhost subtraction-operator/operate?args=1,6
404 page not found
core@w2 ~ $ curl --proxy localhost addition-operator/operate?args=1,6
{"value":7}core@w2 ~ $

Logs (from the l5d pod I am proxying to):

I 0409 19:13:53.050 UTC THREAD17: k8s no suitable rule found in addition-operator for request subtraction-operator /operate
I 0409 19:13:53.051 UTC THREAD17: k8s no suitable rule found in division-operator for request subtraction-operator /operate
I 0409 19:13:53.051 UTC THREAD17: k8s using default service IngressPath(None,None,default,gateway,my-http) for request subtraction-operator /operate
I 0409 19:14:00.394 UTC THREAD16: k8s found rule matching addition-operator /operate: IngressPath(Some(addition-operator),None,default,addition-operator,my-http)

Expected Behavior

Given that I am using the host subtraction-operator, there is not way I should be routed to the default backend.

Notes

If I remove the gateway’s .spec.backend, the example works as expected.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jgensler8commented, Apr 10, 2017

I think some of the earlier examples of Ingress Controllers gave the responsibility of a “default backend” to the Controller, not to the Ingress Objects. link

args:
- /nginx-ingress-controller
- --default-backend-service=$(POD_NAMESPACE)/default-http-backend

Based on these lines, the “default backend” serves 404 pages.

One use case I was thinking of is an organization with multiple applications (say shoes.com and books.org) that are hosted on the same entry Ingress Controller but eventually end up with different “default” page based on the website. The first Ingress Controller wouldn’t have a default backend. Instead, it would have separate backends based on the Host. Each separate backend (shoes.com and books.org) would have its own organizational Ingress Controller with their branded 404 page. Alternatively, they could use Ingress’s .spec.backend. Similar to what @adleong has stated earlier, it is unclear which option (multiple Ingress Controllers w/ default backend set to .spec.ingress vs Single Controller w/ multiple Ingress Objects) would be the best for such an organization.

0reactions
esbiecommented, Apr 10, 2017

A catch-all global default service could end up being a pretty common use case. If multiple folks are confused by this, we should re-evaluate how the identifier evaluates.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ingress - Kubernetes
An Ingress with no rules sends all traffic to a single default backend and .spec.defaultBackend is the backend that should handle requests ...
Read more >
Understanding Kubernetes Ingress Resources and Controllers
Backend is a combination of Service and port, as seen above. An Ingress controller is needed to satisfy the Ingress you created, as...
Read more >
Exposing Kubernetes Applications, Part 3: NGINX Ingress ...
We expect the last two requests to be routed to the default backend, as one is sent to a path that isn't defined...
Read more >
Kubernetes Troubleshooting Walkthrough - Tracing through ...
An ingress resource depends on a Kubernetes service and a service depends on pod(s) where it can send the traffic to. If any...
Read more >
Kubernetes Ingress-Nginx Troubleshooting made Easy with ...
lint Inspect kubernetes resources for possible issues ... upstream-default-backend$ kubectl ingress-nginx backends -n kube-system --backend ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found