-
Notifications
You must be signed in to change notification settings - Fork 891
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an imperative API to support rescheduling
Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
- Loading branch information
1 parent
fdad87e
commit 2cd253b
Showing
38 changed files
with
2,984 additions
and
9 deletions.
There are no files selected for viewing
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
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,20 @@ | ||
/* | ||
Copyright 2024 The Karmada 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 command is the internal version of the API. | ||
// +k8s:deepcopy-gen=package | ||
// +groupName=command.karmada.io | ||
package command |
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,54 @@ | ||
/* | ||
Copyright 2024 The Karmada 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 command | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
// GroupName specifies the group name used to register the objects. | ||
const GroupName = "command.karmada.io" | ||
|
||
// SchemeGroupVersion is group version used to register these objects | ||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} | ||
|
||
// Resource takes an unqualified resource and returns a Group qualified GroupResource | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} | ||
|
||
// Kind takes an unqualified kind and returns a Group qualified GroupKind | ||
func Kind(kind string) schema.GroupKind { | ||
return SchemeGroupVersion.WithKind(kind).GroupKind() | ||
} | ||
|
||
var ( | ||
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package | ||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) | ||
// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) | ||
|
||
// Adds the list of known types to Scheme. | ||
func addKnownTypes(scheme *runtime.Scheme) error { | ||
scheme.AddKnownTypes(SchemeGroupVersion, | ||
&Reschedule{}, | ||
&RescheduleList{}, | ||
) | ||
return nil | ||
} |
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,104 @@ | ||
/* | ||
Copyright 2024 The Karmada 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 command | ||
|
||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
const ( | ||
// ResourceKindReschedule is kind name of Reschedule. | ||
ResourceKindReschedule = "Reschedule" | ||
// ResourceSingularReschedule is singular name of Reschedule. | ||
ResourceSingularReschedule = "reschedule" | ||
// ResourcePluralReschedule is plural name of Reschedule. | ||
ResourcePluralReschedule = "reschedules" | ||
// ResourceNamespaceScopedReschedule indicates if Reschedule is NamespaceScoped. | ||
ResourceNamespaceScopedReschedule = false | ||
) | ||
|
||
//revive:disable:exported | ||
|
||
// +genclient | ||
// +genclient:nonNamespaced | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// Reschedule represents the desire state and status of a task which can enforces a rescheduling. | ||
// | ||
// Notes: make sure the clocks of aggregated-apiserver and scheduler are synchronized when using this API. | ||
type Reschedule struct { | ||
metav1.TypeMeta | ||
metav1.ObjectMeta | ||
|
||
// Spec represents the specification of the desired behavior of Reschedule. | ||
// +required | ||
Spec RescheduleSpec | ||
} | ||
|
||
// RescheduleSpec represents the specification of the desired behavior of Reschedule. | ||
type RescheduleSpec struct { | ||
// TargetRefPolicy used to select batch of resources managed by certain policies. | ||
// +optional | ||
TargetRefPolicy []PolicySelector | ||
|
||
// TargetRefResource used to select resources. | ||
// +optional | ||
TargetRefResource []ResourceSelector | ||
} | ||
|
||
// PolicySelector the resources bound policy will be selected. | ||
type PolicySelector struct { | ||
// Name of the target policy. | ||
// +required | ||
Name string | ||
|
||
// Namespace of the target policy. | ||
// Default is empty, which means it is a cluster propagation policy. | ||
// +optional | ||
Namespace string | ||
} | ||
|
||
// ResourceSelector the resource will be selected. | ||
type ResourceSelector struct { | ||
// APIVersion represents the API version of the target resource. | ||
// +required | ||
APIVersion string | ||
|
||
// Kind represents the Kind of the target resource. | ||
// +required | ||
Kind string | ||
|
||
// Name of the target resource. | ||
// +required | ||
Name string | ||
|
||
// Namespace of the target resource. | ||
// Default is empty, which means it is a non-namespacescoped resource. | ||
// +optional | ||
Namespace string | ||
} | ||
|
||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// RescheduleList contains a list of Reschedule | ||
type RescheduleList struct { | ||
metav1.TypeMeta | ||
metav1.ListMeta | ||
|
||
// Items holds a list of Reschedule. | ||
Items []Reschedule | ||
} | ||
|
||
//revive:enable:exported |
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,22 @@ | ||
/* | ||
Copyright 2024 The Karmada 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 is the v1alpha1 version of the API. | ||
// +k8s:openapi-gen=true | ||
// +k8s:deepcopy-gen=package,register | ||
// +k8s:conversion-gen=github.com/karmada-io/karmada/pkg/apis/command | ||
// +groupName=command.karmada.io | ||
package v1alpha1 |
Oops, something went wrong.