Monday, May 20, 2024

Stuck with simple ingress tutorial


full image - Repost: Stuck with simple ingress tutorial (from Reddit.com, Stuck with simple ingress tutorial)
Hi all,I am in the process of building a simple Hello World API using FastAPI and React on GKE using ingress. Eventually I would like to do this with an internal load balancer for the API and an external load balancer for React, but to keep things more straightforward I tried keeping them both external. I get stuck on a 404 error however, specifically: response 404 (backend NotFound), service rules for the path non-existentMy deployment.yaml for the FastAPI is as follows:apiVersion: apps/v1kind: Deploymentmetadata: name: fastapi-deploymentspec: replicas: 1 selector: matchLabels: app: fastapi template: metadata: labels: app: fastapi spec: nodeSelector: cloud.google.com/gke-nodepool: backend containers: - name: fastapi image: gcr.io/my-project/fastapi-app:latest ports: - containerPort: 8000My deployment.yaml for the React app is as follows: apiVersion: apps/v1kind: Deploymentmetadata: name: react-deploymentspec: replicas: 1 selector: matchLabels: app: react template: metadata: labels: app: react spec: nodeSelector: cloud.google.com/gke-nodepool: frontend containers: - name: react image: gcr.io/my-project/react-app:latest ports: - containerPort: 80The service files for both of them are:apiVersion: v1kind: Servicemetadata: name: fastapi-servicespec: type: LoadBalancer selector: app: fastapi ports: - protocol: TCP port: 80 targetPort: 8000apiVersion: v1kind: Servicemetadata: name: react-servicespec: type: LoadBalancer selector: app: react ports: - protocol: TCP port: 80 targetPort: 3000Both the API and the react app are running fine when going to the loadbalancer ip addresses. However, I suspect there to be something wrong with my ingress.yaml file: apiVersion: networking.k8s.io/v1kind: Ingressmetadata: name: fastapi-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: /spec: rules: - host: test.mydomain.com http: paths: - path: /api pathType: Prefix backend: service: name: fastapi-service port: number: 80For full completeness, this domain would then be used in the react application using fetch('https://ift.tt/NDOiA1z) which would respond:{"Hello": "World"}while https://ift.tt/dRiGXcU should provide access to the api. The website itself now displays the 404 error.Any help would be greatly appreciated!Thank you.


Mining:
Bitcoin, Cryptotab browser - Pi Network cloud PHONE MINING
Fone, cloud PHONE MINING cod. dhvd1dkx - Mintme, PC PHONE MINING


Exchanges:
Coinbase.com - Stex.com - Probit.com


Donations:
Done crypto



Comments System

Disqus Shortname

Disqus Shortname

designcart
Powered by Blogger.