lucidworks / solr-helm-chart

A helm chart to install solr into kubernetes
26 stars 30 forks source link

Create multiple zookeeper services and update zkhosts #1

Open ghost opened 5 years ago

ghost commented 5 years ago

Right now it seems as though this chart only creates 1 service for zookeeper and because of this if you have one of the pods fail for zookeeper and its the leader, solr goes down for a few minutes.

I suggest having the chart create 3 services, 1 per zookeeper pod and then update the zkhosts accordingly.

Each service could be similar to the one below.

kind: Service
apiVersion: v1
metadata:
  name: solr-zookeeper-0-service
  labels:
    app: zookeeper
spec:
  selector:
    statefulset.kubernetes.io/pod-name: solr-zookeeper-0
  ports:
  - protocol: TCP
    port: 2180
    targetPort: 2181
  type: ClusterIP
fredleger commented 5 years ago

another approach i was following in my own chart was to use the headless service direct adressing feature :

- name: "ZK_HOST"
   value: "solr-cloud-zookeeper-0.solr-cloud-zookeeper-headless:2181,solr-cloud-zookeeper-1.solr-cloud-zookeeper-headless:2181,solr-cloud-zookeeper-2.solr-cloud-zookeeper-headless:2181"

So it can just be a for loop in helm templating i guess.

ghost commented 5 years ago

I’ve done this same thing for now. But it would be good if the chart supported this so zookeeper doesn’t show as a red status with just the one headless service.

I’ve also added node selectors so we can run solr in the same cluster, but in a node pool.

lwj5 commented 5 years ago

https://github.com/helm/charts/pull/17515

Showing red status is an issue in Solr, will be filing a bug. Please use the headless service, so solr can switch IP quickly and does not go down for a few minutes. The K8s loadbalancer is slow to change server.

loginvarun commented 4 years ago

I have created custom function "zoo-pods" in file: charts/solr/charts/zookeeper/templates/_helpers.tpl and include that function in solr stateful template. There is no harding coding of zookeeper pod name and its count.

file: charts/solr/charts/zookeeper/templates/_helpers.tpl {{- define "zoo-pods" -}} {{- $podCount := .Values.zookeeper.replicaCount | int }} {{- range $index0 := until $podCount -}} {{- $index1 := $index0 | add1 -}} {{ include "zookeeper.fullname" $ }}-zookeeper-{{ $index0 }}.{{ include "solr.zookeeper-service-name" $ }}:2181{{ if ne $index1 $podCount }},{{ end }} {{- end -}} {{- end -}}

charts/solr/templates/statefulset.yaml

`

loginvarun commented 4 years ago

I have created custom function "zoo-pods" in the helper file and included that function in solr stateful template. It will avoid future issue of increasing replica count of zookeeper.

{{- define "zoo-pods" -}}
{{- $podCount := .Values.zookeeper.replicaCount | int }}
  {{- range $index0 := until $podCount -}}
    {{- $index1 := $index0 | add1 -}}
{{ include "zookeeper.fullname" $  }}-zookeeper-{{ $index0 }}.{{ include "solr.zookeeper-service-name" $ }}:2181{{ if ne $index1 $podCount }},{{ end }}
  {{- end -}}
{{- end -}}

charts/solr/templates/statefulset.yaml

            - name: "ZK_HOST"
              value: "{{ template "zoo-pods" . }}"
kingvip commented 2 years ago

I have created custom function "zoo-pods" in the helper file and included that function in solr stateful template. It will avoid future issue of increasing replica count of zookeeper.

{{- define "zoo-pods" -}}
{{- $podCount := .Values.zookeeper.replicaCount | int }}
  {{- range $index0 := until $podCount -}}
    {{- $index1 := $index0 | add1 -}}
{{ include "zookeeper.fullname" $  }}-zookeeper-{{ $index0 }}.{{ include "solr.zookeeper-service-name" $ }}:2181{{ if ne $index1 $podCount }},{{ end }}
  {{- end -}}
{{- end -}}

charts/solr/templates/statefulset.yaml

            - name: "ZK_HOST"
              value: "{{ template "zoo-pods" . }}"

Follow your method zk status For input string: "null"

kingvip commented 2 years ago

@loginvarun