bentoml / BentoML

The easiest way to serve AI apps and models - Build Model Inference APIs, Job queues, LLM apps, Multi-model pipelines, and more!
https://bentoml.com
Apache License 2.0
7.17k stars 792 forks source link

Can't reach swagger static files when deploy with ingress #1328

Closed yubozhao closed 2 years ago

yubozhao commented 3 years ago

Describe the bug

This issue is created from discussion #1325.

Swagger static files are not able to reach (404) when the bento service is deployed as service with ingress (ingress controller is Nginx) in a Kubernetes cluster.

When porter forwarding from the deployment kubectl por-forward bentopod 5000:5000, everything works fine.

To Reproduce

Expected behavior

Screenshots/Logs

Environment:

Additional context

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

mat-berna commented 2 years ago

Hi. Are there any evolutions on this issue?

I have the same problem when the bento service is deployed as service with ingress (ingress controller is Nginx) in a Kubernetes cluster.

My manifests:

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bento-deploy-123
spec:
  replicas: 1
  selector:
    matchLabels:
      run: bento-123
  template:
    metadata:
      labels:
        run: bento-123
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "5000"
    spec:
      serviceAccountName: sa
      containers:
        - name: bento-{service-request-name}
          image: cr/bento-{service-request-name}:{image-id}
          ports:
            - containerPort: 5000
              protocol: TCP
      imagePullSecrets:
        - name: cr-auth

service.yaml

apiVersion: v1
kind: Service
metadata:
  labels:
    run: bento-123
  name: bento-service-123
spec:
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 5000
  selector:
    run: bento-123

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: bento-ingress-123
  annotations:
    cert-manager.io/cluster-issuer: q3p-issuer
    kubernetes.io/ingress.class: nginx
    kubernetes.io/ingress.provider: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    ingress.kubernetes.io/ssl-redirect: "true"
spec:
  rules:
    - host: bento-host
      http:
        paths:
          - path: /123(/|$)(.*)
            pathType: Prefix
            backend:
              service:
                name: bento-service-123
                port:
                  number: 5000
  tls:
    - hosts:
        - bento-host
      secretName: bento-tls

Thanks.

parano commented 2 years ago

In BentoML version 1.0, kubernetes deployments are managed via Yatai which handles all the deployment endpoints creation and ingress resources out-of-the-box. Updating to 1.0 will resolve this issue.