Skip to content

jerryshell/k8s-postgres-longhorn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

K8s PostgreSQL Longhorn

K8s + PostgreSQL + Longhorn

Install Longhorn

Environment Check Script

curl -sSfL https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/scripts/environment_check.sh | bash

Installing open-iscsi

kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/deploy/prerequisite/longhorn-iscsi-installation.yaml

Installing NFSv4 client

kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/deploy/prerequisite/longhorn-nfs-installation.yaml

Installing Longhorn

kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/deploy/longhorn.yaml

Git clone

git clone https://github.com/jerryshell/k8s-postgres-longhorn.git
cd k8s-postgres-longhorn

ConfigMap

export POSTGRES_DB=postgres
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=your_password
cat k8s/configmap/configmap.yaml | envsubst | kubectl apply -f -

PVC + Deployment + Service

kubectl apply -f k8s/

Delete

kubectl delete --ignore-not-found=true -f k8s/ -f k8s/configmap/

Connect to PostgreSQL via kubectl

kubectl exec -it postgres-UUID -- psql -h localhost -U postgres --password -p 5432 postgres

Backup and Restore PostgreSQL Database

Backup

kubectl exec -it postgres-UUID -- pg_dump -U postgres -d postgres > db_backup.sql

Restore

kubectl cp db_backup.sql postgres-UUID:/tmp/db_backup.sql
kubectl exec -it postgres-UUID -- /bin/bash
psql -U postgres -d postgres -f /tmp/db_backup.sql

LICENSE

GNU Affero General Public License v3.0

Releases

No releases published

Packages

No packages published