集成K8S nginx入口时遇到问题。我安装了nginx入口控制器,并根据文档中的说明建立了测试入口资源,但是我无法跳转到常规路径。测试服务正常,可以通过群集IP访问。我想念什么吗?
安装脚本
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
使用NodePort的裸机
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/baremetal/service-nodeport.yaml
测试入口资源
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx
spec:
selector:
matchLabels:
app: my-nginx
template:
metadata:
labels:
app: my-nginx
spec:
containers:
- name: my-nginx
image: nginx:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: my-nginx
labels:
app: my-nginx
spec:
ports:
- port: 80
protocol: TCP
name: http
selector:
app: my-nginx
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-nginx
annotations:
kubernetes.io/ingress.class: "nginx"
spec:
rules:
- host: nginx1.beencoding.com
http:
paths:
- path: /
backend:
serviceName: nginx-1
servicePort: 80
答案 0 :(得分:1)
我已通过设置hostnetwork: true
答案 1 :(得分:0)
说无法解决。
将域放入/etc/hosts/
文件中,或按以下步骤进行卷曲:
curl -H "Host: nginx1.beecoding.com" IP_ADDRESS
应该工作。