munichpavel / expat-fatcat

Currency conversion automation for American tax-payers abroad.
MIT License
2 stars 0 forks source link

Add option of database data store #7

Open munichpavel opened 2 years ago

munichpavel commented 2 years ago

Probably better to start with localhost db, and only if happy move to containerized, k8s, etc ...

Resources

munichpavel commented 2 years ago

Experience log

from https://phoenixnap.com/kb/postgresql-kubernetes

(base) Pauls-MacBook-Air:expat-fatcat pauldev$ helm install psql-expat-fatcat bitnami/postgresql --set persistence.existingClaim=postgresql-pv-claim --set volumePermissions.enabled=true
NAME: psql-expat-fatcat
LAST DEPLOYED: Tue May 17 16:30:15 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: postgresql
CHART VERSION: 11.2.3
APP VERSION: 14.3.0

** Please be patient while the chart is being deployed **

PostgreSQL can be accessed via port 5432 on the following DNS names from within your cluster:

    psql-expat-fatcat-postgresql.default.svc.cluster.local - Read/Write connection

To get the password for "postgres" run:

    export POSTGRES_PASSWORD=$(kubectl get secret --namespace default psql-expat-fatcat-postgresql -o jsonpath="{.data.postgres-password}" | base64 --decode)

To connect to your database run the following command:

    kubectl run psql-expat-fatcat-postgresql-client --rm --tty -i --restart='Never' --namespace default --image docker.io/bitnami/postgresql:14.3.0-debian-10-r4 --env="PGPASSWORD=$POSTGRES_PASSWORD" \
      --command -- psql --host psql-expat-fatcat-postgresql -U postgres -d postgres -p 5432

    > 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 1001} does not exist"

To connect to your database from outside the cluster execute the following commands:

    kubectl port-forward --namespace default svc/psql-expat-fatcat-postgresql 5432:5432 &
    PGPASSWORD="$POSTGRES_PASSWORD" psql --host 127.0.0.1 -U postgres -d postgres -p 5432
munichpavel commented 2 years ago

or this

https://severalnines.com/database-blog/using-kubernetes-deploy-postgresql