I'm starting with Kubernetes Docker and Flask, I need to publish a Flask app that contains several routes. How can I change the paths into my deploy.yml
in order to access the multiple URLs.
Here is my app.py
:
@app.route('/',methods = ['GET','POST'])
def extract():
{code}
@app.route('/secondeurl', methods = ['GET','POST'])
def seconde():
{code}
And my deploy.yml :
paths:
- path: /
backend:
serviceName: hello
servicePort: 8080
I tried those different methods and none of them worked correctly :
paths:
- path: /.*
backend:
serviceName: hello
servicePort: 8080
paths:
- path: /
backend:
serviceName: hello
servicePort: 8080
- path: /secondeurl
backend:
serviceName: hello
servicePort: 8080
no need to define secondurl route on flask side. "/" route enough to handle request, you should handle on ingress rules side .
apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: kubernetes.io/ingress.class: nginx name: ingress-flask-dev namespace: default spec: rules: - host: first_domain http: paths: - path: / backend: serviceName: flask_app servicePort: 5000
- host: second\_domain
http:
paths:
- path: /
backend:
serviceName: flask\_app
servicePort: 5000