Install postgres helm
postgres-values.yaml
nameOverride: postgres
fullnameOverride: postgres
auth:
username: userSql
password: MyPassword#
global:
postgresql:
auth:
postgresPassword: passAdmin
primary:
service:
type: NodePort
nodePorts:
postgresql: 30432
initdb:
scripts:
init.sql: |
CREATE DATABASE containers;
CREATE DATABASE accounts;
CREATE DATABASE routes;
Ensuite:
helm install postgres -f ./postgres-values.yaml oci://registry-1.docker.io/bitnamicharts/postgresql
Enfin
export NODE_IP=$(kubectl get nodes --namespace postgres -o jsonpath="{.items[0].status.addresses[0].address}")
export NODE_PORT=$(kubectl get --namespace postgres -o jsonpath="{.spec.ports[0].nodePort}" services postgres)
PGPASSWORD="$POSTGRES_PASSWORD" psql --host $NODE_IP --port $NODE_PORT -U appusepostgres-values.yaml r -d your_db_name