我已经在裸机上安装了Kubernetes,并弄清楚了如何使用Ingress并将主机路由到我的服务。
但是当我对不同的主机使用相同的配置时,会得到default backend - 404
。
工作配置:
apiVersion: v1
kind: Namespace
metadata:
name: k8s-mariyo-host-1-sk-node-hello-world
---
apiVersion: v1
kind: Service
metadata:
namespace: k8s-mariyo-host-1-sk-node-hello-world
name: node-hello-world
labels:
app: node-hello-world
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: node-hello-world
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
namespace: k8s-mariyo-host-1-sk-node-hello-world
name: node-hello-world
spec:
selector:
matchLabels:
app: node-hello-world
strategy:
type: Recreate
template:
metadata:
namespace: k8s-mariyo-host-1-sk-node-hello-world
labels:
app: node-hello-world
spec:
containers:
- image: 10.100.100.1:5000/local-node-hello-world:1.5
name: hello-world
ports:
- containerPort: 8080
name: hello-world
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
namespace: k8s-mariyo-host-1-sk-node-hello-world
name: node-hello-world
spec:
rules:
- host: "node-hello-world.host-1.sk"
http:
paths:
- path: /
backend:
serviceName: node-hello-world
servicePort: 80
默认后端-404配置:
apiVersion: v1
kind: Namespace
metadata:
name: k8s-mariyo-host-2-sk-k8s
---
apiVersion: v1
kind: Service
metadata:
namespace: k8s-mariyo-host-2-sk-k8s
name: k8s
labels:
app: k8s
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: k8s
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
namespace: k8s-mariyo-host-2-sk-k8s
name: k8s
spec:
selector:
matchLabels:
app: k8s
strategy:
type: Recreate
template:
metadata:
namespace: k8s-mariyo-host-2-sk-k8s
labels:
app: k8s
spec:
containers:
- image: 10.100.100.1:5000/local-node-hello-world:1.5
name: k8s-hello
ports:
- containerPort: 8080
name: k8s-hello
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
namespace: k8s-mariyo-host-2-sk-k8s
name: k8s
spec:
rules:
- host: "k8s.host-2.sk"
http:
paths:
- path: /
backend:
serviceName: k8s
servicePort: 80
有人能看到几乎相似的配置的奇怪/不同行为吗?这是差异链接:https://www.diffchecker.com/9AlnFQGz
答案 0 :(得分:0)
正如@Mariyo在评论中提到的那样,问题似乎出在Cloudflare SSL配置上。如果您的网站不持有任何SSL证书,并且您考虑仅对Web用户和Cloudflare使用安全连接,而不对Web服务使用安全连接。然后,您可以选择Flexible SSL模式,而不是完全SSL严格模式。已经为任何进一步的贡献者研究提供了答案。