0

I am trying to develop an application on kubernetes with hot-reloading (instant code sync). I am using DevSpace. When running my application on a minikube cluster, everything works and I am able to hit the ingress to reach my FastAPI docs. The problem is when I try to use devspace, I can exec into my pods and see my changes reflected right away, but then when I try to hit my ingress to reach my FastAPI docs, I get a 502 bad gateway.

I have an api-pod.yaml file as such:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: project-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: project-api
  template:
    metadata:
      labels:
        app: project-api
    spec:
      containers:
        - image: project/project-api:0.0.1
          name: project-api
          command: ["uvicorn"]
          args: ["endpoint:app", "--port=8000", "--host", "0.0.0.0"]
          imagePullPolicy: IfNotPresent
          livenessProbe:
            httpGet:
              path: /api/v1/project/tasks/
              port: 8000
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 600
            failureThreshold: 3
          ports:
            - containerPort: 8000
              name: http
              protocol: TCP

---
apiVersion: v1
kind: Service
metadata:
  name: project-api
spec:
  selector:
    app: project-api
  ports:
    - port: 8000
      protocol: TCP
      targetPort: http
  type: ClusterIP

I have an api-ingress.yaml file as such:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: project-ingress
spec:
  rules:
    - http:
        paths:
          - path: /api/v1/project/tasks/
            pathType: Prefix
            backend:
              service:
                name: project-api
                port:
                  number: 8000
  ingressClassName: nginx

---
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  name: nginx
spec:
  controller: k8s.io/ingress-nginx

Using kubectl get ep, I get:

NAME          ENDPOINTS         AGE
project-api   172.17.0.6:8000   17m

Using kubectl get svc, I get:

NAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
project-api   ClusterIP   10.97.182.167   <none>        8000/TCP   17m

Using kubectl get ingress I get:

NAME          CLASS   HOSTS   ADDRESS          PORTS   AGE
api-ingress   nginx   *       192.168.64.112   80      17m

to reiterate, my problem is when I try reaching the FastAPI docs using 192.168.64.112/api/v1/project/tasks/docs I get a 502 bad gateway.

Im running:

MacOS Monterey: 12.4
Minikube version: v1.26.0 (with hyperkit as the vm)
Ingress controller: k8s.gcr.io/ingress-nginx/controller:v1.2.1
Devspace version: 5.18.5
DataPlug
  • 340
  • 3
  • 10

1 Answers1

1

I believe the problem was within DevSpace. I am now comfortably using Tilt. Everything is working as expected.

DataPlug
  • 340
  • 3
  • 10