...

Source file src/k8s.io/api/batch/v1beta1/types.go

Documentation: k8s.io/api/batch/v1beta1

     1  /*
     2  Copyright 2017 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1beta1
    18  
    19  import (
    20  	batchv1 "k8s.io/api/batch/v1"
    21  	v1 "k8s.io/api/core/v1"
    22  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    23  )
    24  
    25  // JobTemplateSpec describes the data a Job should have when created from a template
    26  type JobTemplateSpec struct {
    27  	// Standard object's metadata of the jobs created from this template.
    28  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    29  	// +optional
    30  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    31  
    32  	// Specification of the desired behavior of the job.
    33  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
    34  	// +optional
    35  	Spec batchv1.JobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    36  }
    37  
    38  // +genclient
    39  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    40  // +k8s:prerelease-lifecycle-gen:introduced=1.8
    41  // +k8s:prerelease-lifecycle-gen:deprecated=1.21
    42  // +k8s:prerelease-lifecycle-gen:removed=1.25
    43  // +k8s:prerelease-lifecycle-gen:replacement=batch,v1,CronJob
    44  
    45  // CronJob represents the configuration of a single cron job.
    46  type CronJob struct {
    47  	metav1.TypeMeta `json:",inline"`
    48  	// Standard object's metadata.
    49  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    50  	// +optional
    51  	metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    52  
    53  	// Specification of the desired behavior of a cron job, including the schedule.
    54  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
    55  	// +optional
    56  	Spec CronJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
    57  
    58  	// Current status of a cron job.
    59  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
    60  	// +optional
    61  	Status CronJobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
    62  }
    63  
    64  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    65  // +k8s:prerelease-lifecycle-gen:introduced=1.8
    66  // +k8s:prerelease-lifecycle-gen:deprecated=1.21
    67  // +k8s:prerelease-lifecycle-gen:removed=1.25
    68  // +k8s:prerelease-lifecycle-gen:replacement=batch,v1,CronJobList
    69  
    70  // CronJobList is a collection of cron jobs.
    71  type CronJobList struct {
    72  	metav1.TypeMeta `json:",inline"`
    73  
    74  	// Standard list metadata.
    75  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    76  	// +optional
    77  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    78  
    79  	// items is the list of CronJobs.
    80  	Items []CronJob `json:"items" protobuf:"bytes,2,rep,name=items"`
    81  }
    82  
    83  // CronJobSpec describes how the job execution will look like and when it will actually run.
    84  type CronJobSpec struct {
    85  
    86  	// The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
    87  	Schedule string `json:"schedule" protobuf:"bytes,1,opt,name=schedule"`
    88  
    89  	// The time zone name for the given schedule, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
    90  	// If not specified, this will default to the time zone of the kube-controller-manager process.
    91  	// The set of valid time zone names and the time zone offset is loaded from the system-wide time zone
    92  	// database by the API server during CronJob validation and the controller manager during execution.
    93  	// If no system-wide time zone database can be found a bundled version of the database is used instead.
    94  	// If the time zone name becomes invalid during the lifetime of a CronJob or due to a change in host
    95  	// configuration, the controller will stop creating new new Jobs and will create a system event with the
    96  	// reason UnknownTimeZone.
    97  	// More information can be found in https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones
    98  	// +optional
    99  	TimeZone *string `json:"timeZone,omitempty" protobuf:"bytes,8,opt,name=timeZone"`
   100  
   101  	// Optional deadline in seconds for starting the job if it misses scheduled
   102  	// time for any reason.  Missed jobs executions will be counted as failed ones.
   103  	// +optional
   104  	StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty" protobuf:"varint,2,opt,name=startingDeadlineSeconds"`
   105  
   106  	// Specifies how to treat concurrent executions of a Job.
   107  	// Valid values are:
   108  	//
   109  	// - "Allow" (default): allows CronJobs to run concurrently;
   110  	// - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet;
   111  	// - "Replace": cancels currently running job and replaces it with a new one
   112  	// +optional
   113  	ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty" protobuf:"bytes,3,opt,name=concurrencyPolicy,casttype=ConcurrencyPolicy"`
   114  
   115  	// This flag tells the controller to suspend subsequent executions, it does
   116  	// not apply to already started executions.  Defaults to false.
   117  	// +optional
   118  	Suspend *bool `json:"suspend,omitempty" protobuf:"varint,4,opt,name=suspend"`
   119  
   120  	// Specifies the job that will be created when executing a CronJob.
   121  	JobTemplate JobTemplateSpec `json:"jobTemplate" protobuf:"bytes,5,opt,name=jobTemplate"`
   122  
   123  	// The number of successful finished jobs to retain.
   124  	// This is a pointer to distinguish between explicit zero and not specified.
   125  	// Defaults to 3.
   126  	// +optional
   127  	SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty" protobuf:"varint,6,opt,name=successfulJobsHistoryLimit"`
   128  
   129  	// The number of failed finished jobs to retain.
   130  	// This is a pointer to distinguish between explicit zero and not specified.
   131  	// Defaults to 1.
   132  	// +optional
   133  	FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty" protobuf:"varint,7,opt,name=failedJobsHistoryLimit"`
   134  }
   135  
   136  // ConcurrencyPolicy describes how the job will be handled.
   137  // Only one of the following concurrent policies may be specified.
   138  // If none of the following policies is specified, the default one
   139  // is AllowConcurrent.
   140  type ConcurrencyPolicy string
   141  
   142  const (
   143  	// AllowConcurrent allows CronJobs to run concurrently.
   144  	AllowConcurrent ConcurrencyPolicy = "Allow"
   145  
   146  	// ForbidConcurrent forbids concurrent runs, skipping next run if previous
   147  	// hasn't finished yet.
   148  	ForbidConcurrent ConcurrencyPolicy = "Forbid"
   149  
   150  	// ReplaceConcurrent cancels currently running job and replaces it with a new one.
   151  	ReplaceConcurrent ConcurrencyPolicy = "Replace"
   152  )
   153  
   154  // CronJobStatus represents the current state of a cron job.
   155  type CronJobStatus struct {
   156  	// A list of pointers to currently running jobs.
   157  	// +optional
   158  	// +listType=atomic
   159  	Active []v1.ObjectReference `json:"active,omitempty" protobuf:"bytes,1,rep,name=active"`
   160  
   161  	// Information when was the last time the job was successfully scheduled.
   162  	// +optional
   163  	LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty" protobuf:"bytes,4,opt,name=lastScheduleTime"`
   164  
   165  	// Information when was the last time the job successfully completed.
   166  	// +optional
   167  	LastSuccessfulTime *metav1.Time `json:"lastSuccessfulTime,omitempty" protobuf:"bytes,5,opt,name=lastSuccessfulTime"`
   168  }
   169  

View as plain text