|
1 | | -1. Get the application URL by running these commands: |
2 | | -{{- if .Values.ingress.enabled }} |
3 | | -{{- range $host := .Values.ingress.hosts }} |
4 | | - {{- range .paths }} |
5 | | - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} |
6 | | - {{- end }} |
| 1 | +CHART NAME: {{ .Chart.Name }} |
| 2 | +CHART VERSION: {{ .Chart.Version }} |
| 3 | +APP VERSION: {{ .Chart.AppVersion }} |
| 4 | + |
| 5 | +** Please be patient while the chart is being deployed ** |
| 6 | + |
| 7 | +{{- if .Values.diagnosticMode.enabled }} |
| 8 | +The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with: |
| 9 | + |
| 10 | + command: {{- include "common-v1.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }} |
| 11 | + args: {{- include "common-v1.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }} |
| 12 | + |
| 13 | +Get the list of pods by executing: |
| 14 | + |
| 15 | + kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }} |
| 16 | + |
| 17 | +Access the pod you want to debug by executing |
| 18 | + |
| 19 | + kubectl exec --namespace {{ .Release.Namespace }} -ti <NAME OF THE POD> -- /opt/bitnami/scripts/postgresql/entrypoint.sh /bin/bash |
| 20 | + |
| 21 | +In order to replicate the container startup scripts execute this command: |
| 22 | + |
| 23 | + /opt/bitnami/scripts/postgresql/entrypoint.sh /opt/bitnami/scripts/postgresql/run.sh |
| 24 | + |
| 25 | +{{- else }} |
| 26 | + |
| 27 | +PostgreSQL can be accessed via port {{ include "postgresql.service.port" . }} on the following DNS names from within your cluster: |
| 28 | + |
| 29 | + {{ include "postgresql.primary.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local - Read/Write connection |
| 30 | + |
| 31 | +{{- if eq .Values.architecture "replication" }} |
| 32 | + |
| 33 | + {{ include "postgresql.readReplica.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local - Read only connection |
| 34 | + |
7 | 35 | {{- end }} |
8 | | -{{- else if contains "NodePort" .Values.service.type }} |
9 | | - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "postgresql.fullname" . }}) |
10 | | - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") |
11 | | - echo http://$NODE_IP:$NODE_PORT |
12 | | -{{- else if contains "LoadBalancer" .Values.service.type }} |
13 | | - NOTE: It may take a few minutes for the LoadBalancer IP to be available. |
14 | | - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "postgresql.fullname" . }}' |
15 | | - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "postgresql.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") |
16 | | - echo http://$SERVICE_IP:{{ .Values.service.port }} |
17 | | -{{- else if contains "ClusterIP" .Values.service.type }} |
18 | | - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "postgresql.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") |
19 | | - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") |
20 | | - echo "Visit http://127.0.0.1:8080 to use your application" |
21 | | - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT |
| 36 | + |
| 37 | +{{- $customUser := include "postgresql.username" . }} |
| 38 | +{{- if and (not (empty $customUser)) (ne $customUser "postgres") .Values.auth.enablePostgresUser }} |
| 39 | + |
| 40 | +To get the password for "postgres" run: |
| 41 | + |
| 42 | + export POSTGRES_ADMIN_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ include "postgresql.secretName" . }} -o jsonpath="{.data.postgres-password}" | base64 -d) |
| 43 | + |
| 44 | +To get the password for "{{ $customUser }}" run: |
| 45 | + |
| 46 | + export POSTGRES_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ include "postgresql.secretName" . }} -o jsonpath="{.data.password}" | base64 -d) |
| 47 | + |
| 48 | +{{- else }} |
| 49 | + |
| 50 | +To get the password for "{{ default "postgres" $customUser }}" run: |
| 51 | + |
| 52 | + export POSTGRES_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ include "postgresql.secretName" . }} -o jsonpath="{.data.{{ ternary "password" "postgres-password" (and (not (empty $customUser)) (ne $customUser "postgres")) }}}" | base64 -d) |
| 53 | + |
22 | 54 | {{- end }} |
| 55 | + |
| 56 | +To connect to your database run the following command: |
| 57 | + |
| 58 | + kubectl run {{ include "common-v1.names.fullname" . }}-client --rm --tty -i --restart='Never' --namespace {{ .Release.Namespace }} --image {{ include "postgresql.image" . }} --env="PGPASSWORD=$POSTGRES_PASSWORD" \ |
| 59 | + --command -- psql --host {{ include "postgresql.primary.fullname" . }} -U {{ default "postgres" $customUser }} -d {{- if include "postgresql.database" . }} {{ include "postgresql.database" . }}{{- else }} postgres{{- end }} -p {{ include "postgresql.service.port" . }} |
| 60 | + |
| 61 | + > NOTE: If you access the container using bash, make sure that you execute "/opt/bitnami/scripts/postgresql/entrypoint.sh /bin/bash" in order to avoid the error "psql: local user with ID {{ .Values.primary.containerSecurityContext.runAsUser }}} does not exist" |
| 62 | + |
| 63 | +To connect to your database from outside the cluster execute the following commands: |
| 64 | + |
| 65 | +{{- if contains "NodePort" .Values.primary.service.type }} |
| 66 | + |
| 67 | + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") |
| 68 | + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "postgresql.primary.fullname" . }}) |
| 69 | + PGPASSWORD="$POSTGRES_PASSWORD" psql --host $NODE_IP --port $NODE_PORT -U {{ default "postgres" $customUser }} -d {{- if include "postgresql.database" . }} {{ include "postgresql.database" . }}{{- else }} postgres{{- end }} |
| 70 | + |
| 71 | +{{- else if contains "LoadBalancer" .Values.primary.service.type }} |
| 72 | + |
| 73 | + NOTE: It may take a few minutes for the LoadBalancer IP to be available. |
| 74 | + Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ include "postgresql.primary.fullname" . }}' |
| 75 | + |
| 76 | + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "postgresql.primary.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}") |
| 77 | + PGPASSWORD="$POSTGRES_PASSWORD" psql --host $SERVICE_IP --port {{ include "postgresql.service.port" . }} -U {{ default "postgres" $customUser }} -d {{- if include "postgresql.database" . }} {{ include "postgresql.database" . }}{{- else }} postgres{{- end }} |
| 78 | + |
| 79 | +{{- else if contains "ClusterIP" .Values.primary.service.type }} |
| 80 | + |
| 81 | + kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ include "postgresql.primary.fullname" . }} {{ include "postgresql.service.port" . }}:{{ include "postgresql.service.port" . }} & |
| 82 | + PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U {{ default "postgres" $customUser }} -d {{- if include "postgresql.database" . }} {{ include "postgresql.database" . }}{{- else }} postgres{{- end }} -p {{ include "postgresql.service.port" . }} |
| 83 | + |
| 84 | +{{- end }} |
| 85 | +{{- end }} |
| 86 | + |
| 87 | +{{- include "postgresql.validateValues" . -}} |
| 88 | +{{- include "common-v1.warnings.rollingTag" .Values.image -}} |
| 89 | +{{- include "common-v1.warnings.rollingTag" .Values.volumePermissions.image }} |
0 commit comments