1

I have a bare-metal kubernetes cluster with metal LB and ngnix and I'm able to access nginx on port 80 and see the welcome page. I applied an Ingress resource but yet I can't access my service although I'm able to access my service via the workers (on the nodeport specified). Is there anything I'm missing here?

Ingress:

apiVersion: networking.k8s.io/v1beta1 # for versions before 1.14 use extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
    - http:
        paths:
          - path: /rest/endpoints/hello
            backend:
              serviceName: microservices-service
              servicePort: 8085
          - path: /rest/endpoints/calculateIterationTotalCapcity
            backend:
              serviceName: microservices-service
              servicePort: 8085

Service:

apiVersion: v1
kind: Service
metadata:
  name: microservices-service
spec:
  selector:
    app: microservices-deployment
  ports:
    - port: 8085
      targetPort: 8085
      nodePort: 30000
  type: NodePort

Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: microservices-deployment
  labels:
    app: microservices-deployment
spec:
  replicas: 3
  template:
    metadata:
      name: microservices-deployment
      labels:
        app: microservices-deployment
    spec:
      containers:
        - name: microservices-deployment
          image: ** my image **
          imagePullPolicy: Always
          ports:
            - containerPort: 8085
      restartPolicy: Always
  selector:
    matchLabels:
      app: microservices-deployment

UPDATE: I was able to trace the logs and I see these suspicious logs:

 - - [30/Aug/2020:13:43:12 +0000] "GET /rest/endpoints/hello HTTP/1.1" 404 555 "-"**** "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36" "-"
2020/08/30 13:43:12 [error] 28#28: *7 open() "/usr/share/nginx/html/rest/endpoints/hello" failed (2: No such file or directory), client:**** , server: localhost, request: "GET /rest/endpoints/hello HTTP/1.1", host: "****"

1 Answers1

0

The error message: No such file or directory comes from Nginx and points to a misconfiguration which results in a wrong request.

The easiest way to fix it would be to simply create a directory/file to match the Nginx configuration or adjust the configuration itself.

Remember to also check the permissions of the dir/file and update them if needed with chown command.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
  • Hi, I didn't fully understand. I have a spring jar file the contains all my code, how do I adjust nginx for that? I don't have a directory called "nginx" under the /usr/share at all. – Yaakov Shami Sep 09 '20 at 06:41
  • Nginx tries to access `/usr/share/nginx/html/rest/endpoints/hello` which doesn't exist. You need to check your `nginx.conf` file and see if there are any misconfigured or missing `location`s. – Wytrzymały Wiktor Sep 09 '20 at 06:59
  • I can't find the nginx.conf file (under /etc I don't have ngnix folder, I installed it with manifests) – Yaakov Shami Sep 10 '20 at 12:04
  • By default, the configuration file `nginx.conf` is placed in the directory `/usr/local/nginx/conf`, `/etc/nginx` or `/usr/local/etc/nginx`. – Wytrzymały Wiktor Sep 10 '20 at 12:29
  • I didn't find it in any of those dirs – Yaakov Shami Sep 13 '20 at 10:14