Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/public/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ This sections describes all possible deploy parameters for Patroni component.
| patroni.storage.nodes | []string | no | n/a | Specifies list of nodes to which Patroni pods will be scheduled. |
| patroni.storage.selectors | []string | no | n/a | Specifies list of selector to choose PVCs. |
| patroni.storage.volumes | []string | no | n/a | Specifies list of Persistence Volumes that will be used for PVCs. Should be specified only in case of `pv` storageClass. |
| patroni.storage.annotations | map[string]string | no | n/a | Specifies optional annotations to apply to PVCs. Use `argocd.argoproj.io/sync-options: Prune=false` to protect from ArgoCD pruning. |
| patroni.pgWalStorage | Storage Group | no | n/a | Specifies set of storage parameters for separater volume for `pg_wal` directory. Parameters are the same as for `storage`. |
| patroni.pgWalStorageAutoManage | bool | no | n/a | Specifies is pg_wal files have to be moved to separate volume `pg_wal` directory automatically. |
| patroni.priorityClassName | string | no | n/a | Specifies [Priority Class](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass). |
Expand Down Expand Up @@ -407,6 +408,7 @@ This sections describes all possible deploy parameters for PostgreSQL Backup Dae
| backupDaemon.storage.selectors | []string | no | n/a | Specifies list of selector to choose PVCs. |
| backupDaemon.storage.volumes | []string | no | n/a | Specifies list of Persistence Volumes that will be used for PVCs. Should be specified only in case of `pv` storageClass. |
| backupDaemon.storage.accessMode | []string | no | n/a | Specifies list of [Access Modes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes) that will be used for PVCs. |
| backupDaemon.storage.annotations | map[string]string | no | n/a | Specifies optional annotations to apply to PVCs. Use `argocd.argoproj.io/sync-options: Prune=false` to protect from ArgoCD pruning. |
| backupDaemon.s3Storage.url | string | no | n/a | Specifies url address to S3 storage. |
| backupDaemon.s3Storage.accessKeyId | string | no | n/a | Specifies S3 accessKeyId credential. |
| backupDaemon.s3Storage.secretAccessKey | string | no | n/a | Specifies S3 secretAccessKey credential. |
Expand Down
15 changes: 8 additions & 7 deletions operator/api/common/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ package v1
// Storage Describes Storage that will be used by patroni
type Storage struct {
// +kubebuilder:validation:Pattern=`^[0-9]+(m|Ki|Mi|Gi|Ti|Pi|Ei|k|M|G|T|P|E)$`
Size string `json:"size,omitempty"`
Type string `json:"type,omitempty"`
StorageClass string `json:"storageClass,omitempty"`
Volumes []string `json:"volumes,omitempty"`
Nodes []string `json:"nodes,omitempty"`
Selectors []string `json:"selectors,omitempty"`
AccessModes []string `json:"accessModes,omitempty"`
Size string `json:"size,omitempty"`
Type string `json:"type,omitempty"`
StorageClass string `json:"storageClass,omitempty"`
Volumes []string `json:"volumes,omitempty"`
Nodes []string `json:"nodes,omitempty"`
Selectors []string `json:"selectors,omitempty"`
AccessModes []string `json:"accessModes,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
}
type CloudSql struct {
Project string `json:"project,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions operator/api/common/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions operator/charts/patroni-core/crds/netcracker.com_patronicores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,10 @@ spec:
items:
type: string
type: array
annotations:
additionalProperties:
type: string
type: object
nodes:
items:
type: string
Expand Down Expand Up @@ -2470,6 +2474,10 @@ spec:
items:
type: string
type: array
annotations:
additionalProperties:
type: string
type: object
nodes:
items:
type: string
Expand Down Expand Up @@ -2603,6 +2611,10 @@ spec:
items:
type: string
type: array
annotations:
additionalProperties:
type: string
type: object
nodes:
items:
type: string
Expand Down
4 changes: 4 additions & 0 deletions operator/charts/patroni-core/templates/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ spec:
- {{ . }}
{{- end }}
{{ end }}
{{ if .Values.patroni.storage.annotations }}
annotations:
{{- toYaml .Values.patroni.storage.annotations | nindent 8 }}
{{ end }}
{{ if .Values.patroni.standbyCluster }}
standbyCluster:
host: {{ .Values.patroni.standbyCluster.host }}
Expand Down
7 changes: 7 additions & 0 deletions operator/charts/patroni-core/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,13 @@
"items": {
"type": "string"
}
},
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Optional annotations to apply to PVCs created for this storage. Use this to protect PVCs from ArgoCD pruning or add custom metadata."
}
}
},
Expand Down
11 changes: 11 additions & 0 deletions operator/charts/patroni-core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ patroni:
type: pv
# Size of the PVC that will be create for each of Patroni Pod as mount for data files
size: 5Gi
# Optional annotations to apply to PVCs created for Patroni storage.
# Use this to protect PVCs from ArgoCD pruning or add custom metadata.
# Example: Prevent ArgoCD from deleting PVCs during sync:
# annotations:
# argocd.argoproj.io/sync-options: Prune=false
# Parameter specifies the list of labels that is used to bind suitable
# persistent volumes with the persistent volume claims
# selectors:
Expand Down Expand Up @@ -228,6 +233,10 @@ patroni:
# type: provisioned
# Size of the PVC that will be created for each of Patroni Pod as mount for data files
# size: 10Gi
# Optional annotations to apply to PVCs created for WAL storage.
# Use this to protect PVCs from ArgoCD pruning or add custom metadata.
# annotations:
# argocd.argoproj.io/sync-options: Prune=false
# Parameter specifies the list of labels that is used to bind suitable
# persistent volumes with the persistent volume claims
# selectors:
Expand Down Expand Up @@ -260,6 +269,8 @@ patroni:
# size: 3Gi
# volumes:
# - pg-backrest-backups-pv-1
# annotations:
# argocd.argoproj.io/sync-options: Prune=false
# s3:
# bucket: "pgbackrest"
# endpoint: "https://minio-service"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,10 @@ spec:
items:
type: string
type: array
annotations:
additionalProperties:
type: string
type: object
nodes:
items:
type: string
Expand Down
4 changes: 4 additions & 0 deletions operator/charts/patroni-services/templates/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ spec:
- {{ . }}
{{- end }}
{{ end }}
{{ if .Values.backupDaemon.storage.annotations }}
annotations:
{{- toYaml .Values.backupDaemon.storage.annotations | nindent 8 }}
{{ end }}
{{ if .Values.backupDaemon.priorityClassName }}
priorityClassName: {{ .Values.backupDaemon.priorityClassName }}
{{ end }}
Expand Down
7 changes: 7 additions & 0 deletions operator/charts/patroni-services/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,13 @@
"items": {
"type": "string"
}
},
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Optional annotations to apply to PVCs created for this storage. Use this to protect PVCs from ArgoCD pruning or add custom metadata."
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions operator/charts/patroni-services/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ backupDaemon:
type: provisioned
# Size of the PVC that will be create for each of Patroni Pod as mount for data files
size: 1Gi
# Optional annotations to apply to PVCs created for backup daemon storage.
# Use this to protect PVCs from ArgoCD pruning or add custom metadata.
# Example: Prevent ArgoCD from deleting PVCs during sync:
# annotations:
# argocd.argoproj.io/sync-options: Prune=false
# Parameter specifies the list of labels that is used to bind suitable
# persistent volumes with the persistent volume claims
# selectors:
Expand Down Expand Up @@ -240,6 +245,8 @@ backupDaemon:
# size: 3Gi
# volumes:
# - pg-backrest-backups-pv-1
# annotations:
# argocd.argoproj.io/sync-options: Prune=false
# s3:
# bucket: "pgbackrest"
# endpoint: "https://minio-service"
Expand Down
11 changes: 10 additions & 1 deletion operator/pkg/helper/resource_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,17 @@ func (rm *ResourceManager) CreatePvcIfNotExists(pvc *corev1.PersistentVolumeClai
return err
}
} else {
logger.Info(fmt.Sprintf("PVC %s exists, clearing owner reference...", pvc.Name))
logger.Info(fmt.Sprintf("PVC %s exists, clearing owner reference and updating annotations...", pvc.Name))
foundPvc.OwnerReferences = nil
if pvc.Annotations != nil {
if foundPvc.Annotations == nil {
foundPvc.Annotations = make(map[string]string)
}
for key, value := range pvc.Annotations {
foundPvc.Annotations[key] = value
}
}

err := rm.kubeClient.Update(context.TODO(), foundPvc)
if err != nil {
logger.Error(fmt.Sprintf("Failed to clear Owner Reference for %s", pvc.Name), zap.Error(err))
Expand Down
5 changes: 3 additions & 2 deletions operator/pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ func NewPvc(pvcName string, storageEntity *commonv1.Storage, idx int) *corev1.Pe

pvc := &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: pvcName,
Namespace: util.GetNameSpace(),
Name: pvcName,
Namespace: util.GetNameSpace(),
Annotations: storageEntity.Annotations,
},
Spec: pvcSpec,
}
Expand Down
Loading