{{- if (eq .Values.service.type "LoadBalancer")  }}
---------------------------------------------------------------------------------------------
 WARNING

    By specifying "serviceType=LoadBalancer" and not configuring the authentication
    you have most likely exposed the solr externally without any
    authentication mechanism.

    For security reasons, we strongly suggest that you switch to "ClusterIP" or
    "NodePort". As alternative, you can also configure the Solr authentication.

---------------------------------------------------------------------------------------------
{{- end }}


** Please be patient while the chart is being deployed **

Solr can be accessed via port {{ .Values.service.port }} on the following DNS name from within your cluster:

{{ include "solr.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ .Values.service.port }}

{{- if .Values.authentication.enabled }}

To get the Solr credentials execute the following commands:

    echo Username: {{ .Values.authentication.adminUsername }}
    echo Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ include "solr.secretName" . }} -o jsonpath="{.data.solr-password}" | base64 --decode)

{{- end }}

To connect to your Solr from outside the cluster execute the following commands:

{{- if contains "NodePort" .Values.service.type }}

    export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
    export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.names.fullname" . }})
    echo "Go to ${NODE_IP}:${NODE_PORT}"

{{- else if contains "LoadBalancer" .Values.service.type }}

  NOTE: It may take a few minutes for the LoadBalancer IP to be available.
        Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ include "common.names.fullname" . }}'

    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
    echo "Go to ${SERVICE_IP}:{{ .Values.service.port }}"

{{- else if contains "ClusterIP" .Values.service.type }}

    kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "common.names.fullname" . }} {{ .Values.service.port }}:{{ .Values.service.port }} &

    Go to localhost:{{ .Values.service.port }}

{{- end }}

{{- if .Values.exporter.enabled  }}

** Solr Prometheus metrics are exported to the following endpoints: **

  * Internally, within the kubernetes cluster on:

{{ include "solr.exporter-name" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ .Values.exporter.port }}/metrics

{{- end }}

{{- include "common.warnings.rollingTag" .Values.image }}
{{- include "common.warnings.rollingTag" .Values.exporter.image }}

{{- if .Values.authentication.enabled -}}
{{- $requiredPasswords := list -}}
{{- $secretNameSolr := include "solr.secretName" . -}}

{{- if not .Values.existingSecret -}}
  {{- $requiredSolrPassword := dict "valueKey" "authentication.adminPassword" "secret" $secretNameSolr "field" "solr-password" -}}
  {{- $requiredPasswords = append $requiredPasswords $requiredSolrPassword -}}
{{- end -}}

{{- $requiredSolrPasswordErrors := include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" $) -}}
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $requiredSolrPasswordErrors) "context" $) -}}
{{- end -}}
