Skip to content

HttpRoute creates upstream with server unix:/var/run/nginx/nginx-503-server.sock and throws 503 error #3139

Open
@Fak3

Description

@Fak3

HttpRoute creates upstream with server unix:/var/run/nginx/nginx-503-server.sock and throws 503 error

To Reproduce

1.install nginx-gateway:

kubectl apply -f https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/v1.5.1/deploy/crds.yaml
kubectl apply -f https://raw.githubusercontent.com/nginx/nginx-gateway-fabric/v1.5.1/deploy/nodeport/deploy.yaml
  1. Create NodePort Service
apiVersion: v1
kind: Service
metadata:
  name: ufo-service
  namespace: ufo-ns
spec:
  type: NodePort
  selector:
    app: ufo-app
  ports:
    - protocol: TCP
      name: http
      port: 80
      targetPort: 8000  # inside container

      nodePort: 30007
  1. And HttpRoute
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  namespace: ufo-ns
  name: ufo-httproute
spec:
  parentRefs:
  - name: ufo-gateway
  rules:
  - matches:
    - path:
        type: PathPrefix
        value: /lol
    backendRefs:
    - name: ufo-service
      port: 80
  1. check that service itself can be successfuly accessed on that node port: curl http://vybory.live:30007 returns http 200.

  2. Attempt to access the service via nginx-gateway, notice it throws http 503:

$ curl http://vybory.live/lol

<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>

  1. log into nginx caontainer with
kubectl exec -it --namespace nginx-gateway deployments/nginx-gateway -c nginx -- /bin/sh
  1. retrieve generated configuration with nginx -T and notice that upstream definition for my ufo-service points to server unix:/var/run/nginx/nginx-503-server.sock; instead of actual service ip:
upstream ufo-ns_ufo-service_80 {
    random two least_conn;
    zone ufo-ns_ufo-service_80 512k;

    server unix:/var/run/nginx/nginx-503-server.sock;
}

upstream ufo-ns_grafana_3000 {
    random two least_conn;
    zone ufo-ns_grafana_3000 512k;

    server 10.20.15.122:3000;
}
  1. Also notice that at the same time, grafana upstream correctly references its service ip, and can be accesed via http://grafana.vybory.live

See full nginx config: https://gist.github.com/Fak3/73abc3e2b0bdbe6c38f13c62dbc09531

Expected behavior
Expected: the upstream definition int the config should reference service by ip, instead of pointing to unix:/var/run/nginx/nginx-503-server.sock

Your environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions