Kubernetes NGINX 入口控制器 404 未找到/未找到对象
Kubernetes NGINX Ingress Controller 404 Not found / Object not found
我正在 Udemy 上一门课程,我是 Kubernetes 世界的新手,我正在尝试配置 ingress nginx 控制器在 Kubernetes 中,但它 returns 404 not found 当我在指定 URL 发送请求时,我已经尝试修复它 10 天了,我'我看过类似的问题,但 none 他们的回答对我有用。当我更改文件中的某些内容时,我还使用 Skaffold 在 docker 集线器上自动执行 build/deploy 图像。
我的快递应用程序服务器:
app.get('/api/users/currentuser', (req, res) => {
res.send('Hi there');
});
app.listen(3000, () => {
console.log('[Auth] - Listening on port 3000');
});
入口-srv.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-srv
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
rules:
- host: ticketing.com
http:
paths:
- path: /api/users/?(.*)
pathType: Prefix
backend:
service:
name: auth-srv
port:
number: 3000
auth-depl.yaml(授权部署&srv)
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth-depl
spec:
replicas: 1
selector:
matchLabels:
app: auth
template:
metadata:
labels:
app: auth
spec:
containers:
- name: auth
image: myusername/auth:latest
---
apiVersion: v1
kind: Service
metadata:
name: auth-srv
spec:
type: ClusterIP
selector:
app: auth
ports:
- name: auth
protocol: TCP
port: 3000
targetPort: 3000
skaffold.yaml 文件:
apiVersion: skaffold/v2beta25
kind: Config
deploy:
kubectl:
manifests:
- ./infra/k8s/*
build:
local:
push: false
artifacts:
- image: username/auth
context: auth
docker:
dockerfile: Dockerfile
sync:
manual:
- src: 'src/**/*.ts'
dest: .
Dockerfile:
FROM node:alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "start"]
我还执行了来自NGINX Ingress Controller docs的命令:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.5/deploy/static/provider/cloud/deploy.yaml
我在系统里也改了hosts.file:
127.0.0.1ticketing.com
日志:
kubectl get pods
NAME READY STATUS RESTARTS AGE
auth-depl-5f89899d9f-wtc94 1/1 Running 0 6h33m
kubectl 获取 svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
auth-srv ClusterIP 10.96.23.71 <none> 3000/TCP 23h
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 25h
kubectl get pods --namespace=ingress-nginx
NAME READY STATUS RESTARTS AGE
ingress-nginx-admission-create-7fm56 0/1 Completed 0 23h
ingress-nginx-admission-patch-5vflr 0/1 Completed 1 23h
ingress-nginx-controller-5c8d66c76d-89zhp 1/1 Running 0 23h
kubectl geting
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress-srv <none> ticketing.com localhost 80 23h
kubectl describe ingress-srv
Name: ingress-srv
Namespace: default
Address: localhost
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
ticketing.com
/api/users/?(.*) auth-srv:3000 (10.1.0.10:3000)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: true
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 22m (x18 over 23h) nginx-ingress-controller Scheduled for sync
Windows IIS Web 服务器可能有问题吗?因为我之前为另一个项目配置了一些东西,在上面的屏幕截图中我看到:
Requested URL http://ticketing.com:80/api/users/currentuser
Physical Path C:\inetpub\wwwroot\api\users\currentuser
此外,屏幕截图显示请求 URL 的端口 :80 但我有服务器端口 3000? + 当我在 https 请求时 returns:
502 Bad Gateway
nginx
C:\inetpub\wwwroot我也很陌生
任何想法都会对我继续课程有很大帮助。
经过几天的研究,我终于解决了这个问题,问题出在我在 ASP.NET 核心中处理项目时启用的 IIS Web 服务器,我卸载了它,问题是解决了。
如何从 Windows10 中卸载 IIS:
- 转到“控制面板”>“程序和功能”
- 点击打开或关闭 Windows 功能
- 向下滚动到 Internet 信息服务
- 单击 Internet Information Services 旁边的方块,使其变为空白
- 单击“确定”并重新启动 PC(必需)。
我正在 Udemy 上一门课程,我是 Kubernetes 世界的新手,我正在尝试配置 ingress nginx 控制器在 Kubernetes 中,但它 returns 404 not found 当我在指定 URL 发送请求时,我已经尝试修复它 10 天了,我'我看过类似的问题,但 none 他们的回答对我有用。当我更改文件中的某些内容时,我还使用 Skaffold 在 docker 集线器上自动执行 build/deploy 图像。
我的快递应用程序服务器:
app.get('/api/users/currentuser', (req, res) => {
res.send('Hi there');
});
app.listen(3000, () => {
console.log('[Auth] - Listening on port 3000');
});
入口-srv.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-srv
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
rules:
- host: ticketing.com
http:
paths:
- path: /api/users/?(.*)
pathType: Prefix
backend:
service:
name: auth-srv
port:
number: 3000
auth-depl.yaml(授权部署&srv)
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth-depl
spec:
replicas: 1
selector:
matchLabels:
app: auth
template:
metadata:
labels:
app: auth
spec:
containers:
- name: auth
image: myusername/auth:latest
---
apiVersion: v1
kind: Service
metadata:
name: auth-srv
spec:
type: ClusterIP
selector:
app: auth
ports:
- name: auth
protocol: TCP
port: 3000
targetPort: 3000
skaffold.yaml 文件:
apiVersion: skaffold/v2beta25
kind: Config
deploy:
kubectl:
manifests:
- ./infra/k8s/*
build:
local:
push: false
artifacts:
- image: username/auth
context: auth
docker:
dockerfile: Dockerfile
sync:
manual:
- src: 'src/**/*.ts'
dest: .
Dockerfile:
FROM node:alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "start"]
我还执行了来自NGINX Ingress Controller docs的命令:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.5/deploy/static/provider/cloud/deploy.yaml
我在系统里也改了hosts.file: 127.0.0.1ticketing.com
日志:
kubectl get pods
NAME READY STATUS RESTARTS AGE
auth-depl-5f89899d9f-wtc94 1/1 Running 0 6h33m
kubectl 获取 svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
auth-srv ClusterIP 10.96.23.71 <none> 3000/TCP 23h
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 25h
kubectl get pods --namespace=ingress-nginx
NAME READY STATUS RESTARTS AGE
ingress-nginx-admission-create-7fm56 0/1 Completed 0 23h
ingress-nginx-admission-patch-5vflr 0/1 Completed 1 23h
ingress-nginx-controller-5c8d66c76d-89zhp 1/1 Running 0 23h
kubectl geting
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress-srv <none> ticketing.com localhost 80 23h
kubectl describe ingress-srv
Name: ingress-srv
Namespace: default
Address: localhost
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
ticketing.com
/api/users/?(.*) auth-srv:3000 (10.1.0.10:3000)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: true
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Sync 22m (x18 over 23h) nginx-ingress-controller Scheduled for sync
Windows IIS Web 服务器可能有问题吗?因为我之前为另一个项目配置了一些东西,在上面的屏幕截图中我看到:
Requested URL http://ticketing.com:80/api/users/currentuser
Physical Path C:\inetpub\wwwroot\api\users\currentuser
此外,屏幕截图显示请求 URL 的端口 :80 但我有服务器端口 3000? + 当我在 https 请求时 returns:
502 Bad Gateway
nginx
C:\inetpub\wwwroot我也很陌生
任何想法都会对我继续课程有很大帮助。
经过几天的研究,我终于解决了这个问题,问题出在我在 ASP.NET 核心中处理项目时启用的 IIS Web 服务器,我卸载了它,问题是解决了。
如何从 Windows10 中卸载 IIS:
- 转到“控制面板”>“程序和功能”
- 点击打开或关闭 Windows 功能
- 向下滚动到 Internet 信息服务
- 单击 Internet Information Services 旁边的方块,使其变为空白
- 单击“确定”并重新启动 PC(必需)。