mirror of
https://github.com/bitnami/charts.git
synced 2026-03-13 06:47:24 +08:00
54 lines
3.1 KiB
Plaintext
54 lines
3.1 KiB
Plaintext
{{- if contains .Values.service.type "LoadBalancer" }}
|
|
{{- if not .Values.postgresPassword }}
|
|
-------------------------------------------------------------------------------
|
|
WARNING
|
|
|
|
By specifying "serviceType=LoadBalancer" and not specifying "postgresqlPassword"
|
|
you have most likely exposed the PostgreSQL service externally without any
|
|
authentication mechanism.
|
|
|
|
For security reasons, we strongly suggest that you switch to "ClusterIP" or
|
|
"NodePort". As alternative, you can also specify a valid password on the
|
|
"postgresqlPassword" parameter.
|
|
|
|
-------------------------------------------------------------------------------
|
|
{{- end }}
|
|
{{- end }}
|
|
|
|
** Please be patient while the chart is being deployed **
|
|
|
|
PostgreSQL can be accessed via port 5432 on the following DNS name from within your cluster:
|
|
|
|
{{ template "postgresql.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local
|
|
|
|
To get the password for "{{ .Values.postgresqlUsername }}" run:
|
|
|
|
export POSTGRESQL_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "postgresql.fullname" . }} -o jsonpath="{.data.postgresql-password}" | base64 --decode)
|
|
|
|
To connect to your database run the following command:
|
|
|
|
kubectl run {{ template "postgresql.fullname" . }}-client --rm --tty -i --image bitnami/postgresql {{- if .Values.postgresqlPassword }}--env="PGPASSWORD={{ .Values.postgresqlPassword}}"{{- end }} --command -- psql --host {{ template "postgresql.fullname" . }} -U {{ .Values.postgresqlUsername }}
|
|
|
|
To connect to your database from outside the cluster execute the following commands:
|
|
|
|
{{- if contains "NodePort" .Values.service.type }}
|
|
|
|
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
|
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "postgresql.fullname" . }})
|
|
{{ if .Values.postgresqlPassword }}PGPASSWORD={{ .Values.postgresqlPassword}} "{{- end }}psql --host $NODE_IP --port $NODE_PORT -U {{ .Values.postgresqlUsername }}
|
|
|
|
{{- 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 "postgresql.fullname" . }}'
|
|
|
|
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "postgresql.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
|
|
{{ if .Values.postgresqlPassword }}PGPASSWORD={{ .Values.postgresqlPassword}} "{{- end }}psql --host $SERVICE_IP --port {{ .Values.service.port }} -U {{ .Values.postgresqlUsername }}
|
|
|
|
{{- else if contains "ClusterIP" .Values.service.type }}
|
|
|
|
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "postgresql.name" . }}" -o jsonpath="{.items[0].metadata.name}")
|
|
kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME 5432:5432 &
|
|
{{ if .Values.postgresqlPassword }}PGPASSWORD={{ .Values.postgresqlPassword}} "{{- end }}psql --host 127.0.0.1 -U {{ .Values.postgresqlUsername }}
|
|
|
|
{{- end }} |