ibm-cloud-docs / containers

IBM Bluemix Container Service documentation
https://console.bluemix.net/docs/containers/container_index.html
48 stars 123 forks source link

How to do Kubernetes Ingress multiple service paths? #2269

Closed booboothefool closed 6 years ago

booboothefool commented 6 years ago

https://github.com/IBM-Bluemix-Docs/containers/blob/master/cs_annotations.md

I am trying to do something similar to:

myhost.com/app1/foo => app1-service:80/foo
myhost.com/app2/bar => app2-service:80/bar

But this setup gives me 404s:

 apiVersion: extensions/v1beta1
 kind: Ingress
 metadata:
   name: myingress
 spec:
   rules:
   - host: myhost.com
     http:
       paths:
       - path: /app1
         backend:
           serviceName: app1-service
           servicePort: 80
       - path: /app2
         backend:
           serviceName: app2-service
           servicePort: 80

Some tutorials will suggest I need to add an annotation:

annotations:
  nginx.ingress.kubernetes.io/rewrite-target: /
  // or ingress.kubernetes.io/rewrite-target: / (I don't know)

But how do I add this using IBM Cloud Kubernetes Ingress? ingress.bluemix.net/rewrite-path does not appear to do the same thing as ingress.kubernetes.io/rewrite-target.

Also, do I need to manually deploy an Ingress Controller or does IBM Cloud Kubernetes do it for me? The Kubernetes docs https://kubernetes.io/docs/concepts/services-networking/ingress/ mention :

Before you start using the Ingress resource, You need an Ingress controller to satisfy an Ingress, simply creating the resource will have no effect.

But the IBM Kubernetes docs https://console.bluemix.net/docs/containers/cs_ingress.html#ingress have no mention of this or how to create the Ingress Controller.

booboothefool commented 6 years ago

Found the solution.

https://console.bluemix.net/docs/containers/cs_ingress.html#ingress

Step 3: Creating Ingress resource

 apiVersion: extensions/v1beta1
 kind: Ingress
 metadata:
   name: myingressresource
 spec:
   rules:
   - host: <domain>
     http:
       paths:
       - path: /<app1_path>
         backend:
           serviceName: <app1_service>
           servicePort: 80
       - path: /<app2_path>
         backend:
           serviceName: <app2_service>
           servicePort: 80

^ won't work. It needs:

   annotations:
     ingress.bluemix.net/rewrite-path: "serviceName=app1-service rewrite=/"

   path: /<app1_path>/