Ingress routing by host name challenges

1,358 views
Skip to first unread message

Don Bogardus

unread,
Feb 28, 2017, 4:39:26 PM2/28/17
to Kubernetes developer/contributor discussion
Need some high level guidance and can't see the forest for the documentation trees. 

Have a bunch of microservices (doesn't everyone now), which are accessed from standard ports (fooservice always on port 1234, barservice always on port 4567) 

Have a dev k8s cluster which I want to segregate into dev and staging environments. 

So I'm looking to make both these calls work

dev.services.piedpiper.com:1234 (resolves to a snapshot version of fooservice) 
staging.services.piedpiper.com:1234 (resolves to a release candidate version of fooservice) 

Namespaces look good for getting both versions working on the backend, but struggling getting ingress rules routing to support these goals. 

We have hostname routing working with a Traefik ingress controller, but there are a few problems. We have to map every endpoint (/* doesn't work), and can't get inbound traffic accepted on anything other than port 80. 

Will nginx work better? Any other thoughts? 

Thanks in advance!


Timo Reimann

unread,
Mar 1, 2017, 8:35:40 AM3/1/17
to Kubernetes developer/contributor discussion
Hi,

what do you exactly mean by

We have to map every endpoint (/* doesn't work)

?

If you are asking for regular expression support, Traefik should be able to do that. (See the docs.)
If you mean that you cannot use regular expressions, then one approach is to define one Ingress resource per service.

Which port your inbound traffic flows to should be a matter of defining the right service port in your Ingress resource.

For more specific Traefik support, see the Traefik Slack or file an issue on the issue tracker, ideally along with your configuration.

HTH,

Timo

Guangya Liu

unread,
Mar 1, 2017, 8:58:48 AM3/1/17
to Kubernetes developer/contributor discussion
Are you struggling with this issue https://github.com/kubernetes/ingress/issues/349 ? If so, you may want to add `ingress.kubernetes.io/rewrite-target: /` as annotation to make the path rule works.

在 2017年3月1日星期三 UTC+8上午5:39:26,Don Bogardus写道:

Don Bogardus

unread,
Mar 2, 2017, 1:13:12 PM3/2/17
to Kubernetes developer/contributor discussion
Yes, I would like the /* ingress mapping to just pass through all urls. (so I don't have to map each endpoint individually) 

It seems to be a limitation of ingress rules, Traefik looks like it supports regex nicely. 

I'm playing with nginx now, but so far can't get ingress working at all. 

I'll report back if I get it working. 

Tim Hockin

unread,
Mar 2, 2017, 1:59:52 PM3/2/17
to Don Bogardus, Kubernetes developer/contributor discussion
Doesn't the default backend handle this for you?
> --
> You received this message because you are subscribed to the Google Groups
> "Kubernetes developer/contributor discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kubernetes-de...@googlegroups.com.
> To post to this group, send email to kuberne...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/kubernetes-dev/d691fc64-88a4-48ff-85c0-26038b595d6d%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Warren Strange

unread,
Mar 2, 2017, 4:08:28 PM3/2/17
to Kubernetes developer/contributor discussion

Is there an explanation of what the annotation: ingress.kubernetes.io/rewrite-target does?

Warren Strange

unread,
Mar 2, 2017, 4:11:06 PM3/2/17
to Kubernetes developer/contributor discussion

Answering my own question:


It strips off the request url and re-writes the request with value in the annotation.

Ahmet Alp Balkan

unread,
Mar 2, 2017, 6:16:56 PM3/2/17
to Warren Strange, Kubernetes developer/contributor discussion
Looks like it's not documented on k8s.io. Warren, do you mind opening an issue at https://github.com/kubernetes/kubernetes.github.io/issues/new or even better contributing a patch?

--
You received this message because you are subscribed to the Google Groups "Kubernetes developer/contributor discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-dev+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-dev@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-dev/5289f959-ccdd-4367-8e82-4ab3653172c6%40googlegroups.com.

Warren Strange

unread,
Mar 2, 2017, 8:33:13 PM3/2/17
to Ahmet Alp Balkan, Kubernetes developer/contributor discussion


Yep, will do!


On Thu, Mar 2, 2017 at 4:16 PM Ahmet Alp Balkan <ahm...@google.com> wrote:
Looks like it's not documented on k8s.io. Warren, do you mind opening an issue at https://github.com/kubernetes/kubernetes.github.io/issues/new or even better contributing a patch?

On Thu, Mar 2, 2017 at 1:08 PM, Warren Strange <warren....@gmail.com> wrote:

Is there an explanation of what the annotation: ingress.kubernetes.io/rewrite-target does?



On Wednesday, March 1, 2017 at 6:58:48 AM UTC-7, Guangya Liu wrote:
Are you struggling with this issue https://github.com/kubernetes/ingress/issues/349 ? If so, you may want to add `ingress.kubernetes.io/rewrite-target: /` as annotation to make the path rule works.

在 2017年3月1日星期三 UTC+8上午5:39:26,Don Bogardus写道:
Need some high level guidance and can't see the forest for the documentation trees. 

Have a bunch of microservices (doesn't everyone now), which are accessed from standard ports (fooservice always on port 1234, barservice always on port 4567) 

Have a dev k8s cluster which I want to segregate into dev and staging environments. 

So I'm looking to make both these calls work

dev.services.piedpiper.com:1234 (resolves to a snapshot version of fooservice) 
staging.services.piedpiper.com:1234 (resolves to a release candidate version of fooservice) 

Namespaces look good for getting both versions working on the backend, but struggling getting ingress rules routing to support these goals. 

We have hostname routing working with a Traefik ingress controller, but there are a few problems. We have to map every endpoint (/* doesn't work), and can't get inbound traffic accepted on anything other than port 80. 

Will nginx work better? Any other thoughts? 

Thanks in advance!


--
You received this message because you are subscribed to the Google Groups "Kubernetes developer/contributor discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.

To post to this group, send email to kuberne...@googlegroups.com.

Warren Strange

unread,
Mar 3, 2017, 12:02:49 PM3/3/17
to Ahmet Alp Balkan, Kubernetes developer/contributor discussion

I found this: https://github.com/kubernetes/ingress/blob/0aabfba84832fc7de5dc347ac56eb12a84fb1a0b/controllers/nginx/configuration.md#rewrite

So this is documented for nginx. 

Does this annotation also work for GCE (and AWS ELB?).    

The user guide (https://kubernetes.io/docs/user-guide/ingress/) doesn't cover ingress annotations. Are there annotations that all implementations support, that should be covered here?




On Thu, Mar 2, 2017 at 4:16 PM Ahmet Alp Balkan <ahm...@google.com> wrote:
Looks like it's not documented on k8s.io. Warren, do you mind opening an issue at https://github.com/kubernetes/kubernetes.github.io/issues/new or even better contributing a patch?

On Thu, Mar 2, 2017 at 1:08 PM, Warren Strange <warren....@gmail.com> wrote:

Is there an explanation of what the annotation: ingress.kubernetes.io/rewrite-target does?



On Wednesday, March 1, 2017 at 6:58:48 AM UTC-7, Guangya Liu wrote:
Are you struggling with this issue https://github.com/kubernetes/ingress/issues/349 ? If so, you may want to add `ingress.kubernetes.io/rewrite-target: /` as annotation to make the path rule works.

在 2017年3月1日星期三 UTC+8上午5:39:26,Don Bogardus写道:
Need some high level guidance and can't see the forest for the documentation trees. 

Have a bunch of microservices (doesn't everyone now), which are accessed from standard ports (fooservice always on port 1234, barservice always on port 4567) 

Have a dev k8s cluster which I want to segregate into dev and staging environments. 

So I'm looking to make both these calls work

dev.services.piedpiper.com:1234 (resolves to a snapshot version of fooservice) 
staging.services.piedpiper.com:1234 (resolves to a release candidate version of fooservice) 

Namespaces look good for getting both versions working on the backend, but struggling getting ingress rules routing to support these goals. 

We have hostname routing working with a Traefik ingress controller, but there are a few problems. We have to map every endpoint (/* doesn't work), and can't get inbound traffic accepted on anything other than port 80. 

Will nginx work better? Any other thoughts? 

Thanks in advance!


--
You received this message because you are subscribed to the Google Groups "Kubernetes developer/contributor discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-de...@googlegroups.com.

To post to this group, send email to kuberne...@googlegroups.com.

Don Bogardus

unread,
Mar 3, 2017, 5:46:18 PM3/3/17
to Kubernetes developer/contributor discussion
Ok, I got the wildcard working, the key was using the latest rc of Traefik. Below is the yaml to stand up the ingress controller on port 80. 

So far I can't find a way to use hostname ingress rules, and route to different apps by port (like the original post describes) 

("slaughternetes" is a small spark app we built to simulate load and failure conditions)

So from a remote server these calls route to the app : 

curl slaughternetes/ 
curl slaughternetes/set_override_status_code/404

This assumes you have a dns or /etc/hosts entry which resolves "slaughternetes" to the IP address where the ingress-controller is running 


apiVersion: v1
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: slaughternetes-ingress-controller
  labels:
    k8s-app: traefik-ingress-lb
spec:
  replicas: 3
  selector:
    matchLabels:
      k8s-app: traefik-ingress-lb
  template:
    metadata:
      labels:
        k8s-app: traefik-ingress-lb
        name: traefik-ingress-lb
    spec:
      terminationGracePeriodSeconds: 60
      hostNetwork: true
      containers:
      - image: traefik:v1.2.0-rc2
        name: traefik-ingress-lb
        resources:
          limits:
            cpu: 200m
            memory: 30Mi
          requests:
            cpu: 100m
            memory: 20Mi
        ports:
        - name: http
          containerPort: 80
          hostPort: 80
        args:
        - -d
        - --web
        - --web.address=:8081
        - --kubernetes
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
 name: slaughternetes-ingress
spec:
 rules:
   - host: slaughternetes
     http:
       paths:
         - path: /
           backend:
             serviceName: slaughternetes
             servicePort: http


Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages