I have a problem and I have no more ideas what to do. I want to set up a microservice based app on Linode with kubernetes. I have an Angluar app (running on the same cluster and the same node) already deployed there, and it works fine, from this angular App I want to send a request to a python flask app via the angular http client.
my yaml files for the microservice (flask) look like this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
replicas: 1
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: imageName (unfortunately, I am not allowed to show the real image name, sorry)
ports:
- containerPort: 5000
---
apiVersion: v1
kind: Service
metadata:
name: backend-service
spec:
selector:
app: backend
ports:
- protocol: TCP
port: 5000
targetPort: 5000
In Angular I use the Angular httpClient to send a request to this url:
export const environment = {
production: true,
backendUrl: 'http://backend-service'
};
I also alredy tried to use the ip address given in Linode. The request does not reach the flask app. There everything looks like this and there are no changes (I use flask here in debug mode for monitoring purposes):
Serving Flask app "app.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
my Ingress is:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
spec:
rules:
- host: Linode host url
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: angular-app-service
port:
number: 80
- path: /backend-service
pathType: Prefix
backend:
service:
name: backend-service
port:
number: 5000
I have no clue what my mistake is. When I run the application in containers on my system everything works fine. I'm sure it is a stupid mistake, but I cannot recognize it right now. If this question has been asked already many times, I'm sorry, but I couldn't find a solution until now. Thank you very much.
You will need an ingress setup. This will allow external traffic from your angular app into the cluster to hit the backend.