容器化参考文档
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.

148 lines
2.4 KiB

3 years ago
  1. mapping-external-services.md
  2. ---------------------------------------------------------
  3. ```
  4. @version 180807:1
  5. @author zhangxuhong <zhangxuhong@xitu.io>
  6. ```
  7. Name
  8. ----
  9. mapping-external-services - 映射外部服务.
  10. Table of Contents
  11. -----------------
  12. * [Name](#name)
  13. * [Reference 参考文档](#reference)
  14. Reference 参考文档
  15. ------------------
  16. * [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)
  17. * [ClusterIP和NodePort的区别](https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0)
  18. case
  19. ----
  20. 有的时候我们要访问 kubernetes 集群外部的服务.
  21. 这些服务可能是没来得及迁移到集群里面的, 或者第三方的, 或者是托管的数据库.
  22. 因此便有了映射外部服务的场景.
  23. method
  24. ------
  25. - 映射外部IP和端口
  26. - service
  27. ```
  28. kind: Service
  29. apiVersion: v1
  30. metadata:
  31. name: mongo
  32. labels:
  33. name: mongo
  34. role: proxy
  35. pl: cpp
  36. application: mongo
  37. version: 16.03
  38. division: infrastructure
  39. Spec:
  40. type: ClusterIP
  41. ports:
  42. - port: 27017
  43. targetPort: 27017
  44. ```
  45. - endpoints
  46. ```
  47. kind: Endpoints
  48. apiVersion: v1
  49. metadata:
  50. name: mongo
  51. labels:
  52. name: mongo
  53. role: proxy
  54. pl: cpp
  55. application: mongo
  56. version: 16.03
  57. division: infrastructure
  58. subsets:
  59. - addresses:
  60. - ip: 192.168.0.203
  61. ports:
  62. - port: 27017
  63. ```
  64. - 映射外部URI
  65. - service
  66. ```
  67. kind: Service
  68. apiVersion: v1
  69. metadata:
  70. name: mongo
  71. labels:
  72. name: mongo
  73. role: proxy
  74. pl: cpp
  75. application: mongo
  76. version: 16.03
  77. division: infrastructure
  78. spec:
  79. type: ExternalName
  80. externalName: mongodb01v.lobj.juejin.id
  81. ```
  82. - 映射外部IP并转发端口
  83. - service
  84. ```
  85. kind: Service
  86. apiVersion: v1
  87. metadata:
  88. name: mongo
  89. labels:
  90. name: mongo
  91. role: proxy
  92. pl: cpp
  93. application: mongo
  94. version: 16.03
  95. division: infrastructure
  96. Spec:
  97. type: ClusterIP
  98. ports:
  99. - port: 27017
  100. targetPort: 7000
  101. ```
  102. - endpoints
  103. ```
  104. kind: Endpoints
  105. apiVersion: v1
  106. metadata:
  107. name: mongo
  108. labels:
  109. name: mongo
  110. role: proxy
  111. pl: cpp
  112. application: mongo
  113. version: 16.03
  114. division: infrastructure
  115. subsets:
  116. - addresses:
  117. - ip: 192.168.0.203
  118. ports:
  119. - port: 7000
  120. ```