nodeport-service.yaml 908 B

123456789101112131415161718192021222324252627282930
  1. {{- if .Values.externalAccess.enabled }}
  2. {{- $root := . }}
  3. {{- $fullName := include "kafka.fullname" . }}
  4. {{- $initNodePort := .Values.externalAccess.initNodePort | int }}
  5. {{- $replicaCount := .Values.replicaCount | int }}
  6. {{- range $i, $e := until $replicaCount }}
  7. {{- $targetPod := printf "%s-%d" (printf "%s" $fullName) $i }}
  8. {{- $_ := set $ "targetPod" $targetPod }}
  9. ---
  10. apiVersion: v1
  11. kind: Service
  12. metadata:
  13. name: {{ include "kafka.fullname" $root }}-{{ $i }}-external
  14. labels:
  15. {{- include "kafka.labels" $root | nindent 4 }}
  16. statefulset.kubernetes.io/pod-name: {{ $targetPod }}
  17. spec:
  18. type: NodePort
  19. ports:
  20. - name: tcp-kafka-ext
  21. protocol: TCP
  22. targetPort: tcp-kafka-ext
  23. port: 9094
  24. nodePort: {{ add $initNodePort $i }}
  25. selector:
  26. {{- include "kafka.selectorLabels" $root | nindent 4 }}
  27. statefulset.kubernetes.io/pod-name: {{ $targetPod }}
  28. {{- end }}
  29. {{- end }}