

{{ .Release.Name | camelcase }} with {{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }} has been deployed successfully on {{ template "formbricks.namespace" .}} namespace !

Here's how you can access and manage your deployment:
---

Accessing Your Application:

{{- if .Values.ingress.enabled }}
   Your application is accessible via the configured Ingress.
   ```sh
   kubectl get ingress {{ include "formbricks.name" . }} -n {{ .Release.Namespace }} -o jsonpath='{.items[*].spec.rules[*].host}' | tr ' ' '\n'
   ```
   Ensure that your DNS points to the cluster's Ingress Controller.
{{- else if contains "LoadBalancer" .Values.service.type }}
   Your application is exposed via a LoadBalancer.
   Run the following to get the external IP:
   ```sh
   kubectl get svc {{ include "formbricks.name" . }} -n {{ .Release.Namespace }}
   ```
{{- else if contains "NodePort" .Values.service.type }}
   Your application is accessible via NodePort.
   Run the following to get the assigned port:
   ```sh
   kubectl get svc {{ include "formbricks.name" . }} -n {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}"
   ```
   Then access the service at: `http://<NodeIP>:<NodePort>`
{{- else }}
   Your application is running inside the cluster (ClusterIP service type).
   To access it locally, run:
   ```sh
   kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "formbricks.name" . }} 3000
   ```
   Then visit: **http://localhost:3000**
{{- end }}

---

Database (PostgreSQL) Access:

{{- if .Values.postgresql.enabled }}
   PostgreSQL is deployed within your cluster.
   Retrieve the password using:
   ```sh
   kubectl get secret --namespace {{ .Release.Namespace }} {{ include "formbricks.name" . }}-app-secrets -o jsonpath="{.data.POSTGRES_USER_PASSWORD}" | base64 --decode
   ```
   Connection details:
   - **Host**: `{{ include "formbricks.name" . }}-postgresql`
   - **Port**: `5432`
   - **Database**: `{{ .Values.postgresql.auth.database }}`
   - **Username**: `{{ .Values.postgresql.auth.username }}`
{{- else if .Values.postgresql.externalDatabaseUrl }}
   You're using an external PostgreSQL database.
   Connection URL:
   ```sh
   echo "{{ .Values.postgresql.externalDatabaseUrl }}"
   ```
{{- end }}

---

Redis Access:

{{- if .Values.redis.enabled }}
   Redis is deployed within your cluster.
   Retrieve the password using:
   ```sh
   kubectl get secret --namespace {{ .Release.Namespace }} {{ include "formbricks.name" . }}-app-secrets -o jsonpath="{.data.REDIS_PASSWORD}" | base64 --decode
   ```
   Connection details:
   - **Host**: `{{ include "formbricks.name" . }}-redis-master`
   - **Port**: `6379`
{{- else if .Values.redis.externalRedisUrl }}
   You're using an external Redis instance.
   Connection URL:
   ```sh
   echo "{{ .Values.redis.externalRedisUrl }}"
   ```
{{- else }}
   Redis is not enabled in this deployment.
{{- end }}

---

Environment Variables:
The following environment variables have been configured:

- `WEBAPP_URL`: {{ .Values.formbricks.webappUrl }}
- `NEXTAUTH_URL`: {{ .Values.formbricks.webappUrl }}
{{- if .Values.formbricks.publicUrl }}
- `PUBLIC_URL`: {{ .Values.formbricks.publicUrl }}
{{- end }}
- `NEXTAUTH_SECRET`: A random 32-character string (auto-generated)
- `ENCRYPTION_KEY`: A random 32-character string (auto-generated)
- `CRON_SECRET`: A random 32-character string (auto-generated)
- `EMAIL_VERIFICATION_DISABLED`: 1 # By Default email verification is disabled, configure SMTP settings to enable(https://formbricks.com/docs/self-hosting/configuration/smtp)
- `PASSWORD_RESET_DISABLED`: 1 # By Default password reset is disabled, configure SMTP settings to enable(https://formbricks.com/docs/self-hosting/configuration/smtp)

