From 64d53d53eeaa69fafeb2ec51efc9de4ed3d5b62f Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Tue, 17 Aug 2021 12:29:54 +0800 Subject: [PATCH] Update YAML for label-driven recurring job Longhorn-467 Signed-off-by: Chin-Ya Huang --- deploy/longhorn.yaml | 88 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/deploy/longhorn.yaml b/deploy/longhorn.yaml index 9a6ecf5..4e7d18c 100644 --- a/deploy/longhorn.yaml +++ b/deploy/longhorn.yaml @@ -49,7 +49,8 @@ rules: "engineimages", "engineimages/status", "nodes", "nodes/status", "instancemanagers", "instancemanagers/status", "sharemanagers", "sharemanagers/status", "backingimages", "backingimages/status", "backingimagemanagers", "backingimagemanagers/status", "backingimagedatasources", "backingimagedatasources/status", - "backuptargets", "backuptargets/status", "backupvolumes", "backupvolumes/status", "backups", "backups/status"] + "backuptargets", "backuptargets/status", "backupvolumes", "backupvolumes/status", "backups", "backups/status", + "recurringjobs"] verbs: ["*"] - apiGroups: ["coordination.k8s.io"] resources: ["leases"] @@ -745,6 +746,86 @@ spec: description: The backup last synced time jsonPath: .status.lastSyncedAt --- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + labels: + longhorn-manager: RecurringJob + name: recurringjobs.longhorn.io +spec: + group: longhorn.io + names: + kind: RecurringJob + listKind: RecurringJobList + plural: recurringjobs + shortNames: + - lhrj + singular: recurringjob + scope: Namespaced + versions: + - name: v1beta1 + served: true + storage: true + schema: + openAPIV3Schema: + type: object + properties: + metadata: + type: object + properties: + name: + type: string + spec: + type: object + properties: + groups: + type: array + items: + type: string + task: + type: string + pattern: "^snapshot|backup$" + cron: + type: string + retain: + type: integer + concurrency: + type: integer + labels: + x-kubernetes-preserve-unknown-fields: true + status: + x-kubernetes-preserve-unknown-fields: true + subresources: + status: {} + additionalPrinterColumns: + - name: Groups + type: string + description: Sets groupings to the jobs. When set to "default" group will be added to the volume label when no other job label exist in volume. + jsonPath: .spec.groups + - name: Task + type: string + description: Should be one of "backup" or "snapshot". + jsonPath: .spec.task + - name: Cron + type: string + description: The cron expression represents recurring job scheduling. + jsonPath: .spec.cron + - name: Retain + type: integer + description: The number of snapshots/backups to keep for the volume. + jsonPath: .spec.retain + - name: Concurrency + type: integer + description: The concurrent job to run by each cron job. + jsonPath: .spec.concurrency + - name: Age + type: date + jsonPath: .metadata.creationTimestamp + - name: Labels + type: string + description: Specify the labels + jsonPath: .spec.labels +--- apiVersion: v1 kind: ConfigMap metadata: @@ -874,9 +955,8 @@ data: # backingImageURL: "https://backing-image-example.s3-region.amazonaws.com/test-backing-image" # diskSelector: "ssd,fast" # nodeSelector: "storage,fast" - # recurringJobs: '[{"name":"snap", "task":"snapshot", "cron":"*/1 * * * *", "retain":1}, - # {"name":"backup", "task":"backup", "cron":"*/2 * * * *", "retain":1, - # "labels": {"interval":"2m"}}]' + # recurringJobSelector: '[{"name":"snap-group", "isGroup":true}, + # {"name":"backup", "isGroup":false}]' --- apiVersion: apps/v1 kind: DaemonSet