Skip to content

Commit

Permalink
Merge pull request #39 from radondb/main-split-crd
Browse files Browse the repository at this point in the history
Split code and backup
  • Loading branch information
zlianzhuang authored Jul 10, 2023
2 parents f3fc6b2 + 212e2e2 commit 95270ce
Show file tree
Hide file tree
Showing 34 changed files with 13,450 additions and 6,127 deletions.
32 changes: 28 additions & 4 deletions docs/index.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
apiVersion: v1
entries:
postgres-operator:
- apiVersion: v2
appVersion: v1.2.2
created: "2023-07-10T18:00:06.076836159+08:00"
description: A Helm chart for Kubernetes
digest: 785fb632e2206a16d2c1bd94bab89e5654597db24a440e031fe2a5f9bc26fbc7
home: https://github.com/radondb/multi-platform-postgresql
keywords:
- operator
- postgresql
- database
maintainers:
- email: lianzhuangzhang@yunify.com
name: lzzhang
url: https://lzzhang.github.io/
- email: yanbo2695388808@gmail.com
name: yanboer
url: https://yanboer.github.io/
name: postgres-operator
sources:
- https://github.com/radondb/multi-platform-postgresql
type: application
urls:
- https://radondb.github.io/multi-platform-postgresql/postgres-operator-v1.2.2.tgz
version: v1.2.2
- apiVersion: v2
appVersion: v1.2.0
created: "2023-03-10T02:31:26.692586189Z"
created: "2023-07-10T18:00:06.076520032+08:00"
description: A Helm chart for Kubernetes
digest: 8d1a597a8c52041b8d9d391188d4749abe00f3083e31036000edb0c15975df4e
home: https://github.com/radondb/multi-platform-postgresql
Expand All @@ -27,7 +51,7 @@ entries:
version: v1.2.0
- apiVersion: v2
appVersion: v1.1.1
created: "2023-03-10T02:31:26.69224208Z"
created: "2023-07-10T18:00:06.076189672+08:00"
description: A Helm chart for Kubernetes
digest: 4a536a53eed956e2cf28ffe2addf0625031de1f2581ce40884be94490923d5a2
home: https://github.com/radondb/multi-platform-postgresql
Expand All @@ -51,7 +75,7 @@ entries:
version: v1.0.1
- apiVersion: v2
appVersion: v1.1.0
created: "2023-03-10T02:31:26.69186987Z"
created: "2023-07-10T18:00:06.075585156+08:00"
description: A Helm chart for Kubernetes
digest: 1f6593413ae373c5caa7b8c41a3cd3697fbb164ba417260a3fefa6d32a1852e8
home: https://github.com/radondb/multi-platform-postgresql
Expand All @@ -73,4 +97,4 @@ entries:
urls:
- https://radondb.github.io/multi-platform-postgresql/postgres-operator-v1.0.0.tgz
version: v1.0.0
generated: "2023-03-10T02:31:26.691088749Z"
generated: "2023-07-10T18:00:06.074407851+08:00"
Binary file added docs/postgres-operator-v1.2.2.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions helmversions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"appVersion": "v1.2.0",
"version": "v1.2.0",
"appVersion": "v1.2.2",
"version": "v1.2.2",

