1

我在本地机器上运行多服务系统,当我在 Chrome 中输入域时,我总是得到:

404 Not Found
nginx/1.19.1

考虑客户:

Dockerfile.dev :

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

客户端部署.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  

我在我的主机文件中添加了以下条目:

# 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

当我输入fibonacci.dot我的 Chrome 时,我得到: 图像1

这是控制台输出:

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]

我们如何解决这个问题?为什么我得到 404?

4

1 回答 1

2

根据日志

- ingress.extensions/ingress-fibonacci-service configured

听起来您的应用程序由入口提供服务,因此它很可能通过的路径不是/. 您可以在入口中看到您拥有的内容。

您可以检查入口控制器的入口和日志的配置(取决于您使用的是什么)

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

如果您使用的是 Nginx 入口控制器。检查配置

$ kubectl exec -t <ingress-pod> cat nginx.conf
于 2020-07-16T00:35:14.477 回答