我有一个带有金属LB和ngnix的裸金属kubernetes集群,我可以在端口80上访问nginx并查看欢迎页面。我应用了一个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
服务:
apiVersion: v1
kind: Service
metadata:
name: microservices-service
spec:
selector:
app: microservices-deployment
ports:
- port: 8085
targetPort: 8085
nodePort: 30000
type: NodePort
部署:
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
更新:我能够追踪日志,我看到了这些可疑的日志:
- - [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: "****"
错误消息:No such file or directory
来自Nginx,指向导致错误请求的错误配置。
修复它的最简单方法是简单地创建一个目录/文件来匹配Nginx配置或调整配置本身。
请记住,还要检查目录/文件的权限,并在需要时使用chown
命令进行更新。