我试图设置一个Kubernetes Ingress将外部http流量路由到前端pod (使用path /)和后端pod (使用path /rest/*),但我总是得到一个400错误,而不是主要的nginx index.html。
所以我在https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer页面上尝试了Google Kubernetes的例子,但是我总是得到一个400错误。有什么想法吗?
以下是前端"cup-fe“(使用angular app运行nginx )的部署描述符:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cup-fe
namespace: default
labels:
app: cup-fe
spec:
replicas: 2
selector:
matchLabels:
app: "cup-fe"
template:
metadata:
labels:
app: "cup-fe"
spec:
containers:
- image: "eu.gcr.io/gpi-cup-242708/cup-fe:latest"
name: "cup-fe"接下来是服务NodePort:
apiVersion: v1
kind: Service
metadata:
name: cup-fe
namespace: default
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
run: cup-fe
type: NodePort最后但并非最不重要的一点是,Ingress将前端暴露在外部:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: http-ingress
spec:
rules:
- host: cup-fe
http:
paths:
- path: /
backend:
serviceName: cup-fe
servicePort: 80
- path: /rest/*
backend:
serviceName: cup-be
servicePort: 8080我去掉了"cup-be“部署描述符(运行野蝇),因为它与"cup-fe”部署描述符非常相似。还请注意,如果我创建一个LoadBalancer服务而不是NodePort,我可以访问网页,但我在调用后端时会遇到一些CORS问题。
https://stackoverflow.com/questions/56977038
复制相似问题