diff --git a/src/mpyl/schema/k8s_api_core.schema.yml b/src/mpyl/schema/k8s_api_core.schema.yml index faf17121c..5c4b3c948 100644 --- a/src/mpyl/schema/k8s_api_core.schema.yml +++ b/src/mpyl/schema/k8s_api_core.schema.yml @@ -1,4 +1,4 @@ -# Taken from https://github.com/instrumenta/kubernetes-json-schema and converted to YAML +# Taken from https://github.com/kubernetes/kubernetes/blob/master/api/openapi-spec/swagger.json and converted to YAML definitions: io.k8s.api.core.v1.EnvVarSource: description: EnvVarSource represents a source for the value of an EnvVar. @@ -142,4 +142,56 @@ definitions: kinds. type: array items: - type: string \ No newline at end of file + type: string + io.k8s.api.batch.v1.CronJobSpec: + description: CronJobSpec describes how the job execution will look like and when + it will actually run. + properties: + concurrencyPolicy: + description: |- + Specifies how to treat concurrent executions of a Job. Valid values are: + + - "Allow" (default): allows CronJobs to run concurrently; - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet; - "Replace": cancels currently running job and replaces it with a new one + type: string + enum: + - Allow + - Forbid + - Replace + failedJobsHistoryLimit: + description: The number of failed finished jobs to retain. Value must be non-negative + integer. Defaults to 1. + format: int32 + type: integer + schedule: + description: The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. + type: string + startingDeadlineSeconds: + description: Optional deadline in seconds for starting the job if it misses + scheduled time for any reason. Missed jobs executions will be counted as + failed ones. + format: int64 + type: integer + successfulJobsHistoryLimit: + description: The number of successful finished jobs to retain. Value must be + non-negative integer. Defaults to 3. + format: int32 + type: integer + suspend: + description: This flag tells the controller to suspend subsequent executions, + it does not apply to already started executions. Defaults to false. + type: boolean + 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. The set of valid time zone names and the time zone offset is loaded + from the system-wide time zone database by the API server during CronJob validation + and the controller manager during execution. If no system-wide time zone database + can be found a bundled version of the database is used instead. If the time + zone name becomes invalid during the lifetime of a CronJob or due to a change + in host configuration, the controller will stop creating new new Jobs and + will create a system event with the reason UnknownTimeZone. More information + can be found in https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones + type: string + required: + - schedule + type: object \ No newline at end of file diff --git a/src/mpyl/schema/project.schema.yml b/src/mpyl/schema/project.schema.yml index 905dd3060..834cec454 100644 --- a/src/mpyl/schema/project.schema.yml +++ b/src/mpyl/schema/project.schema.yml @@ -815,45 +815,7 @@ definitions: activeDeadlineSeconds: $ref: '#/definitions/dtapNumberValue' cron: - description: 'CronJobSpec describes how the job execution will look like and when it - will actually run. Identical to See https://kubernetesjsonschema.dev/v1.14.0/_definitions.json#/definitions/io.k8s.api.batch.v1beta1.CronJobSpec - but without jobTemplate' - additionalProperties: false - properties: - concurrencyPolicy: - description: 'Specifies how to treat concurrent executions of a Job. Valid values - are: - "Allow" (default): allows CronJobs to run concurrently; - "Forbid": forbids - concurrent runs, skipping next run if previous run hasn''t finished yet; - "Replace": - cancels currently running job and replaces it with a new one - See https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#concurrency-policy - ' - type: string - enum: - - Allow - - Forbid - - Replace - failedJobsHistoryLimit: - description: The number of failed finished jobs to retain. This is a pointer to - distinguish between explicit zero and not specified. Defaults to 1. - format: int32 - type: integer - schedule: - description: The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. - type: string - startingDeadlineSeconds: - description: Optional deadline in seconds for starting the job if it misses scheduled - time for any reason. Missed jobs executions will be counted as failed ones. - format: int64 - type: integer - successfulJobsHistoryLimit: - description: The number of successful finished jobs to retain. This is a pointer - to distinguish between explicit zero and not specified. Defaults to 3. - format: int32 - type: integer - suspend: - description: This flag tells the controller to suspend subsequent executions, - it does not apply to already started executions. Defaults to false. - type: boolean + $ref: 'k8s_api_core.schema.yml#/definitions/io.k8s.api.batch.v1.CronJobSpec' spark: description: >- Spark job. Requires google spark operator to be installed. diff --git a/tests/projects/job/deployment/project.yml b/tests/projects/job/deployment/project.yml index ff28e9f36..7150f79b9 100644 --- a/tests/projects/job/deployment/project.yml +++ b/tests/projects/job/deployment/project.yml @@ -12,6 +12,7 @@ deployment: job: cron: schedule: "0 22 * * *" + timeZone: "Europe/Amsterdam" dependencies: test: - tests/projects/service/file.py diff --git a/tests/steps/deploy/k8s/chart/templates/cronjob/cronjob.yaml b/tests/steps/deploy/k8s/chart/templates/cronjob/cronjob.yaml index 205e61b3e..0e82016de 100644 --- a/tests/steps/deploy/k8s/chart/templates/cronjob/cronjob.yaml +++ b/tests/steps/deploy/k8s/chart/templates/cronjob/cronjob.yaml @@ -65,3 +65,4 @@ spec: schedule: 0 22 * * * successfulJobsHistoryLimit: 3 suspend: true + timeZone: Europe/Amsterdam diff --git a/tests/test_resources/test_cron_job_project.yml b/tests/test_resources/test_cron_job_project.yml index c5ef65b0b..e24f982f6 100644 --- a/tests/test_resources/test_cron_job_project.yml +++ b/tests/test_resources/test_cron_job_project.yml @@ -26,6 +26,7 @@ deployment: cron: suspend: true schedule: "0 22 * * *" + timeZone: "Europe/Amsterdam" successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 1 concurrencyPolicy: Allow