service.yaml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {{- if and (eq .Values.architecture "replication") (not .Values.sentinel.enabled) }}
  2. apiVersion: v1
  3. kind: Service
  4. metadata:
  5. name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
  6. namespace: {{ .Release.Namespace | quote }}
  7. labels: {{- include "common.labels.standard" . | nindent 4 }}
  8. app.kubernetes.io/component: replica
  9. {{- if .Values.commonLabels }}
  10. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  11. {{- end }}
  12. {{- if or .Values.replica.service.annotations .Values.commonAnnotations }}
  13. annotations:
  14. {{- if .Values.replica.service.annotations }}
  15. {{- include "common.tplvalues.render" ( dict "value" .Values.replica.service.annotations "context" $ ) | nindent 4 }}
  16. {{- end }}
  17. {{- if .Values.commonAnnotations }}
  18. {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  19. {{- end }}
  20. {{- end }}
  21. spec:
  22. type: {{ .Values.replica.service.type }}
  23. {{- if or (eq .Values.replica.service.type "LoadBalancer") (eq .Values.replica.service.type "NodePort") }}
  24. externalTrafficPolicy: {{ .Values.replica.service.externalTrafficPolicy | quote }}
  25. {{- end }}
  26. {{- if (semverCompare ">=1.22-0" (include "common.capabilities.kubeVersion" .)) }}
  27. internalTrafficPolicy: {{ .Values.replica.service.internalTrafficPolicy }}
  28. {{- end }}
  29. {{- if and (eq .Values.replica.service.type "LoadBalancer") (not (empty .Values.replica.service.loadBalancerIP)) }}
  30. loadBalancerIP: {{ .Values.replica.service.loadBalancerIP }}
  31. {{- end }}
  32. {{- if and (eq .Values.replica.service.type "LoadBalancer") (not (empty .Values.replica.service.loadBalancerSourceRanges)) }}
  33. loadBalancerSourceRanges: {{ toYaml .Values.replica.service.loadBalancerSourceRanges | nindent 4 }}
  34. {{- end }}
  35. {{- if and .Values.replica.service.clusterIP (eq .Values.replica.service.type "ClusterIP") }}
  36. clusterIP: {{ .Values.replica.service.clusterIP }}
  37. {{- end }}
  38. {{- if .Values.replica.service.sessionAffinity }}
  39. sessionAffinity: {{ .Values.replica.service.sessionAffinity }}
  40. {{- end }}
  41. {{- if .Values.replica.service.sessionAffinityConfig }}
  42. sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.replica.service.sessionAffinityConfig "context" $) | nindent 4 }}
  43. {{- end }}
  44. ports:
  45. - name: tcp-redis
  46. port: {{ .Values.replica.service.ports.redis }}
  47. targetPort: redis
  48. {{- if and (or (eq .Values.replica.service.type "NodePort") (eq .Values.replica.service.type "LoadBalancer")) .Values.replica.service.nodePorts.redis}}
  49. nodePort: {{ .Values.replica.service.nodePorts.redis}}
  50. {{- else if eq .Values.replica.service.type "ClusterIP" }}
  51. nodePort: null
  52. {{- end }}
  53. {{- if .Values.replica.service.extraPorts }}
  54. {{- include "common.tplvalues.render" (dict "value" .Values.replica.service.extraPorts "context" $) | nindent 4 }}
  55. {{- end }}
  56. selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
  57. app.kubernetes.io/component: replica
  58. {{- end }}