容器化参考文档
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

2.4 KiB

mapping-external-services.md

@version    180807:1
@author     zhangxuhong <zhangxuhong@xitu.io>

Name

mapping-external-services - 映射外部服务.

Table of Contents

Reference 参考文档

case

有的时候我们要访问 kubernetes 集群外部的服务. 这些服务可能是没来得及迁移到集群里面的, 或者第三方的, 或者是托管的数据库. 因此便有了映射外部服务的场景.

method

  • 映射外部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
  • endpoints
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
  • endpoints
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