Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jerryshell/k8s-postgres-longhorn
K8s PostgreSQL Longhorn
https://github.com/jerryshell/k8s-postgres-longhorn
homelab k8s kubernetes longhorn postgresql
Last synced: 4 days ago
JSON representation
K8s PostgreSQL Longhorn
- Host: GitHub
- URL: https://github.com/jerryshell/k8s-postgres-longhorn
- Owner: jerryshell
- License: agpl-3.0
- Created: 2024-04-06T13:01:50.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-09-07T13:37:14.000Z (2 months ago)
- Last Synced: 2024-09-07T15:07:50.899Z (2 months ago)
- Topics: homelab, k8s, kubernetes, longhorn, postgresql
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# K8s PostgreSQL Longhorn
[K8s](https://kubernetes.io/) + [PostgreSQL](https://www.postgresql.org/) + [Longhorn](https://longhorn.io/)
## Install Longhorn
Environment Check Script
```bash
curl -sSfL https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/scripts/environment_check.sh | bash
```Installing open-iscsi
```bash
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/deploy/prerequisite/longhorn-iscsi-installation.yaml
```Installing NFSv4 client
```bash
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/deploy/prerequisite/longhorn-nfs-installation.yaml
```Installing Longhorn
```bash
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/v1.6.1/deploy/longhorn.yaml
```## Git clone
```bash
git clone https://github.com/jerryshell/k8s-postgres-longhorn.git
cd k8s-postgres-longhorn
```## ConfigMap
```bash
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
```bash
kubectl apply -f k8s/
```## Delete
```bash
kubectl delete --ignore-not-found=true -f k8s/ -f k8s/configmap/
```## Connect to PostgreSQL via kubectl
```bash
kubectl exec -it postgres-UUID -- psql -h localhost -U postgres --password -p 5432 postgres
```## Backup and Restore PostgreSQL Database
Backup
```bash
kubectl exec -it postgres-UUID -- pg_dump -U postgres -d postgres > db_backup.sql
```Restore
```bash
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](https://choosealicense.com/licenses/agpl-3.0/)