在Official Guide后,我进入Forwarding to ExtternalNames部分。在哪里说:
当指定ExternalName时,Træfik会相应地将请求转发给给定的主机
指向来自kubernetes services without selectors
的文档这促使我创建了一项服务
kind: Service
apiVersion: v1
metadata:
name: my-service
namespace: prod
spec:
type: ExternalName
externalName: my.database.example.com
当我指出它时,Traefik高兴地忽略了它:
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-service
namespace: kube-system
spec:
rules:
- host: my-service.example.com
http:
paths:
- path: /
backend:
serviceName: my-service
servicePort: 4080
我也尝试过作为终点。
---
kind: Service
apiVersion: v1
metadata:
name: my-service
namespace: kube-system
spec:
ports:
- protocol: TCP
port: 80
targetPort: 4080
---
kind: Endpoints
apiVersion: v1
metadata:
name: my-service
subsets:
- addresses:
- ip: 10.0.0.3
ports:
- port: 4080
有没有人知道如何让traefik指向外部名称,如文档所示?
答案 0 :(得分:0)
如我所见,你错过了Ingress对象中的至少一行 - traefik.frontend.passHostHeader: "false"
。
此外,您需要使用Namespace在同一Service内创建一个Ingress对象。
所以,你的Ingress应该是这样的:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-service
namespace: prod
annotations:
traefik.frontend.passHostHeader: "false"
spec:
rules:
- host: my-service.example.com
http:
paths:
- path: /
backend:
serviceName: my-service
servicePort: 4080
服务:
kind: Service
apiVersion: v1
metadata:
name: my-service
namespace: prod
spec:
type: ExternalName
ports:
- name: app-port
port: 4080
externalName: my.database.example.com