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

  Credentials:

    echo Username              : {{ .Values.rabbitmqUsername }}
    echo Password              : $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.data.rabbitmq-password}" | base64 --decode)
    echo ErLang Cookie         : $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.data.rabbitmq-erlang-cookie}" | base64 --decode)
{{- if .Values.createClientUser }}
    echo 'client' user Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.data.clients-password}" | base64 --decode)
{{- end }}

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

  To access for 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_AMQP=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[1].nodePort}" services {{ template "fullname" . }})
    export NODE_PORT_STATS=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[3].nodePort}" services {{ template "fullname" . }})

  To Access the RabbitMQ AMQP port:

    echo amqp://$NODE_IP:$NODE_PORT_AMQP/

  To Access the RabbitMQ Management interface:

    echo http://$NODE_IP:$NODE_PORT_STATS/

{{- 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 {{ template "name" . }}'

    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

  To Access the RabbitMQ AMQP port:

    echo amqp://$SERVICE_IP:{{ .Values.rabbitmqNodePort }}/

  To Access the RabbitMQ Management interface:

    echo http://$SERVICE_IP:{{ .Values.rabbitmqManagerPort }}/

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

    export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }}" -o jsonpath="{.items[0].metadata.name}")
    kubectl port-forward $POD_NAME --namespace {{ .Release.Namespace }} {{ .Values.rabbitmqNodePort }}:{{ .Values.rabbitmqNodePort }} {{ .Values.rabbitmqManagerPort }}:{{ .Values.rabbitmqManagerPort }}

  To Access the RabbitMQ AMQP port:

    echo amqp://127.0.0.1:{{ .Values.rabbitmqNodePort }}/

  To Access the RabbitMQ Management interface:

    echo URL : http://127.0.0.1:{{ .Values.rabbitmqManagerPort }}
{{- end }}


To enable mirroring for all the host:

  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "name" . }}" -o jsonpath="{.items[0].metadata.name}")
  kubectl exec $POD_NAME --namespace {{ .Release.Namespace }} -- rabbitmqctl set_policy ha-all "." '{"ha-mode":"all", "ha-sync-mode":"automatic"}' --apply-to all --priority 0
