|
|
- mapping-external-services.md
- ---------------------------------------------------------
- ```
- @version 180807:1
- @author zhangxuhong <zhangxuhong@xitu.io>
- ```
-
- Name
- ----
-
- mapping-external-services - 映射外部服务.
-
-
- Table of Contents
- -----------------
-
- * [Name](#name)
- * [Reference 参考文档](#reference)
-
-
-
- Reference 参考文档
- ------------------
-
- * [https://cloudplatform.googleblog.com/2018/05/Kubernetes-best-practices-mapping-external-services.html](https://cloudplatform.googleblog.com/2018/05/Kubernetes-best-practices-mapping-external-services.html)
- * [ClusterIP和NodePort的区别](https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0)
-
- 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
- ```
|