generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
- Loading branch information
Showing
20 changed files
with
1,649 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# permissions for end users to edit paddlejobs. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: '{{ include "kueue.fullname" . }}-paddlejob-editor-role' | ||
labels: | ||
rbac.kueue.x-k8s.io/batch-admin: "true" | ||
rbac.kueue.x-k8s.io/batch-user: "true" | ||
rules: | ||
- apiGroups: | ||
- kubeflow.org | ||
resources: | ||
- paddlejobs | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- kubeflow.org | ||
resources: | ||
- paddlejobs/status | ||
verbs: | ||
- get |
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,23 @@ | ||
# permissions for end users to view paddlejobs. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: '{{ include "kueue.fullname" . }}-paddlejob-viewer-role' | ||
labels: | ||
rbac.kueue.x-k8s.io/batch-admin: "true" | ||
rbac.kueue.x-k8s.io/batch-user: "true" | ||
rules: | ||
- apiGroups: | ||
- kubeflow.org | ||
resources: | ||
- paddlejobs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- kubeflow.org | ||
resources: | ||
- paddlejobs/status | ||
verbs: | ||
- get |
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
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
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,27 @@ | ||
# permissions for end users to edit paddlejobs. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: paddlejob-editor-role | ||
labels: | ||
rbac.kueue.x-k8s.io/batch-admin: "true" | ||
rbac.kueue.x-k8s.io/batch-user: "true" | ||
rules: | ||
- apiGroups: | ||
- kubeflow.org | ||
resources: | ||
- paddlejobs | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- kubeflow.org | ||
resources: | ||
- paddlejobs/status | ||
verbs: | ||
- get |
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,23 @@ | ||
# permissions for end users to view paddlejobs. | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: paddlejob-viewer-role | ||
labels: | ||
rbac.kueue.x-k8s.io/batch-admin: "true" | ||
rbac.kueue.x-k8s.io/batch-user: "true" | ||
rules: | ||
- apiGroups: | ||
- kubeflow.org | ||
resources: | ||
- paddlejobs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- kubeflow.org | ||
resources: | ||
- paddlejobs/status | ||
verbs: | ||
- get |
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
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
98 changes: 98 additions & 0 deletions
98
pkg/controller/jobs/kubeflow/jobs/paddlejob/paddlejob_controller.go
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,98 @@ | ||
/* | ||
Copyright 2023 The Kubernetes 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 paddlejob | ||
|
||
import ( | ||
"context" | ||
|
||
kftraining "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"sigs.k8s.io/kueue/pkg/controller/jobframework" | ||
"sigs.k8s.io/kueue/pkg/controller/jobs/kubeflow/kubeflowjob" | ||
) | ||
|
||
var ( | ||
gvk = kftraining.SchemeGroupVersion.WithKind(kftraining.PaddleJobKind) | ||
FrameworkName = "kubeflow.org/paddlejob" | ||
) | ||
|
||
func init() { | ||
utilruntime.Must(jobframework.RegisterIntegration(FrameworkName, jobframework.IntegrationCallbacks{ | ||
SetupIndexes: SetupIndexes, | ||
NewReconciler: NewReconciler, | ||
SetupWebhook: SetupPaddleJobWebhook, | ||
JobType: &kftraining.PaddleJob{}, | ||
AddToScheme: kftraining.AddToScheme, | ||
})) | ||
} | ||
|
||
// +kubebuilder:rbac:groups=scheduling.k8s.io,resources=priorityclasses,verbs=list;get;watch | ||
// +kubebuilder:rbac:groups="",resources=events,verbs=create;watch;update;patch | ||
// +kubebuilder:rbac:groups=kubeflow.org,resources=paddlejobs,verbs=get;list;watch;update;patch | ||
// +kubebuilder:rbac:groups=kubeflow.org,resources=paddlejobs/status,verbs=get;update | ||
// +kubebuilder:rbac:groups=kueue.x-k8s.io,resources=workloads,verbs=get;list;watch;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=kueue.x-k8s.io,resources=workloads/status,verbs=get;update;patch | ||
// +kubebuilder:rbac:groups=kueue.x-k8s.io,resources=workloads/finalizers,verbs=update | ||
// +kubebuilder:rbac:groups=kueue.x-k8s.io,resources=resourceflavors,verbs=get;list;watch | ||
|
||
var NewReconciler = jobframework.NewGenericReconciler(func() jobframework.GenericJob { | ||
return &kubeflowjob.KubeflowJob{KFJobControl: (*JobControl)(&kftraining.PaddleJob{})} | ||
}, nil) | ||
|
||
type JobControl kftraining.PaddleJob | ||
|
||
var _ kubeflowjob.KFJobControl = (*JobControl)(nil) | ||
|
||
func (j *JobControl) Object() client.Object { | ||
return (*kftraining.PaddleJob)(j) | ||
} | ||
|
||
func fromObject(o runtime.Object) *kubeflowjob.KubeflowJob { | ||
return &kubeflowjob.KubeflowJob{KFJobControl: (*JobControl)(o.(*kftraining.PaddleJob))} | ||
} | ||
|
||
func (j *JobControl) GVK() schema.GroupVersionKind { | ||
return gvk | ||
} | ||
|
||
func (j *JobControl) RunPolicy() *kftraining.RunPolicy { | ||
return &j.Spec.RunPolicy | ||
} | ||
|
||
func (j *JobControl) ReplicaSpecs() map[kftraining.ReplicaType]*kftraining.ReplicaSpec { | ||
return j.Spec.PaddleReplicaSpecs | ||
} | ||
|
||
func (j *JobControl) JobStatus() kftraining.JobStatus { | ||
return j.Status | ||
} | ||
|
||
func (j *JobControl) OrderedReplicaTypes() []kftraining.ReplicaType { | ||
return []kftraining.ReplicaType{kftraining.PaddleJobReplicaTypeMaster, kftraining.PaddleJobReplicaTypeWorker} | ||
} | ||
|
||
func SetupIndexes(ctx context.Context, indexer client.FieldIndexer) error { | ||
return jobframework.SetupWorkloadOwnerIndex(ctx, indexer, gvk) | ||
} | ||
|
||
func GetWorkloadNameForPaddleJob(jobName string) string { | ||
return jobframework.GetWorkloadNameForOwnerWithGVK(jobName, gvk) | ||
} |
Oops, something went wrong.