service.yaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: {{ template "common.names.fullname" . }}
  5. namespace: {{ include "common.names.namespace" . | quote }}
  6. labels: {{- include "common.labels.standard" . | nindent 4 }}
  7. app.kubernetes.io/component: clickhouse
  8. {{- if .Values.commonLabels }}
  9. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  10. {{- end }}
  11. {{- if or .Values.service.annotations .Values.commonAnnotations }}
  12. annotations:
  13. {{- if .Values.service.annotations }}
  14. {{- include "common.tplvalues.render" ( dict "value" .Values.service.annotations "context" $) | nindent 4 }}
  15. {{- end }}
  16. {{- if .Values.commonAnnotations }}
  17. {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  18. {{- end }}
  19. {{- end }}
  20. spec:
  21. type: {{ .Values.service.type }}
  22. {{- if and .Values.service.clusterIP (eq .Values.service.type "ClusterIP") }}
  23. clusterIP: {{ .Values.service.clusterIP }}
  24. {{- end }}
  25. {{- if .Values.service.sessionAffinity }}
  26. sessionAffinity: {{ .Values.service.sessionAffinity }}
  27. {{- end }}
  28. {{- if .Values.service.sessionAffinityConfig }}
  29. sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.service.sessionAffinityConfig "context" $) | nindent 4 }}
  30. {{- end }}
  31. {{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
  32. externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
  33. {{- end }}
  34. {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerSourceRanges)) }}
  35. loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
  36. {{- end }}
  37. {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP)) }}
  38. loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  39. {{- end }}
  40. ports:
  41. - name: http
  42. targetPort: 8123
  43. port: {{ .Values.service.ports.http }}
  44. protocol: TCP
  45. {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.http)) }}
  46. nodePort: {{ .Values.service.nodePorts.http }}
  47. {{- else if eq .Values.service.type "ClusterIP" }}
  48. nodePort: null
  49. {{- end }}
  50. #{{- if .Values.tls.enabled }}
  51. #- name: https
  52. # targetPort: https
  53. # port: {{ .Values.service.ports.https }}
  54. # protocol: TCP
  55. # {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.https)) }}
  56. # nodePort: {{ .Values.service.nodePorts.https }}
  57. # {{- else if eq .Values.service.type "ClusterIP" }}
  58. # nodePort: null
  59. # {{- end }}
  60. #{{- end }}
  61. - name: tcp
  62. targetPort: tcp
  63. port: {{ .Values.service.ports.tcp }}
  64. protocol: TCP
  65. {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.tcp)) }}
  66. nodePort: {{ .Values.service.nodePorts.tcp }}
  67. {{- else if eq .Values.service.type "ClusterIP" }}
  68. nodePort: null
  69. {{- end }}
  70. #{{- if .Values.tls.enabled }}
  71. #- name: tcp-secure
  72. # targetPort: tcp-secure
  73. # port: {{ .Values.service.ports.tcpSecure }}
  74. # protocol: TCP
  75. # {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.tcpSecure)) }}
  76. # nodePort: {{ .Values.service.nodePorts.tcpSecure }}
  77. # {{- else if eq .Values.service.type "ClusterIP" }}
  78. # nodePort: null
  79. # {{- end }}
  80. #{{- end }}
  81. #{{- if .Values.keeper.enabled }}
  82. #- name: tcp-keeper
  83. # targetPort: tcp-keeper
  84. # port: {{ .Values.service.ports.keeper }}
  85. # protocol: TCP
  86. # {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.tcp)) }}
  87. # nodePort: {{ .Values.service.nodePorts.keeper }}
  88. # {{- else if eq .Values.service.type "ClusterIP" }}
  89. # nodePort: null
  90. # {{- end }}
  91. #- name: tcp-keeperinter
  92. # targetPort: tcp-keeperinter
  93. # port: {{ .Values.service.ports.keeperInter }}
  94. # protocol: TCP
  95. # {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.tcp)) }}
  96. # nodePort: {{ .Values.service.nodePorts.keeperInter }}
  97. # {{- else if eq .Values.service.type "ClusterIP" }}
  98. # nodePort: null
  99. # {{- end }}
  100. #{{- if .Values.tls.enabled }}
  101. #- name: tcp-keepertls
  102. # targetPort: tcp-keepertls
  103. # port: {{ .Values.service.ports.keeperSecure }}
  104. # protocol: TCP
  105. # {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.tcpSecure)) }}
  106. # nodePort: {{ .Values.service.nodePorts.keeperSecure }}
  107. # {{- else if eq .Values.service.type "ClusterIP" }}
  108. # nodePort: null
  109. # {{- end }}
  110. #{{- end }}
  111. #{{- end }}
  112. - name: tcp-mysql
  113. targetPort: tcp-mysql
  114. port: {{ .Values.service.ports.mysql }}
  115. protocol: TCP
  116. {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.mysql)) }}
  117. nodePort: {{ .Values.service.nodePorts.mysql }}
  118. {{- else if eq .Values.service.type "ClusterIP" }}
  119. nodePort: null
  120. {{- end }}
  121. #- name: tcp-postgresql
  122. # targetPort: tcp-postgresql
  123. # port: {{ .Values.service.ports.postgresql }}
  124. # protocol: TCP
  125. # {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.postgresql)) }}
  126. # nodePort: {{ .Values.service.nodePorts.postgresql }}
  127. # {{- else if eq .Values.service.type "ClusterIP" }}
  128. # nodePort: null
  129. # {{- end }}
  130. #- name: http-intersrv
  131. # targetPort: http-intersrv
  132. # port: {{ .Values.service.ports.interserver }}
  133. # protocol: TCP
  134. # {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.interserver)) }}
  135. # nodePort: {{ .Values.service.nodePorts.interserver }}
  136. # {{- else if eq .Values.service.type "ClusterIP" }}
  137. # nodePort: null
  138. # {{- end }}
  139. {{- if .Values.metrics.enabled }}
  140. - name: http-metrics
  141. targetPort: http-metrics
  142. port: {{ .Values.service.ports.metrics }}
  143. protocol: TCP
  144. {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.metrics)) }}
  145. nodePort: {{ .Values.service.nodePorts.metrics }}
  146. {{- else if eq .Values.service.type "ClusterIP" }}
  147. nodePort: null
  148. {{- end }}
  149. {{- end }}
  150. #{{- if .Values.service.extraPorts }}
  151. #{{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
  152. #{{- end }}
  153. selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
  154. app.kubernetes.io/component: clickhouse