How to fix "503 Service Temporarily Unavailable"

Rexy Sihombing picture Rexy Sihombing · Oct 25, 2019 · Viewed 11.4k times · Source

FYI:

  1. I run Kubernetes on docker desktop for mac
  2. The website based on Nginx image

I run 2 simple website deployments on Kubetesetes and use the NodePort service. Then I want to make routing to the website using ingress. When I open the browser and access the website, I get an error 503 like images below. So, how do I fix this error?

### Service
apiVersion: v1
kind: Service
metadata:
  name: app-svc
  labels:
    app: app1
spec:
  type: NodePort
  ports:
  - port: 80
  selector:
    app: app1
---
apiVersion: v1
kind: Service
metadata:
  name: app2-svc
  labels:
    app: app2
spec:
  type: NodePort
  ports:
  - port: 80
  selector:
    app: app2

### Ingress-Rules
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: app-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /app1
        backend:
          serviceName: app-svc
          servicePort: 30092
      - path: /app2
        backend:
          serviceName: app2-svc
          servicePort: 30936


enter image description here

Answer

Srinivas Charan Mamidi picture Srinivas Charan Mamidi · Apr 28, 2020

Yes, i end up with same error. once i changed the service type to "ClusterIP", it worked fine for me.