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

-------------------------------------------------------------------------------
 WARNING

    By specifying "client.service.type=LoadBalancer" you have most likely
    exposed the Elasticsearch service externally.

    Please note that Elasticsearch does not implement a authentication
    mechanism to secure your cluster. For security reasons, we strongly
    suggest that you switch to "ClusterIP" or "NodePort".
-------------------------------------------------------------------------------
{{- end }}

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

  Elasticsearch can be accessed within the cluster on port {{ .Values.client.service.port }} at {{ template "client.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local

  To access from outside the cluster execute the following commands:

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

    export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "client.fullname" . }})
    export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
    echo http://$NODE_IP:$NODE_PORT/
{{- else if contains "LoadBalancer" .Values.client.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 {{ template "client.fullname" . }}'

    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "client.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo http://$SERVICE_IP:{{ .Values.client.service.port }}/
{{- else if contains "ClusterIP"  .Values.client.service.type }}

    export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }},release={{ .Release.Name }},component=master" -o jsonpath="{.items[0].metadata.name}")
    echo http://127.0.0.1:{{ .Values.client.service.port }}/
    kubectl port-forward $POD_NAME {{ .Values.client.service.port }}:9200
{{- end }}
