{{- $name := include "go-bananas.fullname" . }}

go-bananas {{ .Chart.AppVersion }} is deployed as {{ $name }} in namespace {{ .Release.Namespace }}.

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

Your instance is reachable at:

{{- range .Values.ingress.hosts }}
{{- $scheme := "http" }}
{{- if $.Values.ingress.tls }}{{ $scheme = "https" }}{{ end }}
{{- range $.Values.ingress.hosts }}
  {{ $scheme }}://{{ .host }}
{{- end }}
{{- break }}
{{- end }}

Follow the admin interface from there. Sign in with your identity provider.
{{- else if eq .Values.service.type "NodePort" }}

Your instance is on node port {{ .Values.service.nodePort }}. Find the address with:

  kubectl get nodes -o wide
  kubectl port-forward --address 0.0.0.0 svc/{{ $name }} 8080:{{ .Values.service.port }}
{{- else }}

Port-forward to reach the admin interface:

  kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ $name }} 8080:{{ .Values.service.port }}

Then open http://localhost:8080
{{- end }}

────────────────────────────────────────────────────────────────────────────
Runtime integration

{{- if eq .Values.identity.mode "oidc" }}

Consumers fetch themes with no dependency and no build step. Add this to any
application's <head>:

  <link rel="stylesheet"
        href="{{ include "go-bananas.publicUrl" . }}/rt/v1/theme.css?slug=midnight">

Full instructions are at {{ include "go-bananas.publicUrl" . }}/rt/v1/embed?slug=midnight

Available themes:

{{- $base := printf "%s/rt/v1" (include "go-bananas.publicUrl" .) }}
{{- $base }}{{ "/theme.css?slug=<slug>" }}
{{- $base }}{{ "/theme.json?slug=<slug>" }}
{{- $base }}{{ "/manifest.json" }}
{{- $base }}{{ "/runtime.js" }}    (framework-free ES module)
{{- $base }}{{ "/react.js" }}      (React provider and hooks)
{{- $base }}{{ "/embed.js" }}      (one-line script tag)
{{- else }}

Authentication is set to "{{ .Values.identity.mode }}". Every request is currently
treated as an administrator. Before exposing this to a network, set:

  identity.mode=oidc
  identity.oidc.issuer=https://auth.dev-urpi.be/realms/<realm>
  identity.oidc.clientId=go-bananas
  identity.oidc.existingSecret=<secret-name>
{{- end }}

────────────────────────────────────────────────────────────────────────────
Verify it is working

  kubectl --namespace {{ .Release.Namespace }} get pods -l app.kubernetes.io/instance={{ .Release.Name }}
  kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ $name }} 8080:{{ .Values.service.port }}
  curl -s localhost:{{ .Values.service.port }}/readyz
{{- if .Values.config.enableMetrics }}

  curl -s localhost:{{ .Values.service.port }}/metrics | head
{{- end }}

────────────────────────────────────────────────────────────────────────────
Notes

  * The database is a single SQLite file on a {{ .Values.persistence.type | default "disabled" }} volume
{{- if and .Values.persistence.enabled (eq .Values.persistence.type "persistentVolumeClaim") }}
    at {{ .Values.persistence.mountPath }}. It is retained on uninstall.
{{- end }}
  * {{ .Values.deployment.replicaCount }} replica(s). With a ReadWriteOnce volume, more than one
    replica needs a filesystem that permits concurrent mounts.
  * Built-in themes are reconciled at start-up. A built-in theme an operator has
    edited is never overwritten.
