k8s实用整理(19)-配置访问外部服务DNS解析

ExternalName服务

ExternalName Service是Service的一个特例,它没有选择器,也没有定义任何端口或Endpoints。它的作用是返回集群外Service的外部别名。

kind: Service
apiVersion: v1
metadata:
  name: my-service
  namespace: prod
spec:
  type: ExternalName #服务类型为外部服务
#  externalName: my.database.example.com #外部服务
externalName: 172.26.77.14

当查找my-service.prod.svc.CLUSTER时,集群DNS服务将会返回一条CNAME记录,此记录的值为my.database.example.com。当然后续也可以将此数据库迁移到集群中,这样就可以通过Pod启动,并为其添加合适的选择器或者Endpoints,并修改服务类型。

 

参考:https://www.kubernetes.org.cn/4040.html

 高频应用配置为ExternalName服务

 

kind: Service
apiVersion: v1
metadata:
  name: xgpappsvc
spec:
  type: ExternalName #服务类型为外部服务
#  externalName: my.database.example.com #外部服务
  externalName: {{ .Values.external.xgpappip }}

 

posted @ 2018-06-08 17:25  Cslc-DaweiJ  阅读(3635)  评论(0编辑  收藏  举报