这是我的eks集群详细信息:kubectl get all
NAME READY STATUS RESTARTS AGE
pod/feed-4fqdrrf-fwcc3 1/1 Running 0 64m
pod/gst-7adn3njl-fg43 1/1 Running 0 71m
pod/ingress-nginx-controller-f567efvef-f653dc 1/1 Running 0 9d
pod/app-24dfs2d-m2fdqw 1/1 Running 0 66m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/feed NodePort 10.100.24.643 <none> 8082:30002/TCP 64m
service/gst NodePort 10.100.54.543 <none> 8081:30004/TCP 71m
service/ingress-nginx-controller LoadBalancer 10.100.643.256 ******************.<region>.elb.amazonaws.com 80:30622/TCP,443:30721/TCP 9d
service/ingress-nginx-controller-admission ClusterIP 10.100.654.542 <none> 443/TCP 9d
service/kubernetes ClusterIP 10.100.0.7 <none> 443/TCP 14d
service/app NodePort 10.100.456.34 <none> 3001:30003/TCP 66m
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/feed 1/1 1 1 64m
deployment.apps/gst 1/1 1 1 71m
deployment.apps/ingress-nginx-controller 1/1 1 1 9d
deployment.apps/app 1/1 1 1 66m
NAME DESIRED CURRENT READY AGE
replicaset.apps/feed-4fqdrrf 1 1 1 64m
replicaset.apps/gst-7adn3njl 1 1 1 71m
replicaset.apps/ingress-nginx-controller-f567efvef 1 1 1 9d
replicaset.apps/app-m2fdqw 1 1 1 66m
kubectl logs feed-4fqdrrf-fwcc3
helloworld: listening on port 8082
~ % kubectl logs gst-7adn3njl-fg43
helloworld: listening on port 8081
~ % kubectl logs app-24dfs2d-m2fdqw
helloworld: listening on port 3001
字符串
以下是我的部署和服务yamls:
apiVersion: apps/v1
kind: Deployment
metadata:
name: feed
labels:
app: feed
spec:
selector:
matchLabels:
app: feed
template:
metadata:
labels:
app: feed
spec:
containers:
- name: feed-container
image: **************.dkr.ecr.******.amazonaws.com/feed:latest
ports:
- containerPort: 8082
---
apiVersion: v1
kind: Service
metadata:
name: feed
spec:
ports:
- port: 8082
protocol: TCP
targetPort: 8082
selector:
app: feed
type: NodePort
型
其他两个服务类似,这是我的入口yaml:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/enable-websocket: "true"
nginx.org/websocket-services: app
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /feed
pathType: Prefix
backend:
service:
name: expertfeed
port:
number: 8082
- path: /app
pathType: Prefix
backend:
service:
name: wehealapp
port:
number: 3001
- path: /socket.io/app
pathType: Prefix
backend:
service:
name: app
port:
number: 3001
- path: /gst
pathType: Prefix
backend:
service:
name: gst
port:
number: 8001
型
我在所有3个服务中都有多个get请求,我把它们暴露成这样:
app.get('/getrequest1', jsonParser, async (request, response) => {
//my code
)}
app.get('/getrequest2', jsonParser, async (request, response) => {
//my code
)}
.
.
.
const port = process.env.PORT || 8082;
app.listen(port, () => {
console.log(`helloworld: listening on port ${port}`);
});
型
所有3个节点服务中的模式相似。404 Not Found nginx当我点击:**. elb.amazonaws.com,当我点击:* .elb.amazonaws.com/feed getting this error:Cannot GET / If I use this url *. elb. amazonaws.com/feed/getreqest1 still getting same error
2条答案
按热度按时间mwecs4sa1#
我找到了一种方法,我将我的nginx负载均衡器EXTERNAL-IP添加到我的DNS记录中,并添加一个CNAME记录。下面是YAML:
字符串
myss37ts2#
因为您在Ingress上设置了
rewrite-target
注解,它将流量转发到不存在的应用程序的根/
。