v1

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package v1 is the v1 version of the API. +groupName=training.kubedl.io

Index

Constants

View Source
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"

	// ReplicaNameLabel represents the label key for the replica-name, the value is replica name.
	ReplicaNameLabel = "replica-name"

	// 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"
)
View Source
const (
	KubeDLPrefix = "kubedl.io"

	// AnnotationGitSyncConfig annotate git sync configurations.
	AnnotationGitSyncConfig = KubeDLPrefix + "/git-sync-config"
	// AnnotationTenancyInfo annotate tenancy information.
	AnnotationTenancyInfo = KubeDLPrefix + "/tenancy"
	// AnnotationNetworkMode annotate job network mode.
	AnnotationNetworkMode = KubeDLPrefix + "/network-mode"

	// AnnotationTensorBoardConfig annotate tensorboard configurations.
	AnnotationTensorBoardConfig = KubeDLPrefix + "/tensorboard-config"
	// ReplicaTypeTensorBoard is the type for TensorBoard.
	ReplicaTypeTensorBoard ReplicaType = "TensorBoard"
	//ResourceNvidiaGPU is the key of gpu type in labels
	ResourceNvidiaGPU v1.ResourceName = "nvidia.com/gpu"
)

Constant label/annotation keys for job configuration.

View Source
const (
	// LabelInferenceName represents the inference service name.
	LabelInferenceName = KubeDLPrefix + "/inference-name"
	// LabelPredictorName represents the predictor name of served model.
	LabelPredictorName = KubeDLPrefix + "/predictor-name"
	// LabelModelVersion represents the model version value for inference role.
	LabelModelVersion = KubeDLPrefix + "/model-version"
	// LabelCronName indicates the name of cron who created this job.
	LabelCronName = KubeDLPrefix + "/cron-name"
	// LabelGangSchedulingJobName indicates name of gang scheduled job.
	LabelGangSchedulingJobName = KubeDLPrefix + "/gang-job-name"
)

Variables

This section is empty.

Functions

func RegisterDefaults

func RegisterDefaults(scheme *runtime.Scheme) error

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

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 ConcurrencyPolicy added in v0.4.2

type ConcurrencyPolicy string

ConcurrencyPolicy describes how the job will be handled. Only one of the following concurrent policies may be specified. If none of the following policies is specified, the default one is AllowConcurrent.

const (
	// AllowConcurrent allows CronJobs to run concurrently.
	AllowConcurrent ConcurrencyPolicy = "Allow"

	// ForbidConcurrent forbids concurrent runs, skipping next run if previous
	// hasn't finished yet.
	ForbidConcurrent ConcurrencyPolicy = "Forbid"

	// ReplaceConcurrent cancels currently running job and replaces it with a new one.
	ReplaceConcurrent ConcurrencyPolicy = "Replace"
)

type ControllerInterface

