现在,我可以使用以下命令测试我的本地应用程序:http://localhost/rgpd/api/...
这是我的 rgpd-ingress.yaml
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: rgpd-ingress
namespace: rgpd
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- http:
paths:
- path: /rgpd/api
backend:
serviceName: rgpd-api-local
servicePort: "rgpd-port"
我想将其更改为:rgpd.local
所以我把它改成:
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: rgpd-ingress
namespace: rgpd
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: rgpd.local
http:
paths:
- backend:
serviceName: rgpd-api-local
servicePort: "port-rgpd"
但是现在,如果我输入旧网址,我会404
,我也无法连接新网址。
这是我的文件:
部署:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
reloader.stakater.com/auto: "true"
labels:
app: rgpd-api-local
name: rgpd-api-local
namespace: rgpd
spec:
replicas: 1
template:
metadata:
labels:
app: rgpd-api-local
spec:
containers:
- image: rgpd_api:local
envFrom:
- secretRef:
name: rgpd-env
name: rgpd-api-local
ports:
- containerPort: 10000
和服务:
apiVersion: v1
kind: Service
metadata:
labels:
app: rgpd-api-local
name: rgpd-api-local
namespace: rgpd
spec:
type: NodePort
ports:
- name: "rgpd-port"
port: 10000
selector:
app: rgpd-api-local
为什么不能工作?
在主机文件中添加一个条目:/etc/hostsrgpd.local 127.0.0.1
更新/etc/hosts
或仅提供主机标头,即curl -H "Host: rgpd.local" 127.0.0.1