Documentation
¶
Overview ¶
Package v1 is the v1 version of the API. +groupName=kubeflow.org
Copyright 2018 The Kubeflow Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition
- func RegisterDefaults(scheme *runtime.Scheme) error
- type CleanPodPolicy
- type ControllerInterface
- type JobCondition
- type JobConditionType
- type JobController
- type JobControllerConfiguration
- type JobStatus
- type ReplicaSpec
- type ReplicaStatus
- type ReplicaType
- type RestartPolicy
- type RunPolicy
- type SchedulingPolicy
Constants ¶
const ( // ReplicaIndexLabel represents the label key for the replica-index, e.g. the value is 0, 1, 2.. etc ReplicaIndexLabel = "replica-index" // ReplicaTypeLabel represents the label key for the replica-type, e.g. the value is ps , worker etc. ReplicaTypeLabel = "replica-type" // GroupNameLabel represents the label key for group name, e.g. the value is kubeflow.org GroupNameLabel = "group-name" // JobNameLabel represents the label key for the job name, the value is job name JobNameLabel = "job-name" // JobRoleLabel represents the label key for the job role, e.g. the value is master JobRoleLabel = "job-role" )
Variables ¶
This section is empty.
Functions ¶
func GetOpenAPIDefinitions ¶
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition
func RegisterDefaults ¶
RegisterDefaults adds defaulters functions to the given scheme. Public to allow building arbitrary schemes. All generated defaulters are covering - they call all nested defaulters.
Types ¶
type CleanPodPolicy ¶
type CleanPodPolicy string
+k8s:openapi-gen=true CleanPodPolicy describes how to deal with pods when the job is finished.
const ( CleanPodPolicyUndefined CleanPodPolicy = "" CleanPodPolicyAll CleanPodPolicy = "All" CleanPodPolicyRunning CleanPodPolicy = "Running" CleanPodPolicyNone CleanPodPolicy = "None" )
type ControllerInterface ¶
type ControllerInterface interface { // Returns the Controller name ControllerName() string // Returns the GroupVersionKind of the API GetAPIGroupVersionKind() schema.GroupVersionKind // Returns the GroupVersion of the API GetAPIGroupVersion() schema.GroupVersion // Returns the Group Name(value) in the labels of the job GetGroupNameLabelValue() string // Returns the Job from Informer Cache GetJobFromInformerCache(namespace, name string) (v1.Object, error) // Returns the Job from API server GetJobFromAPIClient(namespace, name string) (v1.Object, error) // GetPodsForJob returns the pods managed by the job. This can be achieved by selecting pods using label key "job-name" // i.e. all pods created by the job will come with label "job-name" = <this_job_name> GetPodsForJob(job interface{}) ([]*corev1.Pod, error) // GetServicesForJob returns the services managed by the job. This can be achieved by selecting services using label key "job-name" // i.e. all services created by the job will come with label "job-name" = <this_job_name> GetServicesForJob(job interface{}) ([]*corev1.Service, error) // DeleteJob deletes the job DeleteJob(job interface{}) error // UpdateJobStatus updates the job status and job conditions UpdateJobStatus(job interface{}, replicas map[ReplicaType]*ReplicaSpec, jobStatus *JobStatus) error // UpdateJobStatusInApiServer updates the job status in API server UpdateJobStatusInApiServer(job interface{}, jobStatus *JobStatus) error // CreateService creates the service CreateService(job interface{}, service *corev1.Service) error // DeleteService deletes the service DeleteService(job interface{}, name string, namespace string) error // CreatePod creates the pod CreatePod(job interface{}, pod *corev1.Pod) error // DeletePod deletes the pod DeletePod(job interface{}, pod *corev1.Pod) error // SetClusterSpec sets the cluster spec for the pod SetClusterSpec(job interface{}, podTemplate *corev1.PodTemplateSpec, rtype, index string) error // Returns the default container name in pod GetDefaultContainerName() string // Get the default container port name GetDefaultContainerPortName() string // Get the default container port number GetDefaultContainerPortNumber() int32 // Returns if this replica type with index specified is a master role. // MasterRole pod will have "job-role=master" set in its label IsMasterRole(replicas map[ReplicaType]*ReplicaSpec, rtype ReplicaType, index int) bool }
ControllerInterface defines the Interface to be implemented by custom operators. e.g. tf-operator needs to implement this interface
type JobCondition ¶
type JobCondition struct { // Type of job condition. Type JobConditionType `json:"type"` // Status of the condition, one of True, False, Unknown. Status v1.ConditionStatus `json:"status"` // The reason for the condition's last transition. Reason string `json:"reason,omitempty"` // A human readable message indicating details about the transition. Message string `json:"message,omitempty"` // The last time this condition was updated. LastUpdateTime metav1.Time `json:"lastUpdateTime,omitempty"` // Last time the condition transitioned from one status to another. LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` }
+k8s:openapi-gen=true +k8s:deepcopy-gen=true JobCondition describes the state of the job at a certain point.
func (*JobCondition) DeepCopy ¶
func (in *JobCondition) DeepCopy() *JobCondition
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JobCondition.
func (*JobCondition) DeepCopyInto ¶
func (in *JobCondition) DeepCopyInto(out *JobCondition)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type JobConditionType ¶
type JobConditionType string
JobConditionType defines all kinds of types of JobStatus.
const ( // JobCreated means the job has been accepted by the system, // but one or more of the pods/services has not been started. // This includes time before pods being scheduled and launched. JobCreated JobConditionType = "Created" // JobRunning means all sub-resources (e.g. services/pods) of this job // have been successfully scheduled and launched. // The training is running without error. JobRunning JobConditionType = "Running" // JobRestarting means one or more sub-resources (e.g. services/pods) of this job // reached phase failed but maybe restarted according to it's restart policy // which specified by user in v1.PodTemplateSpec. // The training is freezing/pending. JobRestarting JobConditionType = "Restarting" // JobSucceeded means all sub-resources (e.g. services/pods) of this job // reached phase have terminated in success. // The training is complete without error. JobSucceeded JobConditionType = "Succeeded" // JobFailed means one or more sub-resources (e.g. services/pods) of this job // reached phase failed with no restarting. // The training has failed its execution. JobFailed JobConditionType = "Failed" )
type JobController ¶
type JobController struct { Controller ControllerInterface Config JobControllerConfiguration // KubeClientSet is a standard kubernetes clientset. KubeClientSet kubeclientset.Interface // KubeBatchClientSet is a standard kube-batch clientset. KubeBatchClientSet kubebatchclient.Interface // PodLister can list/get pods from the shared informer's store. PodLister corelisters.PodLister // ServiceLister can list/get services from the shared informer's store. ServiceLister corelisters.ServiceLister // PodInformerSynced returns true if the pod store has been synced at least once. PodInformerSynced cache.InformerSynced // ServiceInformerSynced returns true if the service store has been synced at least once. ServiceInformerSynced cache.InformerSynced // A TTLCache of pod/services creates/deletes each job expects to see // We use Job namespace/name + ReplicaType + pods/services as an expectation key, // For example, there is a TFJob with namespace "tf-operator" and name "tfjob-abc": // { // "PS": { // "Replicas": 2, // }, // "Worker": { // "Replicas": 4, // } // } // We will create 4 expectations: // - "tf-operator/tfjob-abc/ps/services", expects 2 adds. // - "tf-operator/tfjob-abc/ps/pods", expects 2 adds. // - "tf-operator/tfjob-abc/worker/services", expects 4 adds. // - "tf-operator/tfjob-abc/worker/pods", expects 4 adds. Expectations controller.ControllerExpectationsInterface // WorkQueue is a rate limited work queue. This is used to queue work to be // processed instead of performing it as soon as a change happens. This // means we can ensure we only process a fixed amount of resources at a // time, and makes it easy to ensure we are never processing the same item // simultaneously in two different workers. WorkQueue workqueue.RateLimitingInterface // Recorder is an event recorder for recording Event resources to the // Kubernetes API. Recorder record.EventRecorder }
JobController abstracts other operators to manage the lifecycle of Jobs. User need to first implement the ControllerInterface(objectA) and then initialize a JobController(objectB) struct with objectA as the parameter. And then call objectB.ReconcileJobs as mentioned below, the ReconcileJobs method is the entrypoint to trigger the reconcile logic of the job controller
ReconcileJobs(
job interface{}, replicas map[apiv1.ReplicaType]*apiv1.ReplicaSpec, jobStatus apiv1.JobStatus, runPolicy *apiv1.RunPolicy) error
func NewJobController ¶
func NewJobController( controllerImpl ControllerInterface, reconcilerSyncPeriod metav1.Duration, enableGangScheduling bool, kubeClientSet kubeclientset.Interface, kubeBatchClientSet kubebatchclient.Interface, kubeInformerFactory kubeinformers.SharedInformerFactory, workQueueName string) JobController
type JobControllerConfiguration ¶
type JobControllerConfiguration struct { // ReconcilerSyncLoopPeriod is the amount of time the reconciler sync states loop // wait between two reconciler sync. // It is set to 15 sec by default. // TODO(cph): maybe we can let it grows by multiple in the future // and up to 5 minutes to reduce idle loop. // e.g. 15s, 30s, 60s, 120s... ReconcilerSyncLoopPeriod metav1.Duration // Enable gang scheduling by kube-batch EnableGangScheduling bool }
JobControllerConfiguration contains configuration of operator.
type JobStatus ¶
type JobStatus struct { // Conditions is an array of current observed job conditions. Conditions []JobCondition `json:"conditions"` // ReplicaStatuses is map of ReplicaType and ReplicaStatus, // specifies the status of each replica. ReplicaStatuses map[ReplicaType]*ReplicaStatus `json:"replicaStatuses"` // Represents time when the job was acknowledged by the job controller. // It is not guaranteed to be set in happens-before order across separate operations. // It is represented in RFC3339 form and is in UTC. StartTime *metav1.Time `json:"startTime,omitempty"` // Represents time when the job was completed. It is not guaranteed to // be set in happens-before order across separate operations. // It is represented in RFC3339 form and is in UTC. CompletionTime *metav1.Time `json:"completionTime,omitempty"` // Represents last time when the job was reconciled. It is not guaranteed to // be set in happens-before order across separate operations. // It is represented in RFC3339 form and is in UTC. LastReconcileTime *metav1.Time `json:"lastReconcileTime,omitempty"` }
+k8s:openapi-gen=true +k8s:deepcopy-gen=true JobStatus represents the current observed state of the training Job.
func (*JobStatus) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JobStatus.
func (*JobStatus) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ReplicaSpec ¶
type ReplicaSpec struct { // Replicas is the desired number of replicas of the given template. // If unspecified, defaults to 1. Replicas *int32 `json:"replicas,omitempty"` // Template is the object that describes the pod that // will be created for this replica. RestartPolicy in PodTemplateSpec // will be overide by RestartPolicy in ReplicaSpec Template v1.PodTemplateSpec `json:"template,omitempty"` // Restart policy for all replicas within the job. // One of Always, OnFailure, Never and ExitCode. // Default to Never. RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"` }
+k8s:openapi-gen=true +k8s:deepcopy-gen=true ReplicaSpec is a description of the replica
func (*ReplicaSpec) DeepCopy ¶
func (in *ReplicaSpec) DeepCopy() *ReplicaSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReplicaSpec.
func (*ReplicaSpec) DeepCopyInto ¶
func (in *ReplicaSpec) DeepCopyInto(out *ReplicaSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ReplicaStatus ¶
type ReplicaStatus struct { // The number of actively running pods. Active int32 `json:"active,omitempty"` // The number of pods which reached phase Succeeded. Succeeded int32 `json:"succeeded,omitempty"` // The number of pods which reached phase Failed. Failed int32 `json:"failed,omitempty"` }
+k8s:openapi-gen=true ReplicaStatus represents the current observed state of the replica.
func (*ReplicaStatus) DeepCopy ¶
func (in *ReplicaStatus) DeepCopy() *ReplicaStatus
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReplicaStatus.
func (*ReplicaStatus) DeepCopyInto ¶
func (in *ReplicaStatus) DeepCopyInto(out *ReplicaStatus)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type ReplicaType ¶
type ReplicaType string
+k8s:openapi-gen=true ReplicaType represents the type of the replica. Each operator needs to define its own set of ReplicaTypes.
type RestartPolicy ¶
type RestartPolicy string
RestartPolicy describes how the replicas should be restarted. Only one of the following restart policies may be specified. If none of the following policies is specified, the default one is RestartPolicyAlways.
const ( RestartPolicyAlways RestartPolicy = "Always" RestartPolicyOnFailure RestartPolicy = "OnFailure" RestartPolicyNever RestartPolicy = "Never" // RestartPolicyExitCode policy means that user should add exit code by themselves, // The job operator will check these exit codes to // determine the behavior when an error occurs: // - 1-127: permanent error, do not restart. // - 128-255: retryable error, will restart the pod. RestartPolicyExitCode RestartPolicy = "ExitCode" )
type RunPolicy ¶
type RunPolicy struct { // CleanPodPolicy defines the policy to kill pods after the job completes. // Default to Running. CleanPodPolicy *CleanPodPolicy `json:"cleanPodPolicy,omitempty"` // TTLSecondsAfterFinished is the TTL to clean up jobs. // It may take extra ReconcilePeriod seconds for the cleanup, since // reconcile gets called periodically. // Default to infinite. TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"` // Specifies the duration in seconds relative to the startTime that the job may be active // before the system tries to terminate it; value must be positive integer. // +optional ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty"` // Optional number of retries before marking this job failed. // +optional BackoffLimit *int32 `json:"backoffLimit,omitempty"` // SchedulingPolicy defines the policy related to scheduling, e.g. gang-scheduling // +optional SchedulingPolicy *SchedulingPolicy `json:"schedulingPolicy,omitempty"` }
+k8s:deepcopy-gen=true RunPolicy encapsulates various runtime policies of the distributed training job, for example how to clean up resources and how long the job can stay active.
func (*RunPolicy) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunPolicy.
func (*RunPolicy) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type SchedulingPolicy ¶
type SchedulingPolicy struct {
MinAvailable *int32 `json:"minAvailable,omitempty"`
}
SchedulingPolicy encapsulates various scheduling policies of the distributed training job, for example `minAvailable` for gang-scheduling.