svc.yaml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {{- /*
  2. Copyright VMware, Inc.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. apiVersion: v1
  6. kind: Service
  7. metadata:
  8. name: {{ template "common.names.fullname" . }}
  9. namespace: {{ include "common.names.namespace" . | quote }}
  10. labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  11. app.kubernetes.io/component: kafka
  12. {{- if or .Values.service.annotations .Values.commonAnnotations }}
  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 (eq .Values.service.type "LoadBalancer") }}
  25. allocateLoadBalancerNodePorts: {{ .Values.service.allocateLoadBalancerNodePorts }}
  26. {{- if (not (empty .Values.service.loadBalancerSourceRanges)) }}
  27. loadBalancerSourceRanges: {{ .Values.service.loadBalancerSourceRanges }}
  28. {{- end }}
  29. {{- if (not (empty .Values.service.loadBalancerIP)) }}
  30. loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  31. {{- end }}
  32. {{- end }}
  33. {{- if .Values.service.sessionAffinity }}
  34. sessionAffinity: {{ .Values.service.sessionAffinity }}
  35. {{- end }}
  36. {{- if .Values.service.sessionAffinityConfig }}
  37. sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.service.sessionAffinityConfig "context" $) | nindent 4 }}
  38. {{- end }}
  39. ports:
  40. - name: tcp-client
  41. port: {{ .Values.service.ports.client }}
  42. protocol: TCP
  43. targetPort: client
  44. {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.client)) }}
  45. nodePort: {{ .Values.service.nodePorts.client }}
  46. {{- else if eq .Values.service.type "ClusterIP" }}
  47. nodePort: null
  48. {{- end }}
  49. {{- if .Values.externalAccess.enabled }}
  50. - name: tcp-external
  51. port: {{ .Values.service.ports.external }}
  52. protocol: TCP
  53. targetPort: external
  54. {{- if (not (empty .Values.service.nodePorts.external)) }}
  55. nodePort: {{ .Values.service.nodePorts.external }}
  56. {{- end }}
  57. {{- end }}
  58. {{- if .Values.service.extraPorts }}
  59. {{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
  60. {{- end }}
  61. selector: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  62. app.kubernetes.io/part-of: kafka
  63. {{- if and .Values.kraft.enabled .Values.controller.controllerOnly }}
  64. app.kubernetes.io/component: broker
  65. {{- end }}