svc.yaml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {{- /*
  2. Copyright Broadcom, Inc. All Rights Reserved.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. apiVersion: v1
  6. kind: Service
  7. metadata:
  8. name: {{ template "common.names.fullname" . }}
  9. namespace: {{ template "zookeeper.namespace" . }}
  10. labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  11. app.kubernetes.io/component: zookeeper
  12. {{- if or .Values.commonAnnotations .Values.service.annotations }}
  13. {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.annotations .Values.commonAnnotations ) "context" . ) }}
  14. annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
  15. {{- end }}
  16. spec:
  17. type: {{ .Values.service.type }}
  18. {{- if and .Values.service.clusterIP (eq .Values.service.type "ClusterIP") }}
  19. clusterIP: {{ .Values.service.clusterIP }}
  20. {{- end }}
  21. {{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
  22. externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
  23. {{- end }}
  24. {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerSourceRanges)) }}
  25. loadBalancerSourceRanges: {{ .Values.service.loadBalancerSourceRanges }}
  26. {{- end }}
  27. {{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP)) }}
  28. loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  29. {{- end }}
  30. {{- if .Values.service.sessionAffinity }}
  31. sessionAffinity: {{ .Values.service.sessionAffinity }}
  32. {{- end }}
  33. {{- if .Values.service.sessionAffinityConfig }}
  34. sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.service.sessionAffinityConfig "context" $) | nindent 4 }}
  35. {{- end }}
  36. ports:
  37. {{- if not .Values.service.disableBaseClientPort }}
  38. - name: tcp-client
  39. port: {{ .Values.service.ports.client }}
  40. targetPort: client
  41. {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.client)) }}
  42. nodePort: {{ .Values.service.nodePorts.client }}
  43. {{- else if eq .Values.service.type "ClusterIP" }}
  44. nodePort: null
  45. {{- end }}
  46. {{- end }}
  47. {{- if .Values.tls.client.enabled }}
  48. - name: tcp-client-tls
  49. port: {{ .Values.service.ports.tls }}
  50. targetPort: client-tls
  51. {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.tls)) }}
  52. nodePort: {{ .Values.service.nodePorts.tls }}
  53. {{- else if eq .Values.service.type "ClusterIP" }}
  54. nodePort: null
  55. {{- end }}
  56. {{- end }}
  57. {{- if gt (int .Values.replicaCount) 1 }}
  58. {{- /* These ports are only open when there are more than 1 replica */}}
  59. - name: tcp-follower
  60. port: {{ .Values.service.ports.follower }}
  61. targetPort: follower
  62. - name: tcp-election
  63. port: {{ .Values.service.ports.election }}
  64. targetPort: election
  65. {{- end }}
  66. {{- if .Values.service.extraPorts }}
  67. {{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
  68. {{- end }}
  69. {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }}
  70. selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
  71. app.kubernetes.io/component: zookeeper