type ControllerInterface interface {
	//ControllerName Returns the Controller name
	ControllerName() string

	// GetAPIGroupVersionKind Returns the GroupVersionKind of the API
	GetAPIGroupVersionKind() schema.GroupVersionKind

	// GetAPIGroupVersion Returns the GroupVersion of the API
	GetAPIGroupVersion() schema.GroupVersion

	// GetGroupNameLabelValue Returns the Group Name(value) in the labels of the job
	GetGroupNameLabelValue() string

	// GetJobFromInformerCache Returns the Job from Informer Cache
	GetJobFromInformerCache(namespace, name string) (v1.Object, error)

	// GetJobFromAPIClient 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)

	// GetNodeForModelOutput returns the nodeName where the model is output, in case of local storage.
	// If model is output in remote storage, this will return "Any".
	GetNodeForModelOutput(pods []*corev1.Pod) (nodeName string)

	// 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, restart bool) error

	// UpdateJobStatusInApiServer updates the job status in API server
	UpdateJobStatusInApiServer(job interface{}, jobStatus *JobStatus) error

	// SetClusterSpec sets the cluster spec for the pod
	SetClusterSpec(ctx context.Context, job interface{}, podTemplate *corev1.PodTemplateSpec, rtype, index string) error

	// GetDefaultContainerName Returns the default container name in pod
	GetDefaultContainerName() string

	// GetDefaultContainerPortName Get the default container port name
	GetDefaultContainerPortName() string

	// GetDefaultContainerPortNumber Get the default container port number
	GetDefaultContainerPortNumber() int32

	// GetReconcileOrders Get replicas reconcile orders so that replica type with higher priority can be created earlier.
	GetReconcileOrders() []ReplicaType

	// IsMasterRole 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 CronPolicy added in v0.4.2

type CronPolicy struct {
	// The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
	Schedule string `json:"schedule"`

	// Specifies how to treat concurrent executions of a Task.
	// 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
	// +optional
	ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"`

	// This flag tells the controller to suspend subsequent executions, it does
	// not apply to already started executions.  Defaults to false.
	// +optional
	Suspend *bool `json:"suspend,omitempty"`

	// Deadline is the timestamp that a cron job can keep scheduling util then.
	Deadline *metav1.Time `json:"deadline,omitempty"`

	// The number of finished job history to retain.
	// This is a pointer to distinguish between explicit zero and not specified.
	// +optional
	HistoryLimit *int32 `json:"historyLimit,omitempty"`
}

func (*CronPolicy) DeepCopy added in v0.4.2

func (in *CronPolicy) DeepCopy() *CronPolicy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronPolicy.

func (*CronPolicy) DeepCopyInto added in v0.4.2

func (in *CronPolicy) DeepCopyInto(out *CronPolicy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type DAGCondition added in v0.4.0

type DAGCondition struct {
	// Upstream defines which replica type is the source tigger.
	Upstream ReplicaType `json:"upstream"`
	// OnPhase defines at which phase the upstream replica will trigger this condition.
	OnPhase v1.PodPhase `json:"onPhase"`
}

func (*DAGCondition) DeepCopy added in v0.4.2

func (in *DAGCondition) DeepCopy() *DAGCondition

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DAGCondition.

func (*DAGCondition) DeepCopyInto added in v0.4.2

func (in *DAGCondition) DeepCopyInto(out *DAGCondition)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

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"`
}

JobCondition describes the state of the job at a certain point. +k8s:deepcopy-gen=true

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"

	// JobQueuing means the job has been acknowledged by controller and
	// queueing in its tenant queue, waiting to be dequeued and start to
	// reconcile.
	// The training is waiting to be scheduled by kubedl.
	JobQueuing JobConditionType = "Queuing"

	// 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 JobStatus

type JobStatus struct {
	// Conditions is an array of current observed job conditions.
	Conditions []JobCondition `json:"conditions,omitempty"`

	// 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"`

	// ModelVersionName represents the model version name output by this job run.
	ModelVersionName string `json:"modelVersionName,omitempty"`

	// CacheBackendName is the name for the backend cache
	CacheBackendName string `json:"cacheBackendName,omitempty"`
}

JobStatus represents the current observed state of the training Job. +k8s:deepcopy-gen=true

func (*JobStatus) DeepCopy

func (in *JobStatus) DeepCopy() *JobStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JobStatus.

func (*JobStatus) DeepCopyInto

func (in *JobStatus) DeepCopyInto(out *JobStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type NetworkMode added in v0.2.0

type NetworkMode string

NetworkMode defines network mode for intra job communicating.

const (
	// HostNetworkMode indicates that replicas use host-network to communicate with each other.
	HostNetworkMode NetworkMode = "host"
)

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"`

	// Spot replicas are a subset of Replicas that allow for interruptions. They can use resources with less SLO guarantee.
	// Spot replicas are suitable for stateless or fault-tolerant jobs.
	// These replicas can be scheduled with higher chance at lower resource pricing.
	SpotReplicaSpec *SpotReplicaSpec `json:"spotReplicaSpec,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"`

	// DependOn represents a list of upstream vertex conditions to be dependent on for this RepicaType to start.
	// For example, in TensorFlow workers depend on ps to start first. If not set, KubeDL will populates the
	// default DependOn based on each framework's requirements. This feature is enabled by default, and can be
	// disabled with DAGScheduling feature gate.
	DependOn []DAGCondition `json:"-"`
}

ReplicaSpec is a description of the replica. +k8s:deepcopy-gen=true

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"`

	// The number of pods which reached phase Failed and reason is Evicted,
	// it is included in the number of Failed.
	Evicted int32 `json:"evicted,omitempty"`
}

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

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"`

	// +optional
	CronPolicy *CronPolicy `json:"cronPolicy,omitempty"`
}

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. +k8s:deepcopy-gen=true

