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

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

{{- $port := .Values.service.httpsPort | toString }}

1. Get the EJBCA URL by running these commands:

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

   export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[1].nodePort}" services {{ template "ejbca.fullname" . }})
   export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
   echo "EJBCA Public URL: https://$NODE_IP:$NODE_PORT/ejbca"
   echo "EJBCA Admin URL: https://$NODE_IP:$NODE_PORT/ejbca/adminweb"
   echo "EJBCA Enrol URL: https://$NODE_IP:$NODE_PORT/ejbca/enrol/keystore.jsp"


{{- else if contains "LoadBalancer" .Values.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 {{ template "ejbca.fullname" . }}'

   export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "ejbca.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
   echo "EJBCA Public URL: https://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.service.httpsPort }}{{ end }}/ejbca"
   echo "EJBCA Admin URL: https://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.service.httpsPort }}{{ end }}/ejbca/adminweb"
   echo "EJBCA Enrol URL: https://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.service.httpsPort }}{{ end }}/ejbca/enrol/keystore.jsp"


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

   kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "ejbca.fullname" . }} {{ .Values.service.httpsPort }}:{{ .Values.service.httpsPort }} &
   echo "EJBCA Public URL: https://127.0.0.1{{- if ne $port "80" }}:{{ .Values.service.httpsPort }}{{ end }}/ejbca"
   echo "EJBCA Admin URL: https://127.0.0.1{{- if ne $port "80" }}:{{ .Values.service.httpsPort }}{{ end }}/ejbca/adminweb"
   echo "EJBCA Enrol URL: https://127.0.0.1{{- if ne $port "80" }}:{{ .Values.service.httpsPort }}{{ end }}/ejbca/enrol/keystore.jsp"

{{- end }}

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

3. In order to be able to log in to the Admin Portal, you first need to enrol and import the generated certificate in your Browser:
  export EJBCA_ADMIN_USERNAME={{ .Values.ejbcaAdminUsername }}
  export EJBCA_ADMIN_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "ejbca.secretName" . }} -o jsonpath="{.data.ejbca-admin-password}" | base64 --decode)
  echo Username: $EJBCA_ADMIN_USERNAME
  echo Password: $EJBCA_ADMIN_PASSWORD

4. You can access the DB using the following password:
  export APP_DATABASE_PASSWORD=$(kubectl get secret --namespace default {{ include "ejbca.databaseSecretName" . }} -o jsonpath="{.data.mariadb-password}" | base64 --decode)
