@version 180807:1
@author zhangxuhong <zhangxuhong@xitu.io>
mapping-external-services - 映射外部服务.
有的时候我们要访问 kubernetes 集群外部的服务. 这些服务可能是没来得及迁移到集群里面的, 或者第三方的, 或者是托管的数据库. 因此便有了映射外部服务的场景.
映射外部IP和端口
service
kind: Service
apiVersion: v1
metadata:
name: mongo
labels:
name: mongo
role: proxy
pl: cpp
application: mongo
version: 16.03
division: infrastructure
Spec:
type: ClusterIP
ports:
- port: 27017
targetPort: 27017
kind: Endpoints
apiVersion: v1
metadata:
name: mongo
labels:
name: mongo
role: proxy
pl: cpp
application: mongo
version: 16.03
division: infrastructure
subsets:
- addresses:
- ip: 192.168.0.203
ports:
- port: 27017
映射外部URI
service
kind: Service
apiVersion: v1
metadata:
name: mongo
labels:
name: mongo
role: proxy
pl: cpp
application: mongo
version: 16.03
division: infrastructure
spec:
type: ExternalName
externalName: mongodb01v.lobj.juejin.id
映射外部IP并转发端口
service
kind: Service
apiVersion: v1
metadata:
name: mongo
labels:
name: mongo
role: proxy
pl: cpp
application: mongo
version: 16.03
division: infrastructure
Spec:
type: ClusterIP
ports:
- port: 27017
targetPort: 7000
kind: Endpoints
apiVersion: v1
metadata:
name: mongo
labels:
name: mongo
role: proxy
pl: cpp
application: mongo
version: 16.03
division: infrastructure
subsets:
- addresses:
- ip: 192.168.0.203
ports:
- port: 7000