func (*RunPolicy) DeepCopy

func (in *RunPolicy) DeepCopy() *RunPolicy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunPolicy.

func (*RunPolicy) DeepCopyInto

func (in *RunPolicy) DeepCopyInto(out *RunPolicy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SchedulingPolicy

type SchedulingPolicy struct {
	// MinAvailable is the minimum number of scheduable instances for a gang-scheduling to go.
	MinAvailable *int32 `json:"minAvailable,omitempty"`
	// The priority value. KubeDL use this field to find the priority of the job.
	// The controller populates this field from PriorityClassName by default.
	// The higher the value, the higher the priority.
	// +optional
	Priority *int32 `json:"priority,omitempty"`
	// If specified, indicates the jobs's priority. Any other name must be defined
	// by creating a PriorityClass object with that name.
	// If not specified, the job priority will be default or zero if there is no
	// default.
	// +optional
	PriorityClassName string `json:"priorityClassName,omitempty"`
	// Queue indicates the name of tenant queue the job should be enqueued to, this field
	// can be specified manually by job owner, or partitioned by built-in plugin on basis
	// of its namespace/quota or other granularity.
	// +optional
	Queue string `json:"queue,omitempty"`
}

SchedulingPolicy encapsulates various scheduling policies of the distributed training job, for example `minAvailable` for gang-scheduling.

func (*SchedulingPolicy) DeepCopy

func (in *SchedulingPolicy) DeepCopy() *SchedulingPolicy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchedulingPolicy.

func (*SchedulingPolicy) DeepCopyInto

func (in *SchedulingPolicy) DeepCopyInto(out *SchedulingPolicy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SpotReplicaSpec added in v0.4.2

type SpotReplicaSpec struct {
	// SpotReplicaNumber is the desired number of spot replicas.
	// If unspecified, SpotReplicaNumber defaults to 0.
	// By default, replicas with index in the range from (Replicas - SpotReplicaNumber) to (Replicas -1 ) are spot replicas.
	SpotReplicaNumber int32 `json:"spotReplicaNumber,omitempty"`
	// PriorityClassName is the priorityClassName of spot replicas, to override that in replica template.
	PriorityClassName string `json:"priorityClassName,omitempty"`
	// Labels are the extra set of labels to add on the spot replicas, overriding coinciding labels in the replica template if any.
	Labels map[string]string `json:"labels,omitempty"`
}

SpotReplicaSpec is the differential spec of spot replicas, to override the replica template.

func (*SpotReplicaSpec) DeepCopy added in v0.4.2

func (in *SpotReplicaSpec) DeepCopy() *SpotReplicaSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpotReplicaSpec.

func (*SpotReplicaSpec) DeepCopyInto added in v0.4.2

func (in *SpotReplicaSpec) DeepCopyInto(out *SpotReplicaSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type SuccessPolicy added in v0.4.0

type SuccessPolicy string

SuccessPolicy is the policy to mark the job as succeeded, when the job does not contain the chief or master role.

const (
	// SuccessPolicyDefault indicates the job is succeeded if all workers are succeeded or worker 0 completed
	SuccessPolicyDefault SuccessPolicy = ""
	// SuccessPolicyAllWorkers indicates the job is succeeded if all workers are succeeded.
	SuccessPolicyAllWorkers SuccessPolicy = "AllWorkers"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL