Search code examples
kubernetesgoogle-cloud-platformgoogle-kubernetes-enginekubernetes-ingressflask-restplus

Not able to open swagger documentation in gcp ingress


I have created a simple flask api with swagger integration using flask_restplus library. It is working fine in localhost. But when I use it in gcp kubernetes ingress, it is giving results for endpoints but not able to show the documentation or swagger ui. Here are the browser console errors browser console errors

Here is ingress.yml file

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-restplustest
  annotations:
    
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    kubernetes.io/ingress.global-static-ip-name: "web-static-ip"
spec:
  rules:
  - http:
      paths:
      - path: /rt
        backend:
          serviceName: restplustest
          servicePort: 5000
In local system localhost:5000/rt shows the swagger-ui


Solution

  • Your endpoint return a script that references other scripts located on /swaggerui/* but that path is not defined in your Ingress.

    It may be solved if you add that path to your service as well

      - path: /swaggerui/*
        backend:
          serviceName: restplustest
          servicePort: 5000