Prospect of new characteristics of Kubernetes1.4: Set job execution plan

Source: Internet
Author: User
Tags new set

(i) Core Concepts

Kubernetes in the new version will be a new set of job execution plan features, in 1.3 can be seen in the beginning, from the progress of the release in the 1.4 version, we have a preview.

Kubernetes This feature allows the job to set execution time, which is similar to the functionality provided by an Open-source project quartz. Quartz is a completely Java-written open source job scheduling framework that provides a simple but powerful mechanism for job scheduling in Java applications, Quartz allows developers to schedule jobs based on time intervals.

The following diagram is the core conceptual model for this new feature:


(ii) Data structure Introduction

1) Configure the departure time for scheduled tasks

The variable schedule in the struct Scheduledjobspec is a string variable that holds a cron-type string that kubernetes1.3 to configure the trigger time of the scheduled task through this cron expression.


A cron expression consists of 6 or 7 time fields separated by a space:

4

6

7

Position

Time domain name

Allow values

Allowed special characters

1

sec

0-59

,-*/

2

Minutes

0-59

,-*/

3

Hours

0-23

,-*/

Date

1-31

,-*?/L W C

Week

1-7

,-*/L C #

Year (optional)

Null 1970-2099

,-*/

The time field of a cron expression allows you to set a numeric value, and you can use special characters to provide lists, ranges, wildcard characters, and so on, as follows:

• asterisk (*): Available in all fields, representing every moment in the corresponding time field, for example, * "Per minute" in the minute field;

• Question mark (?): The character is used only in the date and week fields, which is usually specified as "meaningless value", equivalent to a dot character;

• Minus sign (-): The expression of a range, such as the use of "10-12" in the hour field, means from 10 to 12 points, that is, 10,11,12;

• Comma (,): Expresses a list value, such as using "Mon,wed,fri" in the Week field, for Monday, Wednesday, and Friday;

• Slash (/): X/y expresses a sequence of equal steps, X is the starting value, and Y is the increment step value. If you use 0/15 in the minute field, it is 0,15,30 and 45 seconds, and 5/15 represents 5,20,35,50 in the minute field, you can also use */y, which is equivalent to 0/y;

L: This character is used only in the date and week fields, meaning "last", but it means different in two fields. L In the Date field, represents the last day of the month, such as number 31st in January, not leap year February 28th; if L is used in the week, it means Saturday, equivalent to 7. However, if L appears in the Week field and has a value x in front of it, it means "last x days of the Month", for example, 6L represents the last Friday of the month;

W: This character can only appear in the Date field and is a cosmetic of the leading date that represents the most recent weekday from that date. For example, 15W represents the most recent working day from 15th, if the month 15th is Saturday, match 14th Friday; if 15th is Sunday, match 16th Monday; if 15th is Tuesday, the result is 15th Tuesday. But it must be noted that the associated matching date is not able to span the month, as you specify 1W, if number 1th is Saturday, the result matches the number 3rd Monday, not last month. The W string can only specify a single date and cannot specify a date range;

LW Combination: In the Date field can be combined to use LW, which means the last working day of the month;

• Well sign (#): This character can only be used in the week field, indicating a weekday of the month. If 6#3 said that the third Friday of the month (6 for Friday, #3表示当前的第三个), and 4#5 that the month of the fifth Wednesday, assuming that the month does not have the fifth Wednesday, ignoring the trigger;

C: This character is used only in the date and week fields and represents the meaning of calendar. It means the date that the plan is associated with, and if the date is not associated, it is equivalent to all the dates in the calendar. For example 5C in the Date field corresponds to the first day of the calendar after 5th. 1C is equivalent to the first day after Sunday in the Week field.

Cron expressions are not sensitive to the case of special characters, nor are they sensitive to the abbreviated English case of the representative week. Some examples of cron expressions are given below:

Representation of

Description

"0 0 12 * *?"

Run at 12 every day.

"0 15 10?" * *"

Run 10:15 every day

"0 15 10 * *?"

Run 10:15 every day

"0 15 10 * *? *"

Run 10:15 every day

"0 15 10 * *? 2008 "

Running 10:15 every day in 2008.

"0 * 14 * *?"

Run every minute between 14 o'clock and 15 every day, starting at 14:00 and ending at 14:59.

"0 0/5 14 * *?"

Run every 5 minutes from 14 o'clock to 15 every day, starting at 14:00 and ending at 14:55.

"0 0/5 14,18 * *?"

Run every 5 minutes from 14 o'clock to 15 every day, and also every 5 minutes every 18 o'clock to 19 o ' clock.

"0 0-5 14 * *?"

Every day 14:00 to 14:05, run every minute.

"0 10,44 14?" 3 WED "

March every Wednesday of 14:10 minutes to 14:44, run every minute.

"0 15 10?" * Mon-fri "

Run for 10:15 minutes per Monday, two, three, four, five.

"0 15 10 15 *?"

Every month 15th 10:15 minutes run.

"0 L *?"

Run 10:15 on the last day of each month.

"0 15 10?" * 6L "

Run at the last Friday 10:15 per month.

"0 15 10?" * 6L 2007-2009 "

Run in the last Friday of the 2007,2008,2009 year of 10:15 minutes per month.

"0 15 10?" * 6#3 "

10:15 minutes per month for the third Friday run.

2 Configure Scheduled Tasks

The variable jobtemplate in the structure body scheduledjobspec is a job template structure variable that holds the job that needs to be executed according to the execution plan, and can be seen from the following figure, through which you can find the job that needs to be performed. That is, the SCHEDULEDJOBSPEC structure, through the SCHEDULEDJOBSPEC structure template can find the job corresponding to the pod, that is, the PODSPEC structure. So kubernetes is a container-centric platform for the pod, and the job's final operation is reflected in the pod's operation.


3 Configure scheduled Task concurrent processing policy

The variable concurrencypolicy in struct Scheduledjobspec is a string variable that specifies the processing policy for a job when it executes concurrently.


The Concurrencypolicy values include "Allow", "forbid", "Replace" three types, meaning the following:

1) Allow: Allows a job to execute concurrently, and can perform a new job once the previous job has finished without execution.

2) Forbid: a job is not allowed to execute concurrently, and a new job cannot be executed again when the previous job has not finished executing.

3 Replace: Do not allow a job concurrent execution, when the previous job at the end of no execution, you can perform a new job here, but the job that has not performed the end is canceled.

If Concurrencypolicy is not set, then kubernetes1.3 default concurrencypolicy is "Allow".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.