github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/applications/postgresql/README.md (about) 1 # Overview 2 3 This image chooses OpenEBS LocalPV as its persistence storage engine. 4 5 Components included in this image: 6 7 * 1 StatefulSet replica for postgresql primary which requests "50Gi" storage. 8 * 1 StatefulSet replica for postgresql read which requests "50Gi" storage. 9 10 ## How to use it 11 12 PostgreSQL can be accessed via port 5432 on the following DNS names from within your cluster: 13 14 ``` 15 my-postgresql.postgresql-system.svc.cluster.local - Read/Write connection 16 my-postgresql-read.postgresql-system.svc.cluster.local - Read only connection 17 ``` 18 19 To get the password for "postgres" run: 20 21 ``` 22 export POSTGRES_PASSWORD=$(kubectl get secret --namespace postgresql-system my-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode) 23 ``` 24 25 To connect to your database run the following command: 26 27 ``` 28 kubectl run my-postgresql-client --rm --tty -i --restart='Never' --namespace postgresql-system --image docker.io/bitnami/postgresql:11.12.0-debian-10-r70 --env="PGPASSWORD=$POSTGRES_PASSWORD" --command -- psql --host my-postgresql -U postgres -d postgres -p 5432 29 ``` 30 31 To connect to your database from outside the cluster execute the following commands: 32 33 ``` 34 kubectl port-forward --namespace postgresql-system svc/my-postgresql 5432:5432 & PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -d postgres -p 5432 35 ``` 36 37 ## How to rebuild it use helm 38 39 Kubefile: 40 41 ```shell 42 FROM registry.cn-qingdao.aliyuncs.com/sealer-apps/openebs-localpv:2.11.0 43 # add helm repo and run helm install 44 RUN helm repo add bitnami https://charts.bitnami.com/bitnami 45 # set persistence.storageClass=local-hostpath, which is provided by base image openebs-localpv:2.11.0. 46 CMD helm install my-postgresql --create-namespace --namespace postgresql-system --set replication.enabled=true --set global.storageClass=local-hostpath bitnami/postgresql --version 10.9.4 47 ``` 48 49 run below command to build it 50 51 ```shell 52 sealer build -t {Your Image Name} -f Kubefile -m cloud . 53 ``` 54 55 More parameters see [official document here](https://artifacthub.io/packages/helm/bitnami/postgresql).