Congratulations. You have just deployed JFrog Artifactory HA!

{{- if and (not .Values.artifactory.masterKeySecretName) (eq .Values.artifactory.masterKey "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") }}


***************************************** WARNING ******************************************
* Your Artifactory master key is still set to the provided example:                        *
* artifactory.masterKey=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF   *
*                                                                                          *
* You should change this to your own generated key:                                        *
* $ export MASTER_KEY=$(openssl rand -hex 32)                                              *
* $ echo ${MASTER_KEY}                                                                     *
*                                                                                          *
* Pass the created master key to helm with '--set artifactory.masterKey=${MASTER_KEY}'     *
*                                                                                          *
* Alternatively, you can use a pre-existing secret with a key called master-key with       *
* '--set artifactory.masterKeySecretName=${SECRET_NAME}'                                   *
********************************************************************************************
{{- end }}

{{ if eq .Values.artifactory.joinKey "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" }}


***************************************** WARNING ******************************************
* Your Artifactory join key is still set to the provided example:                          *
* artifactory.joinKey=EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE                                     *
*                                                                                          *
* You should change this to your own generated key:                                        *
* $ export JOIN_KEY=$(openssl rand -hex 16)                                                *
* $ echo ${JOIN_KEY}                                                                       *
*                                                                                          *
* Pass the created master key to helm with '--set artifactory.joinKey=${JOIN_KEY}'         *
*                                                                                          *
********************************************************************************************
{{- end }}

{{- if .Values.postgresql.enabled }}

DATABASE:
To extract the database password, run the following
export DB_PASSWORD=$(kubectl get --namespace {{ .Release.Namespace }} $(kubectl get secret --namespace {{ .Release.Namespace }} -o name | grep postgresql) -o jsonpath="{.data.postgresql-password}" | base64 --decode)
echo ${DB_PASSWORD}
{{- end }}

SETUP:
1. Get the Artifactory IP and URL

   {{- if contains "NodePort" .Values.nginx.service.type }}
   export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "artifactory-ha.nginx.fullname" . }})
   export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
   echo http://$NODE_IP:$NODE_PORT/

   {{- else if contains "LoadBalancer" .Values.nginx.service.type }}
   NOTE: It may take a few minutes for the LoadBalancer public IP to be available!

   You can watch the status of the service by running 'kubectl get svc -w {{ template "artifactory-ha.nginx.fullname" . }}'
   export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "artifactory-ha.nginx.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
   echo http://$SERVICE_IP/

   {{- else if contains "ClusterIP" .Values.nginx.service.type }}
   export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "component={{ .Values.nginx.name }}" -o jsonpath="{.items[0].metadata.name}")
   kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME 8080:80
   echo http://127.0.0.1:8080

   {{- end }}

2. Open Artifactory in your browser
   Default credential for Artifactory:
   user:     admin
   password: password

   {{- if .Values.artifactory.license.secret }}

3. Manage Artifactory license through the {{ .Values.artifactory.license.secret }} secret ONLY!
   Since the artifactory license(s) is managed with a secret ({{ .Values.artifactory.license.secret }}), any change through the Artifactory UI might not be saved!

   {{- else }}

3. Add HA licenses to activate Artifactory HA through the Artifactory UI
   NOTE: Each Artifactory node requires a valid license. See https://www.jfrog.com/confluence/display/RTF/HA+Installation+and+Setup for more details.

   {{- end }}

{{ if or .Values.artifactory.primary.javaOpts.jmx.enabled .Values.artifactory.node.javaOpts.jmx.enabled }}
JMX configuration:
{{- if not (contains "LoadBalancer"  .Values.artifactory.service.type) }}
If you want to access JMX from you computer with jconsole, you should set ".Values.artifactory.service.type=LoadBalancer" !!!
{{ end }}

1. Get the Artifactory service IP:
{{- if .Values.artifactory.primary.javaOpts.jmx.enabled }}
export PRIMARY_SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "artifactory-ha.primary.name" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
{{- end }}
{{- if .Values.artifactory.node.javaOpts.jmx.enabled }}
export MEMBER_SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "artifactory-ha.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
{{- end }}

2. Map the service name to the service IP in /etc/hosts:
{{- if .Values.artifactory.primary.javaOpts.jmx.enabled }}
sudo sh -c "echo \"${PRIMARY_SERVICE_IP}    {{ template "artifactory-ha.primary.name" . }}\" >> /etc/hosts"
{{- end }}
{{- if .Values.artifactory.node.javaOpts.jmx.enabled }}
sudo sh -c "echo \"${MEMBER_SERVICE_IP}    {{ template "artifactory-ha.fullname" . }}\" >> /etc/hosts"
{{- end }}

3. Launch jconsole:
{{- if .Values.artifactory.primary.javaOpts.jmx.enabled }}
jconsole {{ template "artifactory-ha.primary.name" . }}:{{ .Values.artifactory.primary.javaOpts.jmx.port }}
{{- end }}
{{- if .Values.artifactory.node.javaOpts.jmx.enabled }}
jconsole {{ template "artifactory-ha.fullname" . }}:{{ .Values.artifactory.node.javaOpts.jmx.port }}
{{- end }}
{{- end }}
