svc.yaml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: {{ template "kafka.fullname" . }}
  5. labels: {{- include "common.labels.standard" . | nindent 4 }}
  6. app.kubernetes.io/component: kafka
  7. {{- if .Values.commonLabels }}
  8. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  9. {{- end }}
  10. {{- if or .Values.service.annotations .Values.commonAnnotations }}
  11. annotations:
  12. {{- if .Values.service.annotations }}
  13. {{ include "common.tplvalues.render" ( dict "value" .Values.service.annotations "context" $) | nindent 4 }}
  14. {{- end }}
  15. {{- if .Values.commonAnnotations }}
  16. {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  17. {{- end }}
  18. {{- end }}
  19. spec:
  20. type: {{ .Values.service.type }}
  21. {{- if eq .Values.service.type "LoadBalancer" }}
  22. {{- if .Values.service.loadBalancerIP }}
  23. loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  24. {{- end }}
  25. {{- if .Values.service.loadBalancerSourceRanges }}
  26. loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
  27. {{- end }}
  28. {{- end }}
  29. ports:
  30. - name: tcp-client
  31. port: {{ .Values.service.port }}
  32. protocol: TCP
  33. targetPort: kafka-client
  34. {{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) (not (empty .Values.service.nodePorts.client)) }}
  35. nodePort: {{ .Values.service.nodePorts.client }}
  36. {{- else if eq .Values.service.type "ClusterIP" }}
  37. nodePort: null
  38. {{- end }}
  39. {{- if and .Values.externalAccess.enabled (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) }}
  40. - name: tcp-external
  41. port: {{ .Values.service.externalPort }}
  42. protocol: TCP
  43. targetPort: kafka-external
  44. {{- if (not (empty .Values.service.nodePorts.external)) }}
  45. nodePort: {{ .Values.service.nodePorts.external }}
  46. {{- end }}
  47. {{- end }}
  48. selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
  49. app.kubernetes.io/component: kafka