Skip to content

Commit

Permalink
Merge pull request #1482 from hasbro17/add-etcd-backups-api
Browse files Browse the repository at this point in the history
Add etcd backup API
  • Loading branch information
openshift-merge-robot authored Jul 14, 2023
2 parents aaae710 + b8b94d3 commit de6ad79
Show file tree
Hide file tree
Showing 14 changed files with 1,884 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.openshift.io: https://github.com/openshift/api/pull/1482
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
include.release.openshift.io/single-node-developer: "true"
release.openshift.io/feature-set: TechPreviewNoUpgrade
name: backups.config.openshift.io
spec:
group: config.openshift.io
names:
kind: Backup
listKind: BackupList
plural: backups
singular: backup
scope: Cluster
versions:
- name: v1alpha1
served: true
storage: true
subresources:
status: {}
schema:
openAPIV3Schema:
description: "Backup provides configuration for performing backups of the openshift cluster. \n Compatibility level 4: No compatibility is provided, the API can change at any point for any reason. These capabilities should not be used by applications needing long term support."
type: object
required:
- spec
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: spec holds user settable values for configuration
type: object
required:
- etcd
properties:
etcd:
description: etcd specifies the configuration for periodic backups of the etcd cluster
type: object
properties:
pvcName:
description: PVCName specifies the name of the PersistentVolumeClaim (PVC) which binds a PersistentVolume where the etcd backup files would be saved The PVC itself must always be created in the "openshift-etcd" namespace If the PVC is left unspecified "" then the platform will choose a reasonable default location to save the backup. In the future this would be backups saved across the control-plane master nodes.
type: string
retentionPolicy:
description: RetentionPolicy defines the retention policy for retaining and deleting existing backups.
type: object
required:
- retentionType
properties:
retentionNumber:
description: RetentionNumber configures the retention policy based on the number of backups
type: object
required:
- maxNumberOfBackups
properties:
maxNumberOfBackups:
description: MaxNumberOfBackups defines the maximum number of backups to retain. If the existing number of backups saved is equal to MaxNumberOfBackups then the oldest backup will be removed before a new backup is initiated.
type: integer
minimum: 1
retentionSize:
description: RetentionSize configures the retention policy based on the size of backups
type: object
required:
- maxSizeOfBackupsGb
properties:
maxSizeOfBackupsGb:
description: MaxSizeOfBackupsGb defines the total size in GB of backups to retain. If the current total size backups exceeds MaxSizeOfBackupsGb then the oldest backup will be removed before a new backup is initiated.
type: integer
minimum: 1
retentionType:
description: RetentionType sets the type of retention policy. Currently, the only valid policies are retention by number of backups (RetentionNumber), by the size of backups (RetentionSize). More policies or types may be added in the future. Empty string means no opinion and the platform is left to choose a reasonable default which is subject to change without notice. The current default is RetentionNumber with 15 backups kept.
type: string
allOf:
- enum:
- RetentionNumber
- RetentionSize
- enum:
- ""
- RetentionNumber
- RetentionSize
schedule:
description: 'Schedule defines the recurring backup schedule in Cron format every 2 hours: 0 */2 * * * every day at 3am: 0 3 * * * Empty string means no opinion and the platform is left to choose a reasonable default which is subject to change without notice. The current default is "no backups", but will change in the future.'
type: string
pattern: ^(@(annually|yearly|monthly|weekly|daily|hourly))|(\*|(?:\*|(?:[0-9]|(?:[1-5][0-9])))\/(?:[0-9]|(?:[1-5][0-9]))|(?:[0-9]|(?:[1-5][0-9]))(?:(?:\-[0-9]|\-(?:[1-5][0-9]))?|(?:\,(?:[0-9]|(?:[1-5][0-9])))*)) (\*|(?:\*|(?:\*|(?:[0-9]|1[0-9]|2[0-3])))\/(?:[0-9]|1[0-9]|2[0-3])|(?:[0-9]|1[0-9]|2[0-3])(?:(?:\-(?:[0-9]|1[0-9]|2[0-3]))?|(?:\,(?:[0-9]|1[0-9]|2[0-3]))*)) (\*|(?:[1-9]|(?:[12][0-9])|3[01])(?:(?:\-(?:[1-9]|(?:[12][0-9])|3[01]))?|(?:\,(?:[1-9]|(?:[12][0-9])|3[01]))*)) (\*|(?:[1-9]|1[012]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(?:(?:\-(?:[1-9]|1[012]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?|(?:\,(?:[1-9]|1[012]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))*)) (\*|(?:[0-6]|SUN|MON|TUE|WED|THU|FRI|SAT)(?:(?:\-(?:[0-6]|SUN|MON|TUE|WED|THU|FRI|SAT))?|(?:\,(?:[0-6]|SUN|MON|TUE|WED|THU|FRI|SAT))*))$
timeZone:
description: The time zone name for the given schedule, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. If not specified, this will default to the time zone of the kube-controller-manager process. See https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones
type: string
pattern: ^([A-Za-z_]+([+-]*0)*|[A-Za-z_]+(\/[A-Za-z_]+){1,2})(\/GMT[+-]\d{1,2})?$
status:
description: status holds observed values from the cluster. They may not be overridden.
type: object
2 changes: 2 additions & 0 deletions config/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&InsightsDataGather{},
&InsightsDataGatherList{},
&Backup{},
&BackupList{},
)
metav1.AddToGroupVersion(scheme, GroupVersion)
return nil
Expand Down
202 changes: 202 additions & 0 deletions config/v1alpha1/techpreview.backup.testsuite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[TechPreview] Backup"
crd: 0000_10_config-operator_01_backup-TechPreviewNoUpgrade.crd.yaml
tests:
onCreate:
- name: Should be able to create a Backup with a valid spec
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "* 2 * * *"
pvcName: etcdbackup-pvc
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "* 2 * * *"
pvcName: etcdbackup-pvc
- name: Should be able to create an EtcdBackup without the pvcName specified
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "* 2 * * *"
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "* 2 * * *"
- name: Should be able to create a Backup with a valid schedule - At 22:00 on every day-of-week from Monday through Friday
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "0 22 * * 1-5"
pvcName: etcdbackup-pvc
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "0 22 * * 1-5"
pvcName: etcdbackup-pvc
- name: Should be able to create a Backup with a valid schedule - At 04:05 on Sunday.
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "5 4 * * SUN"
pvcName: etcdbackup-pvc
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "5 4 * * SUN"
pvcName: etcdbackup-pvc
- name: Should be able to create a Backup with a valid schedule - Predefined hourly
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "@hourly"
pvcName: etcdbackup-pvc
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "@hourly"
pvcName: etcdbackup-pvc
- name: Should fail to create an EtcdBackup with an invalid schedule - At 04:05 on invalid day FOO.
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "5 4 * * FOO"
pvcName: etcdbackup-pvc
expectedError: "spec.etcd.schedule in body should match"
- name: Should fail to create an EtcdBackup with an invalid schedule - Predefined typo @hourli instead of @hourly.
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "@hourli"
pvcName: etcdbackup-pvc
expectedError: "spec.etcd.schedule in body should match"
- name: Should fail to create an EtcdBackup with an invalid schedule - Non standard L last Friday in month
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "* * * * 5L"
pvcName: etcdbackup-pvc
expectedError: "spec.etcd.schedule in body should match"
- name: Should fail to create an EtcdBackup with an invalid schedule - Non standard L 5th day before last day of month
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "* * L-5 * *"
pvcName: etcdbackup-pvc
expectedError: "spec.etcd.schedule in body should match"
- name: Should fail to create an EtcdBackup with an invalid schedule - Non standard W closest weekday to 15th of month
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
schedule: "* * 15W * *"
pvcName: etcdbackup-pvc
expectedError: "spec.etcd.schedule in body should match"
- name: Should be able to create a Backup with a valid time zone - Africa/Banjul
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: Africa/Banjul
pvcName: etcdbackup-pvc
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: Africa/Banjul
pvcName: etcdbackup-pvc
- name: Should be able to create a Backup with a valid time zone - Etc/GMT-8
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: Etc/GMT-8
pvcName: etcdbackup-pvc
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: Etc/GMT-8
pvcName: etcdbackup-pvc
- name: Should be able to create a Backup with a valid time zone - Etc/UTC
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: Etc/UTC
pvcName: etcdbackup-pvc
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: Etc/UTC
pvcName: etcdbackup-pvc
- name: Should be able to create a Backup with a valid time zone - America/Argentina/Catamarca
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: America/Argentina/Catamarca
pvcName: etcdbackup-pvc
expected: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: America/Argentina/Catamarca
pvcName: etcdbackup-pvc
- name: Should fail to create an EtcdBackup with an invalid time zone - GMT2
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: GMT2
pvcName: etcdbackup-pvc
expectedError: "spec.etcd.timeZone in body should match"
- name: Should fail to create an EtcdBackup with an invalid time zone - GMT+3
initial: |
apiVersion: config.openshift.io/v1alpha1
kind: Backup
spec:
etcd:
timeZone: GMT+3
pvcName: etcdbackup-pvc
expectedError: "spec.etcd.timeZone in body should match"

Loading

0 comments on commit de6ad79

Please sign in to comment.