CHART NAME: {{ .Chart.Name }}
CHART VERSION: {{ .Chart.Version }}
APP VERSION: {{ .Chart.AppVersion }}

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

{{- if .Values.diagnosticMode.enabled }}

The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:

  command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
  args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}

Get the list of pods by executing:

  kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }}

Access the pod you want to debug by executing

  kubectl exec --namespace {{ .Release.Namespace }} -ti <NAME OF THE POD> -- bash

In order to replicate the container startup scripts execute this command:

    /opt/bitnami/scripts/kong/entrypoint.sh /opt/bitnami/scripts/kong/run.sh

{{- else }}
{{- $proxyPort := coalesce .Values.service.ports.proxyHttp .Values.service.proxyHttpPort | toString }}
{{- $adminPort := coalesce .Values.service.ports.adminHttp .Values.service.adminHttpPort | toString }}
{{- if .Values.ingress.enabled }}

Get the Kong proxy URL and associate its hostname to your cluster external IP:

   export CLUSTER_IP=$(minikube ip) # On Minikube. Use: `kubectl cluster-info` on others K8s clusters
   echo "Kong proxy URL: http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.hostname }}"
   echo "$CLUSTER_IP  {{ .Values.ingress.hostname }}" | sudo tee -a /etc/hosts

{{- 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 "common.names.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 "common.names.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 "common.names.fullname" . }}'

Access the Kong proxy by using the following commands:

    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo http://$SERVICE_IP:{{ $proxyPort }}

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

Access the Kong admin by using the following commands:

    export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
    echo http://$SERVICE_IP:{{ $adminPort }}

    {{- end }}
{{- 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 "common.names.fullname" . }} 8080:{{ $proxyPort }} &

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

Access the Kong admin by using the following commands:

    echo "Browse to http://127.0.0.1:8001"
    kubectl port-forward svc/{{ include "common.names.fullname" . }} 8080:{{ $adminPort }} &

    {{- 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 }}

{{- include "common.warnings.rollingTag" .Values.image }}
{{- if .Values.ingressController.enabled }}
{{- include "common.warnings.rollingTag" .Values.ingressController.image }}
{{- end }}

{{- $passwordValidationErrors := list }}

If you want to upgrade the installation you will need to re-set the database credentials. Execute the following command
{{- if ne .Values.database "postgresql" }}
  {{- $dbSecretName := include "kong.cassandra.secretName" . -}}
  {{- $dbPasswordValidationErrors := include "common.validations.values.cassandra.passwords" (dict "secret" $dbSecretName "subchart" true "context" $) -}}
  {{- $passwordValidationErrors = append $passwordValidationErrors $dbPasswordValidationErrors -}}

  kubectl get secret --namespace {{ .Release.Namespace }} {{ include "kong.cassandra.secretName" . }} -o jsonpath="{.data.cassandra-password}" | base64 -d
{{- 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" . }}
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $) -}}
{{- end }}
