使用Endpoints 可以方便的使用 service ( traefik、nodeport、loadbalancer 等 ) 连接外部资源
下面是一个 traefik 连接 postgre sql 的例子
endpoint.yaml
apiVersion: v1
kind: Endpoints
metadata:
name: postgre-endpoint
namespace: postgre
subsets:
- addresses:
- ip: 10.10.20.135
ports:
- port: 5432
创建 service
apiVersion: v1
kind: Service
metadata:
name: postgre-endpoint
namespace: postgre
spec:
ports:
- port: 5432
protocol: TCP
targetPort: 5432
IngressRoute
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRouteTCP
metadata:
name: postgre-endpoint
namespace: postgre
spec:
entryPoints:
- postgre
routes:
- match: HostSNI(`*`)
services:
- name: postgre-endpoint
port: 5432