Skip to content

Commit

Permalink
Merge pull request #63 from QiJune/edl
Browse files Browse the repository at this point in the history
elasticdljob: type definition and controller implementation of elasticdljob workload.
  • Loading branch information
SimonCqk authored Oct 20, 2020
2 parents 6033305 + 2f74278 commit a65735c
Show file tree
Hide file tree
Showing 23 changed files with 4,892 additions and 49 deletions.
23 changes: 23 additions & 0 deletions api/addtoscheme_elasticdljob_v1alpha1.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2019 The Alibaba 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.
*/

package api

import "github.com/alibaba/kubedl/api/elasticdljob/v1alpha1"

func init() {
AddToSchemes = append(AddToSchemes, v1alpha1.AddToScheme)
}
12 changes: 11 additions & 1 deletion api/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,24 @@ limitations under the License.

// Generate deepcopy for pytorch apis.
//go:generate go run $GOPATH/src/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./pytorch/... -h ../hack/boilerplate.go.txt
// Generate default for tensorflow apis.
// Generate default for pytorch apis.
//go:generate go run $GOPATH/src/k8s.io/code-generator/cmd/defaulter-gen/main.go -O zz_generated.defaults -i ./pytorch/... -h ../hack/boilerplate.go.txt

// Generate deepcopy for xgboost apis.
//go:generate go run $GOPATH/src/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./xgboost/... -h ../hack/boilerplate.go.txt
// Generate default for xgboost apis.
//go:generate go run $GOPATH/src/k8s.io/code-generator/cmd/defaulter-gen/main.go -O zz_generated.defaults -i ./xgboost/... -h ../hack/boilerplate.go.txt

// Generate deepcopy for marsjob apis.
//go:generate go run $GOPATH/src/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./marsjob/... -h ../hack/boilerplate.go.txt
// Generate default for elasticdljob apis.
//go:generate go run $GOPATH/src/k8s.io/code-generator/cmd/defaulter-gen/main.go -O zz_generated.defaults -i ./marsjob/... -h ../hack/boilerplate.go.txt

// Generate deepcopy for elasticdljob apis.
//go:generate go run $GOPATH/src/k8s.io/code-generator/cmd/deepcopy-gen/main.go -O zz_generated.deepcopy -i ./elasticdljob/... -h ../hack/boilerplate.go.txt
// Generate default for elasticdljob apis.
//go:generate go run $GOPATH/src/k8s.io/code-generator/cmd/defaulter-gen/main.go -O zz_generated.defaults -i ./elasticdljob/... -h ../hack/boilerplate.go.txt

package api

import (
Expand Down
7 changes: 7 additions & 0 deletions api/elasticdljob/v1alpha1/constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package v1alpha1

const (
DefaultContainerName = "elasticdl"
DefaultPortName = "elasticdl-port"
DefaultPort = 11111
)
89 changes: 89 additions & 0 deletions api/elasticdljob/v1alpha1/elasticdljob_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
Copyright 2020 The Alibaba 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.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

common "github.com/alibaba/kubedl/pkg/job_controller/api/v1"
)

// ElasticDLJobSpec is a desired state description of the ElasticDLJob.
type ElasticDLJobSpec struct {
// 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.
common.RunPolicy `json:",inline"`

// A map of ElasticDLReplicaType (type) to ReplicaSpec (value). Specifies the ElasticDL cluster configuration.
// For example,
// {
// "Master": ElasticDLReplicaSpec,
// }
ElasticDLReplicaSpecs map[common.ReplicaType]*common.ReplicaSpec `json:"elasticdlReplicaSpecs"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:defaulter-gen=TypeMeta
// +resource:path=elasticdljob
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Namespaced
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.conditions[-1:].type`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:printcolumn:name="Finished-TTL",type=integer,JSONPath=`.spec.ttlSecondsAfterFinished`
// +kubebuilder:printcolumn:name="Max-Lifetime",type=integer,JSONPath=`.spec.activeDeadlineSeconds`

// ElasticDLJob Represents an elasticdl Job instance
type ElasticDLJob struct {
// Standard Kubernetes type metadata.
metav1.TypeMeta `json:",inline"`

// Standard Kubernetes object's metadata.
metav1.ObjectMeta `json:"metadata,omitempty"`

// Specification of the desired state of the ElasticDLJob.
Spec ElasticDLJobSpec `json:"spec,omitempty"`

// Most recently observed status of the ElasticDLJob.
// Read-only (modified by the system).
Status common.JobStatus `json:"status,omitempty"`
}

const (
// ElasticDLReplicaTypeMaster is the type of Master of distributed ElasticDL
ElasticDLReplicaTypeMaster common.ReplicaType = "Master"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +resource:path=elasticdljobs

// ElasticDLJobList is a list of ElasticDLJobs.
type ElasticDLJobList struct {
// Standard type metadata.
metav1.TypeMeta `json:",inline"`

// Standard list metadata.
metav1.ListMeta `json:"metadata,omitempty"`

// List of ElasticDLJobs.
Items []ElasticDLJob `json:"items"`
}

func init() {
SchemeBuilder.Register(&ElasticDLJob{}, &ElasticDLJobList{})
}
48 changes: 48 additions & 0 deletions api/elasticdljob/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
Copyright 2020 The Alibaba 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.
*/

// +kubebuilder:object:generate=true
// +groupName=elasticdl.org
package v1alpha1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
)

const (
Kind = "ElasticDLJob"
GroupName = "elasticdl.org"
GroupVersion = "v1alpha1"
)

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion}

GroupVersionKind = SchemeGroupVersion.WithKind(Kind)

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

// Resource takes an unqualified resource and returns a Group-qualified GroupResource.
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
116 changes: 116 additions & 0 deletions api/elasticdljob/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a65735c

Please sign in to comment.