"template_name": "radondb-postgres-operator",
"template_image": "radondb/radondb-postgres-operator:v1.2.0",
Expand Down
17 changes: 11 additions & 6 deletions image/postgresql/pgtools
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function s3_backup() {
check_and_set_backup_param
fi
if [ $role == "$ROLE_MASTER" ]; then
backup_cmd="barman-cloud-backup -h 127.0.0.1 -p $run_port --immediate-checkpoint $(eval $BARMAN_S3_PARAM)"
backup_cmd="barman-cloud-backup -h 127.0.0.1 -p $run_port --name $BARMAN_BACKUP_ALIAS_NAME --immediate-checkpoint $(eval $BARMAN_S3_PARAM)"
backup_cmd=$(add_s3_param "$backup_cmd")
$backup_cmd
check_error $? "backup failed, please check error log"
Expand Down Expand Up @@ -407,18 +407,23 @@ function get_backup_info_or_backup_size() {
fi
}

#function delete_backup_by_id() {
# backupid=$1
# barman-cloud-backup-delete $(eval $BARMAN_S3_PARAM) --backup-id $backupid
#}
function delete_backup_by_id() {
# backup_id is comma separated
for id in $(echo ${backup_id} | tr ',' ' '); do
barman-cloud-backup-delete $(eval $BARMAN_S3_PARAM) --backup-id $id
done
}

function delete_backup_by_policy() {
barman-cloud-backup-delete $(eval $BARMAN_S3_PARAM) --retention-policy "$retention"
}

function delete_backup() {
check_and_generate_s3_profile
if [ ! "$retention" -o "$retention" == "none" ]; then
if [ "${backup_id}" ]; then
delete_backup_by_id
check_error $? "delete_backup ${backup_id} maybe not completed, please check error log"
elif [ ! "$retention" -o "$retention" == "none" ]; then
check_error 1 "delete_backup but retention env is not set or retention is none."
elif [ "$retention" == "$BARMAN_RENTION_DELETE_ALL" ]; then
param=$(get_aws_param)
Expand Down
2 changes: 1 addition & 1 deletion operatorversions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"clusterrolebinding": "radondb-postgres-operator-rolebinding-cluster",
"rolebinding": "radondb-postgres-operator-rolebinding-role",
"name": "radondb-postgres-operator",
"image": "radondb/radondb-postgres-operator:v1.2.1",
"image": "radondb/radondb-postgres-operator:v1.2.2",
"datapath": "/data",
"imageRegistry": "",
"namespaceOverride": ""
Expand Down
8 changes: 4 additions & 4 deletions pgversions.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"pgaudit": "1.4.3",
"postgres_aws_s3": "v1.0.0",
"name": "radondb-postgresql",
"version": "v1.2.1",
"version": "v1.2.2",
"arches": [
"aarch64",
"x86_64"
Expand All @@ -31,7 +31,7 @@
"pgaudit": "1.5.2",
"postgres_aws_s3": "v1.0.0",
"name": "radondb-postgresql",
"version": "v1.2.1",
"version": "v1.2.2",
"arches": [
"aarch64",
"x86_64"
Expand All @@ -50,7 +50,7 @@
"pgaudit": "1.6.2",
"postgres_aws_s3": "v1.0.0",
"name": "radondb-postgresql",
"version": "v1.2.1",
"version": "v1.2.2",
"arches": [
"aarch64",
"x86_64"
Expand All @@ -69,7 +69,7 @@
"pgaudit": "1.7.0",
"postgres_aws_s3": "v1.0.0",
"name": "radondb-postgresql",
"version": "v1.2.1",
"version": "v1.2.2",
"arches": [
"aarch64",
"x86_64"
Expand Down
127 changes: 122 additions & 5 deletions platforms/kubernetes/postgres-operator/deploy/postgres-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,123 @@ spec:
type: string

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: postgresqlbackups.postgres.radondb.io
namespace: radondb-postgres-operator
spec:
group: postgres.radondb.io
names:
kind: PostgreSQLBackup
listKind: PostgreSQLBackupList
plural: postgresqlbackups
singular: postgresqlbackup
shortNames:
- pgb
scope: Namespaced
versions:
- name: v1
served: true
storage: true
additionalPrinterColumns:
- jsonPath: .status.state
description: The postgresql cluster status
name: State
type: string
priority: 0
- jsonPath: .status.beginTime
description: Backup begin time
name: BeginTime
type: string
priority: 0
- jsonPath: .status.endTime
description: Backup end time
name: EndTime
type: string
priority: 0
- jsonPath: .status.backupId
description: Backup id
name: BackupId
type: string
priority: 0
- jsonPath: .status.backupSize
description: Backup size
name: BackupSize
type: string
priority: 0
- jsonPath: .status.backupBeginWal
description: Backup begin wal
name: BackupBeginWal
type: string
priority: 1
- jsonPath: .status.backupEndWal
description: Backup end wal
name: BackupEndWal
type: string
priority: 1
- jsonPath: .spec.deletes3
description: delete S3 data when backup is deleted.
name: DeleteS3
type: boolean
priority: 1
- jsonPath: .spec.backup.backupToS3.schedule
description: If Backup is cron show Bakcup Schedule
name: Schedule
type: string
priority: 1
- jsonPath: .status.nextRunTime
description: If Backup is cron show Backup next run time
name: NextRunTime
type: string
priority: 1
# - jsonPath: .status.backups_list
# description: The postgresql cluster backup status
# name: BackupStatus
# type: string
# priority: 1
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
x-kubernetes-preserve-unknown-fields: true
spec:
type: object
properties:
clusterName:
type: string
description: "The name of the cluster to be backed up"
clusterNamespace:
type: string
description: "The namespace of the cluster to be backed up"
backup:
type: object
x-kubernetes-preserve-unknown-fields: true
properties:
backupToS3:
type: object
x-kubernetes-preserve-unknown-fields: true
properties:
name:
type: string
kind:
type: string
enum:
- single
- schedule
schedule:
type: string
description: "Rules for scheduled backup."
deletes3:
type: boolean
enum:
- true
- false
default: false
description: "Delete S3 data when backup is deleted."
---
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down Expand Up @@ -477,8 +594,8 @@ rules:

# Application: read-only access for watching cluster-wide.
- apiGroups: [postgres.radondb.io]
resources: [postgresqls]
verbs: [list, watch, get, patch, create,]
resources: [postgresqls, postgresqlbackups]
verbs: [list, watch, get, patch, create, delete, update]

- apiGroups: [""]
resources: [pods, persistentvolumeclaims, services]
Expand Down Expand Up @@ -512,8 +629,8 @@ rules:

# Application: watching & handling for the custom resource we declare.
- apiGroups: [postgres.radondb.io]
resources: [postgresqls]
verbs: [list, watch, get, patch]
resources: [postgresqls, postgresqlbackups]
verbs: [list, watch, get, patch, delete, create, update]

# Application: other resources it produces and manipulates.
# Here, we create Jobs+PVCs+Pods, but we do not patch/update/delete them ever.
Expand Down Expand Up @@ -582,7 +699,7 @@ spec:
priorityClassName: system-cluster-critical
containers:
- name: radondb-postgres-operator
image: radondb/radondb-postgres-operator:v1.2.1
image: radondb/radondb-postgres-operator:v1.2.2
imagePullPolicy: IfNotPresent
resources:
limits:
Expand Down
Loading

0 comments on commit 95270ce

Please sign in to comment.