discovery-lb.yaml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # This creates a discovery Service for each member in the core set, and ties to
  2. # the use of the Neo4j discovery type "K8S" with the configured selectors.
  3. # Done as many times as there are core machines, or just once if standalone.
  4. #
  5. # IMPORTANT - related to scaling, in order for the cluster to form correctly
  6. # there must be one of these per core node. As a result, we intentionally create
  7. # too many of them in the causal cluster scenario to ensure that when pods scale
  8. # up, there are extra discovery addresses to cover them.
  9. ##########################################################################
  10. {{- $dot := . }}
  11. {{- $servers := int .Values.core.numberOfServers }}
  12. {{- $instances := .Values.core.discoveryService.instances }}
  13. {{- if .Values.core.standalone }}
  14. {{- $instances := .Values.core.discoveryService.standaloneOnly }}
  15. {{- end }}
  16. {{- range $index, $value := $instances }}
  17. ---
  18. apiVersion: v1
  19. kind: Service
  20. metadata:
  21. name: discovery-{{ template "neo4j.fullname" $dot }}-{{ . }}
  22. labels:
  23. neo4j.com/coreindex: "{{ $index }}"
  24. neo4j.com/cluster: {{ template "neo4j.fullname" $dot }}
  25. neo4j.com/role: CORE
  26. neo4j.com/bolt: "false"
  27. neo4j.com/http: "false"
  28. app.kubernetes.io/managed-by: {{ $dot.Release.Service | quote }}
  29. app.kubernetes.io/instance: {{ $dot.Release.Name | quote }}
  30. helm.sh/chart: "{{ $dot.Chart.Name }}-{{ $dot.Chart.Version }}"
  31. app.kubernetes.io/name: {{ template "neo4j.name" $dot }}
  32. app.kubernetes.io/component: core
  33. {{- with $dot.Values.core.discoveryService.labels }}
  34. {{ toYaml . | nindent 4 }}
  35. {{- end }}
  36. {{- with $dot.Values.core.discoveryService.annotations }}
  37. annotations:
  38. {{- toYaml . | nindent 4 }}
  39. {{- end }}
  40. spec:
  41. {{- if (or (eq $dot.Values.core.discoveryService.type "ClusterIP") (empty $dot.Values.core.discoveryService.type)) }}
  42. type: ClusterIP
  43. clusterIP: None
  44. {{- else if eq $dot.Values.core.discoveryService.type "LoadBalancer" }}
  45. type: LoadBalancer
  46. {{- with $dot.Values.core.discoveryService.loadBalancerSourceRanges }}
  47. loadBalancerSourceRanges:
  48. {{ toYaml . | nindent 4 }}
  49. {{- end -}}
  50. {{- else }}
  51. type: {{ $dot.Values.core.discoveryService.type }}
  52. {{- end }}
  53. publishNotReadyAddresses: true
  54. ports:
  55. - name: tcp-discovery
  56. port: 5000
  57. targetPort: 5000
  58. protocol: TCP
  59. - name: tcp-transaction
  60. port: 6000
  61. targetPort: 6000
  62. protocol: TCP
  63. - name: tcp-raft
  64. port: 7000
  65. targetPort: 7000
  66. protocol: TCP
  67. - name: tcp-boltrouting
  68. port: 7688
  69. targetPort: 7688
  70. protocol: TCP
  71. {{- if $dot.Values.metrics.prometheus.enabled }}
  72. - name: tcp-prometheus
  73. port: 2004
  74. targetPort: 2004
  75. protocol: TCP
  76. {{- end }}
  77. {{- if $dot.Values.metrics.graphite.enabled }}
  78. - name: tcp-graphite
  79. port: 2003
  80. targetPort: 2003
  81. protocol: TCP
  82. {{- end }}
  83. {{- if $dot.Values.metrics.jmx.enabled }}
  84. - name: tcp-jmx
  85. port: 3637
  86. targetPort: 3637
  87. protocol: TCP
  88. {{- end }}
  89. selector:
  90. statefulset.kubernetes.io/pod-name: "{{ template "neo4j.fullname" $dot }}-core-{{ . }}"
  91. {{- end }}