我在本地计算机上运行Multiservices系统,当我在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"]
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
我在主机文件中添加了以下条目:# 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
当我在Chrome中输入fibonacci.dot
时,我得到:这是控制台输出:
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? 最佳答案
根据日志
听起来您的应用程序是由入口服务的,因此很可能它所经过的路径不是/
。您可以看到入口中的内容。
您可以检查入口的配置和入口 Controller 的日志(取决于您使用的内容)
$ kubectl get ingress ingress-fibonacci-service -o=yaml
$ kubectl logs <ingress-controller-pod>
如果您使用的是Nginx入口 Controller 。检查配置$ kubectl exec -t <ingress-pod> cat nginx.conf