[英]Nginx Ingress: doesn't run services and get 503 service unavailable
I am trying to create an ingress file to route urls into the inside services.我正在尝试创建一个入口文件以将 URL 路由到内部服务。 but after calling in postman, it just returns 503 error.但是调用postman后,只返回503错误。 this is my ingress file config:这是我的入口文件配置:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-srv
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
spec:
rules:
- host: posts.com
http:
paths:
- path: /posts/create
pathType: Prefix
backend:
service:
name: posts-clusterip-srv
port:
number: 7000
this is my posts deployment file and cluster ip:这是我的帖子部署文件和集群 ip:
apiVersion: apps/v1
kind: Deployment
metadata:
name: posts-depl
spec:
replicas: 1
selector:
matchLabels:
app: posts
template:
metadata:
labels:
app: posts
spec:
containers:
- name: posts
image: 4765/posts
---
apiVersion: v1
kind: Service
metadata:
name: posts-clusterip-srv
spec:
selector:
app: posts
ports:
- name: posts
protocol: TCP
port: 7000
targetPort: 7000
when in postman I send this request http://posts.com/posts/create
just returns 503 service unavailable
.在 postman 时,我发送此请求http://posts.com/posts/create
仅返回503 service unavailable
。 I try to curl the cluster Ip curl http://posts-clusterip-srv:7000
but it responses Could not resolve host: posts-clusterip-srv
我尝试 curl 集群 Ip curl http://posts-clusterip-srv:7000
但它响应Could not resolve host: posts-clusterip-srv
I don't know what to do?我不知道该怎么办?
Does your app server accept request on /?您的应用服务器是否接受 / 上的请求?
As path: /posts/create
will forward the request to your server which will receive a request on /.作为路径: /posts/create
会将请求转发到您的服务器,该服务器将在 / 上接收请求。
Concerning the curl http://posts-clusterip-srv:7000
it depends of the set up of your cluster:关于curl http://posts-clusterip-srv:7000
这取决于集群的设置:
/etc/hosts
add your local IP as posts.com
then you should be able to curl it.如果你在你的计算机上使用本地集群,你应该修改你的/etc/hosts
添加你的本地 IP 作为posts.com
然后你应该能够 curl 它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.