1 # PostgreSQL can be accessed via port 5432 on the following DNS name from within your cluster:
2 # {{ template "postgresql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
4 # To get your user password run:
6 # PGPASSWORD=$(kubectl get secret --namespace {{ .Values.global.nsPrefix }} {{ template "postgresql.fullname" . }} -o jsonpath="{.data.postgres-password}" | base64 --decode; echo)
8 # To connect to your database run the following command (using the env variable from above):
10 # kubectl run --namespace {{ .Values.global.nsPrefix }} {{ template "postgresql.fullname" . }}-client --restart=Never --rm --tty -i --image postgres \
11 # --env "PGPASSWORD=$PGPASSWORD" \{{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
12 # --labels="{{ template "postgresql.fullname" . }}-client=true" \{{- end }}
13 # --command -- psql -U {{ default "postgres" .Values.postgresUser }} \
14 # -h {{ template "postgresql.fullname" . }} {{ default "postgres" .Values.postgresDatabase }}
16 # {{ if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
17 # Note: Since NetworkPolicy is enabled, only pods with label
18 # {{ template "postgresql.fullname" . }}-client=true"
19 # will be able to connect to this PostgreSQL cluster.
22 # To connect to your database directly from outside the K8s cluster:
23 # {{- if contains "NodePort" .Values.service.type }}
24 # PGHOST=$(kubectl get nodes --namespace {{ .Values.global.nsPrefix }} -o jsonpath='{.items[0].status.addresses[0].address}')
25 # PGPORT=$(kubectl get svc --namespace {{ .Values.global.nsPrefix }} {{ template "postgresql.fullname" . }} -o jsonpath='{.spec.ports[0].nodePort}')
27 # {{- else if contains "ClusterIP" .Values.service.type }}
29 # PGPORT={{ default "5432" .Values.service.port }}
31 # # Execute the following commands to route the connection:
32 # export POD_NAME=$(kubectl get pods --namespace {{ .Values.global.nsPrefix }} -l "app={{ template "postgresql.fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
33 # kubectl port-forward --namespace {{ .Values.global.nsPrefix }} $POD_NAME {{ default "5432" .Values.service.port }}:{{ default "5432" .Values.service.port }}