diff --git a/examples/operator/401_scheduled_backups.yaml b/examples/operator/401_scheduled_backups.yaml new file mode 100644 index 00000000000..07eab98b69d --- /dev/null +++ b/examples/operator/401_scheduled_backups.yaml @@ -0,0 +1,190 @@ +apiVersion: planetscale.com/v2 +kind: VitessCluster +metadata: + name: example +spec: + backup: + engine: xtrabackup + locations: + - volume: + hostPath: + path: /tmp + type: Directory + schedules: + - name: "every-minute-customer" + schedule: "* * * * *" + resources: + requests: + cpu: 100m + memory: 1024Mi + limits: + memory: 1024Mi + successfulJobsHistoryLimit: 2 + failedJobsHistoryLimit: 3 + jobTimeoutMinute: 5 + strategies: + - name: BackupShard + keyspace: "customer" + shard: "-80" + - name: BackupShard + keyspace: "customer" + shard: "80-" + - name: "every-minute-commerce" + schedule: "* * * * *" + resources: + requests: + cpu: 100m + memory: 1024Mi + limits: + memory: 1024Mi + successfulJobsHistoryLimit: 2 + failedJobsHistoryLimit: 3 + jobTimeoutMinute: 5 + strategies: + - name: BackupShard + keyspace: "customer" + shard: "-" + images: + vtctld: vitess/lite:latest + vtadmin: vitess/vtadmin:latest + vtgate: vitess/lite:latest + vttablet: vitess/lite:latest + vtbackup: vitess/lite:latest + vtorc: vitess/lite:latest + mysqld: + mysql80Compatible: mysql:8.0.30 + mysqldExporter: prom/mysqld-exporter:v0.11.0 + cells: + - name: zone1 + gateway: + authentication: + static: + secret: + name: example-cluster-config + key: users.json + replicas: 1 + resources: + requests: + cpu: 100m + memory: 256Mi + limits: + memory: 256Mi + vitessDashboard: + cells: + - zone1 + extraFlags: + security_policy: read-only + replicas: 1 + resources: + limits: + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + vtadmin: + rbac: + name: example-cluster-config + key: rbac.yaml + cells: + - zone1 + apiAddresses: + - http://localhost:14001 + replicas: 1 + readOnly: false + apiResources: + limits: + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + webResources: + limits: + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + + keyspaces: + - name: commerce + durabilityPolicy: none + turndownPolicy: Immediate + vitessOrchestrator: + resources: + limits: + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + extraFlags: + recovery-period-block-duration: 5s + partitionings: + - equal: + parts: 1 + shardTemplate: + databaseInitScriptSecret: + name: example-cluster-config + key: init_db.sql + tabletPools: + - cell: zone1 + type: replica + replicas: 2 + vttablet: + extraFlags: + db_charset: utf8mb4 + wait_for_backup_interval: "0" + resources: + limits: + memory: 1024Mi + requests: + cpu: 100m + memory: 1024Mi + mysqld: + resources: + limits: + memory: 1024Mi + requests: + cpu: 100m + memory: 512Mi + dataVolumeClaimTemplate: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 10Gi + - name: customer + durabilityPolicy: none + turndownPolicy: Immediate + partitionings: + - equal: + parts: 2 + shardTemplate: + databaseInitScriptSecret: + name: example-cluster-config + key: init_db.sql + tabletPools: + - cell: zone1 + type: replica + replicas: 2 + vttablet: + extraFlags: + db_charset: utf8mb4 + wait_for_backup_interval: "0" + resources: + limits: + memory: 1024Mi + requests: + cpu: 100m + memory: 1024Mi + mysqld: + resources: + limits: + memory: 1024Mi + requests: + cpu: 100m + memory: 512Mi + dataVolumeClaimTemplate: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 10Gi + updateStrategy: + type: Immediate diff --git a/examples/operator/operator.yaml b/examples/operator/operator.yaml index 5ad24f92771..1ebf69da491 100644 --- a/examples/operator/operator.yaml +++ b/examples/operator/operator.yaml @@ -1,4 +1,3 @@ ---- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: @@ -382,6 +381,177 @@ spec: --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.11.3 + creationTimestamp: null + name: vitessbackupschedules.planetscale.com +spec: + group: planetscale.com + names: + kind: VitessBackupSchedule + listKind: VitessBackupScheduleList + plural: vitessbackupschedules + singular: vitessbackupschedule + scope: Namespaced + versions: + - name: v2 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + affinity: + x-kubernetes-preserve-unknown-fields: true + allowedMissedRun: + minimum: 0 + type: integer + annotations: + additionalProperties: + type: string + type: object + cluster: + type: string + concurrencyPolicy: + enum: + - Allow + - Forbid + example: Forbid + type: string + failedJobsHistoryLimit: + format: int32 + minimum: 0 + type: integer + image: + type: string + imagePullPolicy: + type: string + jobTimeoutMinute: + default: 10 + format: int32 + minimum: 0 + type: integer + name: + example: every-day + minLength: 1 + pattern: ^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$ + type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + schedule: + example: 0 0 * * * + minLength: 0 + type: string + startingDeadlineSeconds: + format: int64 + minimum: 0 + type: integer + strategies: + items: + properties: + extraFlags: + additionalProperties: + type: string + type: object + keyspace: + example: commerce + type: string + name: + enum: + - BackupShard + type: string + shard: + example: '-' + type: string + required: + - keyspace + - name + - shard + type: object + minItems: 1 + type: array + successfulJobsHistoryLimit: + format: int32 + minimum: 0 + type: integer + suspend: + type: boolean + required: + - cluster + - name + - resources + - schedule + - strategies + type: object + status: + properties: + active: + items: + properties: + apiVersion: + type: string + fieldPath: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + resourceVersion: + type: string + uid: + type: string + type: object + x-kubernetes-map-type: atomic + type: array + lastScheduledTime: + format: date-time + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.11.3 @@ -705,6 +875,109 @@ spec: x-kubernetes-preserve-unknown-fields: true initContainers: x-kubernetes-preserve-unknown-fields: true + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object replicas: format: int32 minimum: 0 @@ -792,6 +1065,9 @@ spec: type: object sidecarContainers: x-kubernetes-preserve-unknown-fields: true + terminationGracePeriodSeconds: + format: int64 + type: integer tolerations: x-kubernetes-preserve-unknown-fields: true topologySpreadConstraints: @@ -1364,6 +1640,114 @@ spec: type: object minItems: 1 type: array + schedules: + items: + properties: + affinity: + x-kubernetes-preserve-unknown-fields: true + allowedMissedRun: + minimum: 0 + type: integer + annotations: + additionalProperties: + type: string + type: object + concurrencyPolicy: + enum: + - Allow + - Forbid + example: Forbid + type: string + failedJobsHistoryLimit: + format: int32 + minimum: 0 + type: integer + jobTimeoutMinute: + default: 10 + format: int32 + minimum: 0 + type: integer + name: + example: every-day + minLength: 1 + pattern: ^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$ + type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + schedule: + example: 0 0 * * * + minLength: 0 + type: string + startingDeadlineSeconds: + format: int64 + minimum: 0 + type: integer + strategies: + items: + properties: + extraFlags: + additionalProperties: + type: string + type: object + keyspace: + example: commerce + type: string + name: + enum: + - BackupShard + type: string + shard: + example: '-' + type: string + required: + - keyspace + - name + - shard + type: object + minItems: 1 + type: array + successfulJobsHistoryLimit: + format: int32 + minimum: 0 + type: integer + suspend: + type: boolean + required: + - name + - resources + - schedule + - strategies + type: object + type: array subcontroller: properties: serviceAccountName: @@ -1496,6 +1880,109 @@ spec: x-kubernetes-preserve-unknown-fields: true initContainers: x-kubernetes-preserve-unknown-fields: true + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object replicas: format: int32 minimum: 0 @@ -1583,6 +2070,9 @@ spec: type: object sidecarContainers: x-kubernetes-preserve-unknown-fields: true + terminationGracePeriodSeconds: + format: int64 + type: integer tolerations: x-kubernetes-preserve-unknown-fields: true topologySpreadConstraints: @@ -2278,6 +2768,16 @@ spec: type: string durabilityPolicy: type: string + images: + properties: + mysqld: + properties: + mysql56Compatible: + type: string + mysql80Compatible: + type: string + type: object + type: object name: maxLength: 63 minLength: 1 @@ -2607,6 +3107,45 @@ spec: required: - resources type: object + mysqldExporter: + properties: + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + required: + - resources + type: object + name: + default: "" + type: string replicas: format: int32 minimum: 0 @@ -2664,6 +3203,9 @@ spec: x-kubernetes-int-or-string: true type: object type: object + terminationGracePeriodSeconds: + format: int64 + type: integer required: - resources type: object @@ -2677,6 +3219,7 @@ spec: x-kubernetes-list-map-keys: - type - cell + - name x-kubernetes-list-type: map required: - databaseInitScriptSecret @@ -3002,6 +3545,45 @@ spec: required: - resources type: object + mysqldExporter: + properties: + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + required: + - resources + type: object + name: + default: "" + type: string replicas: format: int32 minimum: 0 @@ -3059,6 +3641,9 @@ spec: x-kubernetes-int-or-string: true type: object type: object + terminationGracePeriodSeconds: + format: int64 + type: integer required: - resources type: object @@ -3072,6 +3657,7 @@ spec: x-kubernetes-list-map-keys: - type - cell + - name x-kubernetes-list-type: map required: - databaseInitScriptSecret @@ -4309,6 +4895,45 @@ spec: required: - resources type: object + mysqldExporter: + properties: + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + required: + - resources + type: object + name: + default: "" + type: string replicas: format: int32 minimum: 0 @@ -4366,6 +4991,9 @@ spec: x-kubernetes-int-or-string: true type: object type: object + terminationGracePeriodSeconds: + format: int64 + type: integer required: - resources type: object @@ -4379,6 +5007,7 @@ spec: x-kubernetes-list-map-keys: - type - cell + - name x-kubernetes-list-type: map required: - databaseInitScriptSecret @@ -4704,6 +5333,45 @@ spec: required: - resources type: object + mysqldExporter: + properties: + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + required: + - resources + type: object + name: + default: "" + type: string replicas: format: int32 minimum: 0 @@ -4761,6 +5429,9 @@ spec: x-kubernetes-int-or-string: true type: object type: object + terminationGracePeriodSeconds: + format: int64 + type: integer required: - resources type: object @@ -4774,6 +5445,7 @@ spec: x-kubernetes-list-map-keys: - type - cell + - name x-kubernetes-list-type: map required: - databaseInitScriptSecret @@ -5641,6 +6313,45 @@ spec: required: - resources type: object + mysqldExporter: + properties: + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + required: + - resources + type: object + name: + default: "" + type: string replicas: format: int32 minimum: 0 @@ -5698,6 +6409,9 @@ spec: x-kubernetes-int-or-string: true type: object type: object + terminationGracePeriodSeconds: + format: int64 + type: integer required: - resources type: object @@ -5711,6 +6425,7 @@ spec: x-kubernetes-list-map-keys: - type - cell + - name x-kubernetes-list-type: map topologyReconciliation: properties: @@ -6091,6 +6806,15 @@ rules: - vitessbackupstorages - vitessbackupstorages/status - vitessbackupstorages/finalizers + - vitessbackupschedules + - vitessbackupschedules/status + - vitessbackupschedules/finalizers + verbs: + - '*' + - apiGroups: + - batch + resources: + - jobs verbs: - '*' --- @@ -6106,6 +6830,22 @@ subjects: - kind: ServiceAccount name: vitess-operator --- +apiVersion: scheduling.k8s.io/v1 +description: Vitess components (vttablet, vtgate, vtctld, etcd) +globalDefault: false +kind: PriorityClass +metadata: + name: vitess +value: 1000 +--- +apiVersion: scheduling.k8s.io/v1 +description: The vitess-operator control plane. +globalDefault: false +kind: PriorityClass +metadata: + name: vitess-operator-control-plane +value: 5000 +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -6155,19 +6895,3 @@ spec: memory: 128Mi priorityClassName: vitess-operator-control-plane serviceAccountName: vitess-operator ---- -apiVersion: scheduling.k8s.io/v1 -description: The vitess-operator control plane. -globalDefault: false -kind: PriorityClass -metadata: - name: vitess-operator-control-plane -value: 5000 ---- -apiVersion: scheduling.k8s.io/v1 -description: Vitess components (vttablet, vtgate, vtctld, etcd) -globalDefault: false -kind: PriorityClass -metadata: - name: vitess -value: 1000