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

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

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

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

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

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

1. Get the WordPress URL by running these commands:

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

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

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

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

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

   kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "wordpress.fullname" . }} {{ .Values.service.port }}:{{ .Values.service.port }} &
   echo "WordPress URL: http://127.0.0.1{{- if ne $port "80" }}:{{ .Values.service.port }}{{ end }}//"
   echo "WordPress Admin URL: http://127.0.0.1{{- if ne $port "80" }}:{{ .Values.service.port }}{{ end }}//admin"

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

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

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

  echo Username: {{ .Values.wordpressUsername }}
  echo Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "wordpress.fullname" . }} -o jsonpath="{.data.wordpress-password}" | base64 --decode)

{{- if .Values.metrics.enabled }}

You can access Apache Prometheus metrics following the steps below:

1. Get the Apache Prometheus metrics URL by running:

    kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "wordpress.fullname" . }} {{ .Values.service.metricsPort }}:{{ .Values.service.metricsPort }} &
    echo "Apache Prometheus metrics URL: http://127.0.0.1:{{ .Values.service.metricsPort }}/metrics"

2. Open a browser and access Apache Prometheus metrics using the obtained URL.

{{- end }}

{{- include "wordpress.checkRollingTags" . }}
