<p>I have a Python Flask app I've deployed on IBM Kubernetes Service. My deployment YAML specifies <code>path: /</code>, which is handled in my code with <code>@app.route('/')</code>. That works fine. I then attempted to move the app by changing <code>path: /</code> to <code>path: /foo</code> in my deployment YAML. I was expecting the request coming into my app to still come in as <code>/</code>, but it's coming in as <code>/foo</code>. Ultimately what I'm trying to do is to be flexible in the deployment of the app without having the change source code. I don't see a way in either Kubernetes or Flask to create this level of indirection. Am I missing something?</p>

<p>Original YAML:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
spec:
  tls:
  - hosts:
      - my....us-east.containers.appdomain.cloud
    secretName: my...
  rules:
  - host: my....us-east.containers.appdomain.cloud
    http:
      paths:
       - path: /
         backend:
           serviceName: my-service
           servicePort: 5000
</code></pre>

KineticSquid
<p>Need to check the content of your <code>ingress</code> yaml definition. </p>

<p>Here's an example <code>yaml</code> definition with rewrites </p>

<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: rewrite
  namespace: default
spec:
  rules:
  - host: rewrite.bar.com
    http:
      paths:
      - backend:
          serviceName: http-svc
          servicePort: 80
        path: /something(/|$)(.*) 
</code></pre>

<p>For example, the ingress definition above will result in the following rewrites:</p>

<pre><code>rewrite.bar.com/something rewrites to rewrite.bar.com/
rewrite.bar.com/something/ rewrites to rewrite.bar.com/
rewrite.bar.com/something/new rewrites to rewrite.bar.com/new
</code></pre>

<p>You can check Nginx Ingress controller Rewrite annotations <a href="https://kubernetes.github.io/ingress-nginx/examples/rewrite/" rel="nofollow noreferrer">here</a>. You can also customize Ingress routing with annotations on IBM Cloud following the <a href="https://cloud.ibm.com/docs/containers?topic=containers-ingress_annotation" rel="nofollow noreferrer">documentation here</a></p>
