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/appsmith/entrypoint.sh /opt/bitnami/scripts/appsmith/run.sh

{{- else }}

Your Appsmith site can be accessed through the following DNS name from within your cluster:

    {{ include "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }} (port {{ .Values.client.service.ports.http }})

To access your Appsmith site from outside the cluster follow the steps below:

{{- if .Values.client.ingress.enabled }}

1. Get the Appsmith URL and associate Appsmith hostname to your cluster external IP:

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

{{- else }}
{{- $port := .Values.client.service.ports.http | toString }}

1. Get the Appsmith URL by running these commands:

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

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

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

   export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "common.names.fullname" . }} --include "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
   echo "Appsmith URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.client.service.ports.http }}{{ end }}/"
   echo "Appsmith Admin URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.client.service.ports.http }}{{ end }}/admin"

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

   kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "common.names.fullname" . }} {{ .Values.client.service.ports.http }}:{{ .Values.client.service.ports.http }} &
   echo "Appsmith URL: http://127.0.0.1{{- if ne $port "80" }}:{{ .Values.client.service.ports.http }}{{ end }}//"

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

2. Open a browser and access Appsmith using the obtained URL.

3. Login with the following credentials below to see your blog:

  echo Username: {{ .Values.backend.adminUser }}
  echo Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ include "appsmith.backend.fullname" . }} -o jsonpath="{.data.admin-password}" | base64 -d)
{{- end }}

{{- include "appsmith.validateValues" . }}
{{- include "common.warnings.rollingTag" .Values.image }}
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
{{- include "common.warnings.resources" (dict "sections" (list "backend" "client" "rts" "volumePermissions") "context" $) }}
