initial commit
This commit is contained in:
19
odroid/cnpg/README.md
Executable file
19
odroid/cnpg/README.md
Executable file
@@ -0,0 +1,19 @@
|
||||
#Installatie:
|
||||
============
|
||||
kubectl apply --server-side -f \
|
||||
https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.26/releases/cnpg-1.26.0.yaml
|
||||
#Cluster aanmaken:
|
||||
----------------
|
||||
|
||||
kubectl apply -f postgres15.yaml
|
||||
|
||||
#Monitoring
|
||||
-----------
|
||||
|
||||
kubectl create ns monitoring
|
||||
helm upgrade --install \
|
||||
-f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/docs/src/samples/monitoring/kube-stack-config.yaml \
|
||||
prometheus-community \
|
||||
prometheus-community/kube-prometheus-stack -n monitoring
|
||||
kubectl apply -n monitoring -f \
|
||||
https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/docs/src/samples/monitoring/prometheusrule.yaml
|
||||
11
odroid/cnpg/catalog-info.yaml
Normal file
11
odroid/cnpg/catalog-info.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: odroid-cnpg
|
||||
title: Cnpg (odroid)
|
||||
spec:
|
||||
type: service
|
||||
lifecycle: production
|
||||
owner: platform-team
|
||||
partOf:
|
||||
- ../catalog-info.yaml
|
||||
16082
odroid/cnpg/cnpg-1.23.2.yaml
Normal file
16082
odroid/cnpg/cnpg-1.23.2.yaml
Normal file
File diff suppressed because it is too large
Load Diff
6
odroid/cnpg/create-minio-secret.sh
Executable file
6
odroid/cnpg/create-minio-secret.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
microk8s kubectl delete secret minio-creds -n postgres
|
||||
microk8s kubectl create secret generic minio-creds \
|
||||
--from-literal=MINIO_ACCESS_KEY=Gudh6fKAlGv5PFWxLrCS \
|
||||
--from-literal=MINIO_SECRET_KEY=L2CxDKJAvXS2h0KyWWX3fu9twiVIzR1tZpoEYINl \
|
||||
--from-literal=REGION=us-east \
|
||||
-n postgres
|
||||
7
odroid/cnpg/examples/backup-example.yaml
Normal file
7
odroid/cnpg/examples/backup-example.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Backup
|
||||
metadata:
|
||||
name: pg-backup-example
|
||||
spec:
|
||||
cluster:
|
||||
name: pg-backup
|
||||
47
odroid/cnpg/examples/cluster-example-initdb-sql-refs.yaml
Normal file
47
odroid/cnpg/examples/cluster-example-initdb-sql-refs.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: post-init-sql-configmap
|
||||
data:
|
||||
configmap.sql: |
|
||||
create table configmaps (i integer);
|
||||
insert into configmaps (select generate_series(1,10000));
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: post-init-sql-secret
|
||||
stringData:
|
||||
secret.sql: |
|
||||
create table secrets (i integer);
|
||||
insert into secrets (select generate_series(1,10000));
|
||||
---
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: cluster-example-initdb
|
||||
spec:
|
||||
instances: 3
|
||||
|
||||
bootstrap:
|
||||
initdb:
|
||||
database: appdb
|
||||
owner: appuser
|
||||
postInitSQL:
|
||||
- create table numbers (i integer)
|
||||
- insert into numbers (select generate_series(1,10000))
|
||||
postInitTemplateSQL:
|
||||
- create extension intarray
|
||||
postInitApplicationSQL:
|
||||
- create table application_numbers (i integer)
|
||||
- insert into application_numbers (select generate_series(1,10000))
|
||||
postInitApplicationSQLRefs:
|
||||
configMapRefs:
|
||||
- name: post-init-sql-configmap
|
||||
key: configmap.sql
|
||||
secretRefs:
|
||||
- name: post-init-sql-secret
|
||||
key: secret.sql
|
||||
|
||||
storage:
|
||||
size: 1Gi
|
||||
25
odroid/cnpg/examples/cluster-pvc-template.yaml
Normal file
25
odroid/cnpg/examples/cluster-pvc-template.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: postgresql-pvc-template
|
||||
spec:
|
||||
instances: 3
|
||||
|
||||
# Example of rolling update strategy:
|
||||
# - unsupervised: automated update of the primary once all
|
||||
# replicas have been upgraded (default)
|
||||
# - supervised: requires manual supervision to perform
|
||||
# the switchover of the primary
|
||||
primaryUpdateStrategy: unsupervised
|
||||
|
||||
# Persistent storage configuration
|
||||
storage:
|
||||
size: 1Gi
|
||||
pvcTemplate:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
storageClassName: standard
|
||||
volumeMode: Filesystem
|
||||
32
odroid/cnpg/examples/cluster-storage-class-with-backup.yaml
Normal file
32
odroid/cnpg/examples/cluster-storage-class-with-backup.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: pg-backup
|
||||
spec:
|
||||
instances: 3
|
||||
|
||||
# Example of rolling update strategy:
|
||||
# - unsupervised: automated update of the primary once all
|
||||
# replicas have been upgraded (default)
|
||||
# - supervised: requires manual supervision to perform
|
||||
# the switchover of the primary
|
||||
primaryUpdateStrategy: unsupervised
|
||||
|
||||
# Persistent storage configuration
|
||||
storage:
|
||||
storageClass: standard
|
||||
size: 1Gi
|
||||
|
||||
# Backup properties
|
||||
backup:
|
||||
barmanObjectStore:
|
||||
destinationPath: s3://BUCKET_NAME/path/to/folder
|
||||
s3Credentials:
|
||||
accessKeyId:
|
||||
name: aws-creds
|
||||
key: ACCESS_KEY_ID
|
||||
secretAccessKey:
|
||||
name: aws-creds
|
||||
key: ACCESS_SECRET_KEY
|
||||
wal:
|
||||
compression: gzip
|
||||
6450
odroid/cnpg/monitoring/grafana-dashboard.json
Normal file
6450
odroid/cnpg/monitoring/grafana-dashboard.json
Normal file
File diff suppressed because it is too large
Load Diff
21
odroid/cnpg/monitoring/grafana-lb.yaml
Normal file
21
odroid/cnpg/monitoring/grafana-lb.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: grafana-lb
|
||||
namespace: monitoring
|
||||
spec:
|
||||
externalTrafficPolicy: Cluster
|
||||
internalTrafficPolicy: Cluster
|
||||
ipFamilies:
|
||||
- IPv4
|
||||
ports:
|
||||
- nodePort: 30093
|
||||
port: 3000
|
||||
protocol: TCP
|
||||
targetPort: 3000
|
||||
selector:
|
||||
app.kubernetes.io/instance: prometheus-community
|
||||
app.kubernetes.io/name: grafana
|
||||
type: LoadBalancer
|
||||
status:
|
||||
loadBalancer:
|
||||
8
odroid/cnpg/postgres13/backup.yaml
Normal file
8
odroid/cnpg/postgres13/backup.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Backup
|
||||
metadata:
|
||||
name: postgres13-backup
|
||||
namespace: postgres
|
||||
spec:
|
||||
cluster:
|
||||
name: postgres13
|
||||
50
odroid/cnpg/postgres13/create.yaml
Normal file
50
odroid/cnpg/postgres13/create.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: postgres13
|
||||
namespace: postgres
|
||||
spec:
|
||||
imageName: ghcr.io/cloudnative-pg/postgresql:13.14-3
|
||||
instances: 3
|
||||
superuserSecret:
|
||||
name: superuser-secret
|
||||
bootstrap:
|
||||
initdb:
|
||||
postInitSQL:
|
||||
- CREATE USER admin WITH PASSWORD 'Postgres01@'
|
||||
- ALTER USER admin WITH SUPERUSER
|
||||
- CREATE USER harbor WITH PASSWORD 'harbor'
|
||||
- CREATE DATABASE harbor OWNER harbor
|
||||
storage:
|
||||
size: 5Gi
|
||||
|
||||
monitoring:
|
||||
enablePodMonitor: true
|
||||
|
||||
backup:
|
||||
barmanObjectStore:
|
||||
destinationPath: 's3://backups/'
|
||||
endpointURL: 'http://minio.postgres:9000'
|
||||
s3Credentials:
|
||||
accessKeyId:
|
||||
name: minio-creds
|
||||
key: MINIO_ACCESS_KEY
|
||||
secretAccessKey:
|
||||
name: minio-creds
|
||||
key: MINIO_SECRET_KEY
|
||||
retentionPolicy: "1d"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres13-lb
|
||||
namespace: postgres
|
||||
spec:
|
||||
selector:
|
||||
cnpg.io/cluster: postgres13
|
||||
role: primary
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
type: LoadBalancer
|
||||
|
||||
46
odroid/cnpg/postgres13/recover1.yaml
Normal file
46
odroid/cnpg/postgres13/recover1.yaml
Normal file
@@ -0,0 +1,46 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: postgres13-1
|
||||
namespace: postgres
|
||||
spec:
|
||||
instances: 3
|
||||
imageName: ghcr.io/cloudnative-pg/postgresql:13.14-3
|
||||
|
||||
superuserSecret:
|
||||
name: superuser-secret
|
||||
|
||||
storage:
|
||||
size: 5Gi
|
||||
storageClass: nfs-client
|
||||
|
||||
monitoring:
|
||||
enablePodMonitor: true
|
||||
|
||||
backup:
|
||||
barmanObjectStore:
|
||||
destinationPath: 's3://backups/'
|
||||
endpointURL: 'http://minio.postgres:9000'
|
||||
s3Credentials:
|
||||
accessKeyId:
|
||||
name: minio-creds
|
||||
key: MINIO_ACCESS_KEY
|
||||
secretAccessKey:
|
||||
name: minio-creds
|
||||
key: MINIO_SECRET_KEY
|
||||
retentionPolicy: "1d"
|
||||
bootstrap:
|
||||
recovery:
|
||||
source: postgres13
|
||||
externalClusters:
|
||||
- name: postgres13
|
||||
barmanObjectStore:
|
||||
destinationPath: 's3://backups/'
|
||||
endpointURL: 'http://minio.postgres:9000'
|
||||
s3Credentials:
|
||||
accessKeyId:
|
||||
name: minio-creds
|
||||
key: MINIO_ACCESS_KEY
|
||||
secretAccessKey:
|
||||
name: minio-creds
|
||||
key: MINIO_SECRET_KEY
|
||||
46
odroid/cnpg/postgres13/recover2.yaml
Normal file
46
odroid/cnpg/postgres13/recover2.yaml
Normal file
@@ -0,0 +1,46 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: postgres13
|
||||
namespace: postgres
|
||||
spec:
|
||||
instances: 3
|
||||
imageName: ghcr.io/cloudnative-pg/postgresql:13.14-3
|
||||
|
||||
superuserSecret:
|
||||
name: superuser-secret
|
||||
|
||||
storage:
|
||||
size: 5Gi
|
||||
storageClass: nfs-client
|
||||
|
||||
monitoring:
|
||||
enablePodMonitor: true
|
||||
|
||||
backup:
|
||||
barmanObjectStore:
|
||||
destinationPath: 's3://backups/'
|
||||
endpointURL: 'http://minio.postgres:9000'
|
||||
s3Credentials:
|
||||
accessKeyId:
|
||||
name: minio-creds
|
||||
key: MINIO_ACCESS_KEY
|
||||
secretAccessKey:
|
||||
name: minio-creds
|
||||
key: MINIO_SECRET_KEY
|
||||
retentionPolicy: "1d"
|
||||
bootstrap:
|
||||
recovery:
|
||||
source: postgres13-1
|
||||
externalClusters:
|
||||
- name: postgres13-1
|
||||
barmanObjectStore:
|
||||
destinationPath: 's3://backups/'
|
||||
endpointURL: 'http://minio.postgres:9000'
|
||||
s3Credentials:
|
||||
accessKeyId:
|
||||
name: minio-creds
|
||||
key: MINIO_ACCESS_KEY
|
||||
secretAccessKey:
|
||||
name: minio-creds
|
||||
key: MINIO_SECRET_KEY
|
||||
9
odroid/cnpg/postgres13/schedulebackup.yaml
Normal file
9
odroid/cnpg/postgres13/schedulebackup.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: ScheduledBackup
|
||||
metadata:
|
||||
name: postgres13-backup
|
||||
spec:
|
||||
schedule: "0 0 14 * * *"
|
||||
backupOwnerReference: self
|
||||
cluster:
|
||||
name: postgres13
|
||||
8
odroid/cnpg/postgres14/backup.yaml
Normal file
8
odroid/cnpg/postgres14/backup.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Backup
|
||||
metadata:
|
||||
name: postgres14-backup
|
||||
namespace: postgres
|
||||
spec:
|
||||
cluster:
|
||||
name: postgres14
|
||||
50
odroid/cnpg/postgres14/create.yaml
Normal file
50
odroid/cnpg/postgres14/create.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
apiVersion: postgresql.cnpg.io/v1
|
||||
kind: Cluster
|
||||
metadata:
|
||||
name: postgres14
|
||||
namespace: postgres
|
||||
spec:
|
||||
imageName: ghcr.io/cloudnative-pg/postgresql:14.11-3
|
||||
instances: 3
|
||||
superuserSecret:
|
||||
name: superuser-secret
|
||||
bootstrap:
|
||||
initdb:
|
||||
postInitSQL:
|
||||
- CREATE USER admin WITH PASSWORD 'Postgres01@'
|
||||
- ALTER USER admin WITH SUPERUSER
|
||||
- CREATE USER harbor WITH PASSWORD 'harbor'
|
||||
- CREATE DATABASE harbor OWNER harbor
|
||||
storage:
|
||||
size: 5Gi
|
||||
|
||||
monitoring:
|
||||
enablePodMonitor: true
|
||||
|
||||
backup:
|
||||
barmanObjectStore:
|
||||
destinationPath: 's3://backups/'
|
||||
endpointURL: 'http://minio.postgres:9000'
|
||||
s3Credentials:
|
||||
accessKeyId:
|
||||
name: minio-creds
|
||||
key: MINIO_ACCESS_KEY
|
||||
secretAccessKey:
|
||||
name: minio-creds
|
||||
key: MINIO_SECRET_KEY
|
||||
retentionPolicy: "1d"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres14-lb
|
||||
namespace: postgres
|
||||
spec:
|
||||
selector:
|
||||
cnpg.io/cluster: postgres14
|
||||
role: primary
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
type: LoadBalancer
|
||||
|
||||
9
odroid/cnpg/script.sh
Executable file
9
odroid/cnpg/script.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
CLUSTER_NAME=postgres13
|
||||
NAMESPACE=postgres
|
||||
|
||||
PRIMARY=$(kubectl get cluster -n "$NAMESPACE" "$CLUSTER_NAME" -o jsonpath='{.status.currentPrimary}')
|
||||
for pvc in $(kubectl get pvc -n "$NAMESPACE" -l"cnpg.io/cluster=$CLUSTER_NAME" -o name); do
|
||||
ROLE=$([ "$pvc" = "persistentvolumeclaim/$PRIMARY" ] && echo primary || echo replica)
|
||||
kubectl label -n "$NAMESPACE" "$pvc" --overwrite "cnpg.io/instanceRole=$ROLE" "role=$ROLE"
|
||||
done
|
||||
kubectl delete pod -n "$NAMESPACE" -l "cnpg.io/cluster=$CLUSTER_NAME"
|
||||
8
odroid/cnpg/superuser-secret.yaml
Normal file
8
odroid/cnpg/superuser-secret.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
data:
|
||||
username: cG9zdGdyZXMK
|
||||
password: UG9zdGdyZXMwMUA=
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: superuser-secret
|
||||
type: kubernetes.io/basic-auth
|
||||
2
odroid/cnpg/tenant.txt
Normal file
2
odroid/cnpg/tenant.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
LyxDkhkSaQvoLUfb
|
||||
ew3h3CEilTbGu6rpGG918zl0LdnVP32s
|
||||
Reference in New Issue
Block a user