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

{{- if .Values.ingress.enabled }}
    Kong URL(s):
{{- if .Values.ingress.hostname }}
    - http://{{ .Values.ingress.hostname }}
{{- end }}
{{- range $host := .Values.ingress.hosts }}
  {{- range .paths }}
    - http://{{ $host.name }}{{ . }}
  {{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}

    Get the Kubernetes node IP by using the following command
    export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")

    Access the Kong proxy by using the following commands

    export PROXY_NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "kong.fullname" . }})
    echo http://$NODE_IP:$PROXY_NODE_PORT

    {{- if .Values.service.exposeAdmin }}

    Access the Kong admin by using the following commands

    export ADMIN_NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[2].nodePort}" services {{ include "kong.fullname" . }})
    echo http://$NODE_IP:$ADMIN_NODE_PORT

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

     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
           You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "kong.fullname" . }}'
    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "kong.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo http://$SERVICE_IP:{{ .Values.service.proxyHttpPort }}
{{- else if contains "ClusterIP" .Values.service.type }}

    Access the Kong proxy by using the following commands

    echo "Browse to http://127.0.0.1:8000"
    kubectl port-forward svc/{{ include "kong.fullname" . }} 8080:{{ .Values.service.proxyHttpPort }} &

    Access the Kong admin by using the following commands

    echo "Browse to http://127.0.0.1:8001"
    {{- if .Values.service.exposeAdmin }}
    kubectl port-forward svc/{{ include "kong.fullname" . }} 8001:{{ .Values.service.adminHttpPort }} &
    {{- else }}
    export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name:{{ include "kong.name" . }},app.kubernetes.io/instance:{{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")

    kubectl port-forward pod/$POD_NAME 8001:8001 &
    {{- end }}
{{- end }}

{{- if .Values.ingressController.enabled }}

     The Kong Ingress Controller was deployed as part of the Kong pods. The following objects are available in the Kubernetes API:

     kubectl get kongconsumers
     kubectl get kongcredentials
     kubectl get kongingresses
     kubectl get kongplugins

{{- end }}

{{- if and (contains "bitnami/" .Values.image.repository) (not (.Values.image.tag | toString | regexFind "-r\\d+$|sha256:")) }}

WARNING: Rolling tag detected ({{ .Values.image.repository }}:{{ .Values.image.tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment.
+info https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/

{{- end }}

If you want to upgrade the installation you will need to re-set the database credentials. Execute the following command
{{- if eq .Values.database "postgresql" }}

  kubectl get secret --namespace {{ .Release.Namespace }} {{ include "kong.postgresql.secretName" . }} -o jsonpath="{.data.postgresql-password}" | base64 --decode
{{- else }}

  kubectl get secret --namespace {{ .Release.Namespace }} {{ include "kong.cassandra.secretName" . }} -o jsonpath="{.data.cassandra-password}" | base64 --decode
{{- end }}

{{- if .Values.service.exposeAdmin }}

WARNING: You made the Kong admin {{ if contains "ClusterIP" .Values.service.type }}accessible from other pods in the cluster{{ else }}externally accessible{{- end }}. We do not recommend this configuration in production. For accessing the admin, using pod port-forwarding or using the Kong Ingress Controller is preferred.
{{- end }}

{{ include "kong.validateValues" . }}