Retrieve them using:
```sh
kubectl get secret --namespace {{ .Release.Namespace }} {{ include "formbricks.name" . }}-app-secrets -o jsonpath="{.data.NEXTAUTH_SECRET}" | base64 --decode
kubectl get secret --namespace {{ .Release.Namespace }} {{ include "formbricks.name" . }}-app-secrets -o jsonpath="{.data.ENCRYPTION_KEY}" | base64 --decode
kubectl get secret --namespace {{ .Release.Namespace }} {{ include "formbricks.name" . }}-app-secrets -o jsonpath="{.data.CRON_SECRET}" | base64 --decode	
```

---

Scaling:

{{- if .Values.autoscaling.enabled }}
   Horizontal Pod Autoscaling (HPA) is enabled.
   - **Min Replicas**: `{{ .Values.autoscaling.minReplicas }}`
   - **Max Replicas**: `{{ .Values.autoscaling.maxReplicas }}`

   Check HPA status:
   ```sh
   kubectl get hpa -n {{ .Release.Namespace }} {{ include "formbricks.name" . }}
   ```
{{- else }}
   HPA is **not enabled**. Your deployment has a fixed number of `{{ .Values.deployment.replicas }}` replicas.
   Manually scale using:
   ```sh
   kubectl scale deployment -n {{ .Release.Namespace }} {{ include "formbricks.name" . }} --replicas=<desired_number>
   ```
{{- end }}

---

Pod Disruption Budget:

{{- if .Values.pdb.enabled }}
   A PodDisruptionBudget is active to protect against voluntary disruptions.
   {{- if not (kindIs "invalid" .Values.pdb.minAvailable) }}
   - **Min Available**: `{{ .Values.pdb.minAvailable }}`
   {{- end }}
   {{- if not (kindIs "invalid" .Values.pdb.maxUnavailable) }}
   - **Max Unavailable**: `{{ .Values.pdb.maxUnavailable }}`
   {{- end }}

   Check PDB status:
   ```sh
   kubectl get pdb -n {{ .Release.Namespace }} {{ include "formbricks.name" . }}
   ```
   {{- if and .Values.autoscaling.enabled (eq (int .Values.autoscaling.minReplicas) 1) }}

   WARNING: autoscaling.minReplicas is 1. With minAvailable: 1, the PDB
   will block all node drains when only 1 replica is running. Set
   autoscaling.minReplicas to at least 2 for proper HA protection.
   {{- end }}
{{- else }}
   PDB is **not enabled**. Voluntary disruptions (node drains, upgrades) may
   take down all pods simultaneously.
{{- end }}

---

External Secrets:
{{- if .Values.externalSecret.enabled }}
   External secrets are enabled.
   Ensure that your `SecretStore` or `ClusterSecretStore` is configured properly.
   - Secret Store Name: `{{ .Values.externalSecret.secretStore.name }}`
   - Refresh Interval: `{{ .Values.externalSecret.refreshInterval }}`

   Verify the external secret:
   ```sh
   kubectl get externalsecrets -n {{ .Release.Namespace }}
   ```
{{- else }}
   External secrets are **not enabled**.
{{- end }}

---

Persistence:

{{- if .Values.postgresql.enabled }}
   PostgreSQL data is persisted with `{{ .Values.postgresql.primary.persistence.size }}` storage.
{{- end }}
{{- if .Values.redis.enabled }}
   Redis data is persisted with `{{ .Values.redis.master.persistence.size }}` storage..
{{- end }}

---

Formbricks Documentation and Support:

For more information, advanced configurations, and support, visit:
- **Official Website**: https://formbricks.com
- **Documentation**: https://formbricks.com/docs

For troubleshooting, refer to the documentation or community support.

---
