homelab/kubernetes: cloudnative-pg how to copy existing db
- add documentation regarding how to copy existing DB using cloudnative-pg
This commit is contained in:
@ -512,7 +512,7 @@ kubectl get secret wildcard-cert-secret --namespace=cert-manager -o yaml \
|
|||||||
# The configMap contains the app.ini file values for gitea
|
# The configMap contains the app.ini file values for gitea
|
||||||
envsubst < gitea/configMap.yaml | kubectl apply -n gitea -f -
|
envsubst < gitea/configMap.yaml | kubectl apply -n gitea -f -
|
||||||
|
|
||||||
helm install gitea gitea-charts/gitea -f gitea/values.yaml \
|
helm upgrade --install gitea gitea-charts/gitea -f gitea/values.yaml \
|
||||||
--namespace gitea \
|
--namespace gitea \
|
||||||
--atomic \
|
--atomic \
|
||||||
--set ingress.hosts[0].host=$GITEA_HOST \
|
--set ingress.hosts[0].host=$GITEA_HOST \
|
||||||
@ -706,10 +706,21 @@ envsubst < cloud-native-pg/backup-recovery.yaml | kubectl apply -n immich -f -
|
|||||||
## Create a new PostgreSQL cluster from existing Database
|
## Create a new PostgreSQL cluster from existing Database
|
||||||
|
|
||||||
To create a new PostgreSQL cluster from an existing database, you can use the
|
To create a new PostgreSQL cluster from an existing database, you can use the
|
||||||
`create-cluster.yaml` template. This template allows you to create a new
|
`create-cluster-main.yaml` as template. This template allows you to create a new
|
||||||
PostgreSQL cluster from an existing database by specifying the necessary
|
PostgreSQL cluster from an existing database by specifying the necessary
|
||||||
configurations and parameters in the YAML file.
|
configurations and parameters in the YAML file.
|
||||||
|
|
||||||
|
This below example shows how I created a new PostgreSQL cluster from my existing
|
||||||
|
main postgres database. The new cluster is created in the `postgres` namespace.
|
||||||
|
The existing postgres database will be deprecated and removed in the future.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source .env
|
||||||
|
envsubst < cloud-native-pg/secrets.yaml | kubectl apply -n postgres -f -
|
||||||
|
envsubst < cloud-native-pg/create-cluster-main.yaml | kubectl apply -n postgres -f -
|
||||||
|
kubectl apply -f cloud-native-pg/pg-main-backup.yaml -n postgres
|
||||||
|
```
|
||||||
|
|
||||||
# Immich Self-hosted Photo and Video Backup Solution
|
# Immich Self-hosted Photo and Video Backup Solution
|
||||||
|
|
||||||
Immich is a self-hosted photo and video backup solution that is deployed in
|
Immich is a self-hosted photo and video backup solution that is deployed in
|
||||||
|
|||||||
49
kubernetes/cloud-native-pg/create-cluster-main.yaml
Normal file
49
kubernetes/cloud-native-pg/create-cluster-main.yaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
name: master-postgres
|
||||||
|
spec:
|
||||||
|
instances: 1
|
||||||
|
bootstrap:
|
||||||
|
initdb:
|
||||||
|
import:
|
||||||
|
type: monolith
|
||||||
|
databases:
|
||||||
|
- giteadb
|
||||||
|
- reservemaster
|
||||||
|
roles:
|
||||||
|
- gitea
|
||||||
|
- postgres
|
||||||
|
- taqi
|
||||||
|
source:
|
||||||
|
externalCluster: pg-main
|
||||||
|
storage:
|
||||||
|
size: 5Gi
|
||||||
|
storageClass: longhorn-2x
|
||||||
|
externalClusters:
|
||||||
|
- name: pg-main
|
||||||
|
connectionParameters:
|
||||||
|
host: 192.168.1.142
|
||||||
|
user: postgres
|
||||||
|
dbname: postgres
|
||||||
|
password:
|
||||||
|
name: my-postgres-postgresql
|
||||||
|
key: postgres-password
|
||||||
|
# Backup properties for MinIO
|
||||||
|
backup:
|
||||||
|
barmanObjectStore:
|
||||||
|
destinationPath: s3://pgmain
|
||||||
|
endpointURL: ${MINIO_ENDPOINT_URL}
|
||||||
|
s3Credentials:
|
||||||
|
accessKeyId:
|
||||||
|
name: minio-creds
|
||||||
|
key: ACCESS_KEY_ID
|
||||||
|
secretAccessKey:
|
||||||
|
name: minio-creds
|
||||||
|
key: ACCESS_SECRET_KEY
|
||||||
|
wal:
|
||||||
|
compression: gzip
|
||||||
|
data:
|
||||||
|
compression: gzip
|
||||||
|
retentionPolicy: "15d"
|
||||||
|
|
||||||
10
kubernetes/cloud-native-pg/pg-main-backup.yaml
Normal file
10
kubernetes/cloud-native-pg/pg-main-backup.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: ScheduledBackup
|
||||||
|
metadata:
|
||||||
|
name: pg-main-backup
|
||||||
|
spec:
|
||||||
|
immediate: true
|
||||||
|
schedule: "0 0 0 * * *" # At midnight every day
|
||||||
|
backupOwnerReference: self
|
||||||
|
cluster:
|
||||||
|
name: master-postgres
|
||||||
12
kubernetes/cloud-native-pg/pgmain-svc.yaml
Normal file
12
kubernetes/cloud-native-pg/pgmain-svc.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: pgmain-svc
|
||||||
|
spec:
|
||||||
|
type: LoadBalancer
|
||||||
|
ports:
|
||||||
|
- port: 5432
|
||||||
|
targetPort: 5432
|
||||||
|
selector:
|
||||||
|
cnpg.io/cluster: master-postgres
|
||||||
|
|
||||||
Reference in New Issue
Block a user