-
Notifications
You must be signed in to change notification settings - Fork 706
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add mpi-operator(v1) to the unified operator (#1457)
* fix:add mpi-operator to the unified operator fix: controller-gen fix:fmt * add unittest and fix typo in controller.go Co-authored-by: hackerboy01 <[email protected]> Co-authored-by: Wang Zhang <[email protected]>
- Loading branch information
1 parent
c3a867e
commit 63a6067
Showing
20 changed files
with
23,377 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2019 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. | ||
|
||
package v1 | ||
|
||
import common "github.com/kubeflow/common/pkg/apis/common/v1" | ||
|
||
const ( | ||
// EnvKubeflowNamespace is ENV for kubeflow namespace specified by user. | ||
EnvKubeflowNamespace = "KUBEFLOW_NAMESPACE" | ||
// DefaultPortName is name of the port used to communicate between Master and Workers. | ||
DefaultPortName = "mpi-port" | ||
// DefaultContainerName is the name of the XGBoostJob container. | ||
DefaultContainerName = "mpi" | ||
// DefaultPort is default value of the port. | ||
DefaultPort = 9999 | ||
// DefaultRestartPolicy is default RestartPolicy for ReplicaSpec. | ||
|
||
DefaultRestartPolicy = common.RestartPolicyNever | ||
Kind = "MPIJob" | ||
// Plural is the Plural for TFJob. | ||
Plural = "mpijobs" | ||
// Singular is the singular for TFJob. | ||
Singular = "mpijob" | ||
// FrameworkName is the name of the ML Framework | ||
FrameworkName = "mpi" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2019 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. | ||
|
||
package v1 | ||
|
||
import ( | ||
common "github.com/kubeflow/common/pkg/apis/common/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
// Int32 is a helper routine that allocates a new int32 value | ||
// to store v and returns a pointer to it. | ||
func Int32(v int32) *int32 { | ||
return &v | ||
} | ||
|
||
func addDefaultingFuncs(scheme *runtime.Scheme) error { | ||
return RegisterDefaults(scheme) | ||
} | ||
|
||
// setDefaultsTypeLauncher sets the default value to launcher. | ||
func setDefaultsTypeLauncher(spec *common.ReplicaSpec) { | ||
if spec != nil && spec.RestartPolicy == "" { | ||
spec.RestartPolicy = DefaultRestartPolicy | ||
} | ||
} | ||
|
||
// setDefaultsTypeWorker sets the default value to worker. | ||
func setDefaultsTypeWorker(spec *common.ReplicaSpec) { | ||
if spec != nil && spec.RestartPolicy == "" { | ||
spec.RestartPolicy = DefaultRestartPolicy | ||
} | ||
} | ||
|
||
func SetDefaults_MPIJob(mpiJob *MPIJob) { | ||
// Set default cleanpod policy to None. | ||
if mpiJob.Spec.CleanPodPolicy == nil { | ||
none := common.CleanPodPolicyNone | ||
mpiJob.Spec.CleanPodPolicy = &none | ||
} | ||
|
||
// set default to Launcher | ||
setDefaultsTypeLauncher(mpiJob.Spec.MPIReplicaSpecs[MPIReplicaTypeLauncher]) | ||
|
||
// set default to Worker | ||
setDefaultsTypeWorker(mpiJob.Spec.MPIReplicaSpecs[MPIReplicaTypeWorker]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// 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. | ||
|
||
// +k8s:defaulter-gen=TypeMeta | ||
// +k8s:openapi-gen=true | ||
|
||
// Package v1 is the v1 version of the API. | ||
// +groupName=kubeflow.org | ||
package v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Copyright 2021. | ||
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 v1 contains API Schema definitions for the kubeflow.org v1 API group | ||
//+kubebuilder:object:generate=true | ||
//+groupName=kubeflow.org | ||
package v1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "kubeflow.org", Version: "v1"} | ||
|
||
SchemeGroupVersionKind = schema.GroupVersionKind{Group: "kubeflow.org", Version: "v1", Kind: Kind} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
Oops, something went wrong.