Search code examples
dockernginxkuberneteskubernetes-ingressskaffold

(NGINX + Skaffold) - Running Micro-services system on local machine produces always 404, even though compiles properly?


I'm running a Multiservices system on my local machine and when I type the domain in Chrome I always get :

404 Not Found
nginx/1.19.1

Consider the client:

Dockerfile.dev :

FROM node:13.14.0
WORKDIR /app
COPY package.json .
RUN npm i
COPY . .
CMD ["npm","run","start"]

client-deployment.yaml :

apiVersion: apps/v1
kind: Deployment
metadata:
  name: client-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: multi-client
  template:
    metadata:
      labels:
        app: multi-client
    spec:
      containers:
        - name: multi-client
          image: MYDOCKERID/multi-client
                
---
apiVersion: v1
kind: Service
metadata:
  name: client-cluster-ip-service
spec:
  selector:
    app: multi-client
  ports:
    - name: multi-client
      protocol: TCP
      port: 3000
      targetPort: 3000

Skaffold.yaml :

apiVersion: skaffold/v2alpha3
kind: Config
deploy:
  kubectl:
    manifests:
      - ./k8s/*
build:
  local:
    push: false
  artifacts:
    - image: MYDOCKERID/multi-client
      context: client
      docker:
        dockerfile: Dockerfile.dev
      sync:
        manual:
          - src: 'src/**/*.js'
            dest: .


// ... more services , they work OK  

I've added in my hosts file the following entry:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host
# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

127.0.0.1 fibonacci.dot

When I type fibonacci.dot in my Chrome I get : image1

And here is the Console output:

C:\Development-T410\Docker\Fibonacci>skaffold dev
[34mListing files to watch...[0m

[34mStarting deploy...[0m
 - deployment.apps/client-depl configured
 - service/client-cluster-ip-service configured
 - persistentvolumeclaim/database-persistent-volume-claim configured
 - ingress.extensions/ingress-fibonacci-service configured
 - service/postgres-cluster-ip-service configured
 - deployment.apps/postgres-deployment configured
 - service/redis-cluster-ip-service configured
 - deployment.apps/redis-deployment configured
 - deployment.apps/server-deployment configured
 - service/server-cluster-ip-service configured
 - deployment.apps/worker-deployment configured
[34mWaiting for deployments to stabilize...[0m
 - deployment/client-depl:
 - deployment/postgres-deployment:
 - deployment/redis-deployment:
 - deployment/server-deployment:
 - deployment/worker-deployment:
 - deployment/server-deployment: waiting for rollout to finish: 1 out of 3 new replicas have been updated...
 - deployment/worker-deployment: waiting for rollout to finish: 0 out of 1 new replicas have been updated...
 - deployment/client-depl: waiting for rollout to finish: 1 old replicas are pending termination...
 - deployment/redis-deployment: waiting for rollout to finish: 1 old replicas are pending termination...
 - deployment/postgres-deployment: waiting for rollout to finish: 1 old replicas are pending termination...
 - deployment/worker-deployment: waiting for rollout to finish: 1 old replicas are pending termination...
 - deployment/client-depl is ready. [4/5 deployment(s) still pending]
 - deployment/server-deployment: waiting for rollout to finish: 2 out of 3 new replicas have been updated...
 - deployment/postgres-deployment is ready. [3/5 deployment(s) still pending]
 - deployment/worker-deployment is ready. [2/5 deployment(s) still pending]
 - deployment/redis-deployment is ready. [1/5 deployment(s) still pending]
 - deployment/server-deployment: waiting for rollout to finish: 2 old replicas are pending termination...
 - deployment/server-deployment: waiting for rollout to finish: 1 old replicas are pending termination...
 - deployment/server-deployment is ready.
[34mDeployments stabilized in 34.4563547s[0m
[33mWatching for changes...[0m

[client-depl-f646b85cd-bgmm5 multi-client] ℹ 「wds」: Project is running at http://10.1.1.203/
[client-depl-f646b85cd-bgmm5 multi-client] ℹ 「wds」: webpack output is served from
[client-depl-f646b85cd-bgmm5 multi-client] ℹ 「wds」: Content not from webpack is served from /app/public
[client-depl-f646b85cd-bgmm5 multi-client] ℹ 「wds」: 404s will fallback to /
[client-depl-f646b85cd-bgmm5 multi-client] Starting the development server...
[client-depl-f646b85cd-bgmm5 multi-client]

How can we fix this? Why am I getting 404?


Solution

  • Based on the logs

    - ingress.extensions/ingress-fibonacci-service configured

    It sounds like your application is served by an ingress so it's likely that it's going through a path that is not /. You can see what you have in the ingress.

    You can check the configs of the ingress and logs of the ingress controller (depending on what you are using)

    $ kubectl get ingress ingress-fibonacci-service -o=yaml
    $ kubectl logs <ingress-controller-pod>
    

    If you are using an Nginx ingress controller. Check the configs

    $ kubectl exec -t <ingress-pod> cat nginx.conf