svc.yaml 2.8 KB

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