-
Notifications
You must be signed in to change notification settings - Fork 38
interface: Policy scheduling API #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1c0edfb
policy scheduling api
c2e3a4d
Apply suggestions from code review
ryanzhang-oss 244059a
fix go lint
0a2ccbc
bump github ci go version to 1.20
9c238f2
address comments
80f68f0
check in the new CRDs
b8d2572
use v1alpha1 as storage version
1745caa
Apply suggestions from code review
ryanzhang-oss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ on: | |
|
|
||
| env: | ||
| # Common versions | ||
| GO_VERSION: '1.18' | ||
| GO_VERSION: '1.20' | ||
|
|
||
| jobs: | ||
|
|
||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| run: | ||
| deadline: 10m | ||
| go: '1.18' | ||
| go: '1.20' | ||
|
|
||
| linters: | ||
| disable-all: true | ||
|
|
||
This file contains hidden or 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 hidden or 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,102 @@ | ||
| /* | ||
| Copyright (c) Microsoft Corporation. | ||
| Licensed under the MIT license. | ||
| */ | ||
|
|
||
| package v1 | ||
|
|
||
| import ( | ||
| "k8s.io/apimachinery/pkg/api/meta" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // CRPTrackingLabel is the label that points to the cluster resource policy that creates a resource binding. | ||
| const CRPTrackingLabel = labelPrefix + "parentCRP" | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:resource:scope=Cluster,categories={fleet},shortName=rb | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=="ResourceBindingApplied")].status`,name="Applied",type=string | ||
| // +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date | ||
|
|
||
| // ClusterResourceBinding represents a scheduling decision that binds a group of resources to a cluster. | ||
| // It must have CRPTrackingLabel that points to the cluster resource policy that creates it. | ||
| type ClusterResourceBinding struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| // The desired state of ClusterResourceBinding. | ||
| // +required | ||
| Spec ResourceBindingSpec `json:"spec"` | ||
|
|
||
| // The observed status of ClusterResourceBinding. | ||
| // +optional | ||
| Status ResourceBindingStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // ResourceBindingSpec defines the desired state of ClusterResourceBinding. | ||
| type ResourceBindingSpec struct { | ||
| // ResourceSnapshotName is the name of the resource snapshot that this resource binding points to. If the resources are divided into multiple snapshots because of the resource size limit, it will point to the name of the parent snapshot. | ||
| ResourceSnapshotName string `json:"resourceSnapshotName"` | ||
|
|
||
| // TargetCluster is the name of the cluster that the scheduler assigns the resources to. | ||
| TargetCluster string `json:"targetCluster"` | ||
ryanzhang-oss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // ResourceBindingStatus represents the current status of a ClusterResourceBinding. | ||
| type ResourceBindingStatus struct { | ||
| // +patchMergeKey=type | ||
| // +patchStrategy=merge | ||
| // +listType=map | ||
| // +listMapKey=type | ||
|
|
||
| // Conditions is an array of current observed conditions for ClusterResourceBinding. | ||
| // +optional | ||
| Conditions []metav1.Condition `json:"conditions"` | ||
| } | ||
|
|
||
| // ResourceBindingConditionType identifies a specific condition of the ClusterResourceBinding. | ||
| type ResourceBindingConditionType string | ||
|
|
||
| const ( | ||
| // ResourceBindingBound indicates the bound condition of the given resources. | ||
| // Its condition status can be one of the following: | ||
| // - "True" means the corresponding work CR is created in the target cluster's namespace. | ||
| // - "False" means the corresponding work CR is not created yet. | ||
| // - "Unknown" means it is unknown. | ||
| ResourceBindingBound ResourceBindingConditionType = "Bound" | ||
|
|
||
| // ResourceBindingApplied indicates the applied condition of the given resources. | ||
| // Its condition status can be one of the following: | ||
| // - "True" means all the resources are created in the target cluster. | ||
| // - "False" means not all the resources are created in the target cluster yet. | ||
| // - "Unknown" means it is unknown. | ||
| ResourceBindingApplied ResourceBindingConditionType = "Applied" | ||
| ) | ||
|
|
||
| // ClusterResourceBindingList is a collection of ClusterResourceBinding. | ||
| // +kubebuilder:resource:scope="Cluster" | ||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
| type ClusterResourceBindingList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
|
|
||
| // items is the list of ClusterResourceBindings. | ||
| Items []ClusterResourceBinding `json:"items"` | ||
| } | ||
|
|
||
| // SetConditions set the given conditions on the ClusterResourceBinding. | ||
| func (m *ClusterResourceBinding) SetConditions(conditions ...metav1.Condition) { | ||
| for _, c := range conditions { | ||
| meta.SetStatusCondition(&m.Status.Conditions, c) | ||
| } | ||
| } | ||
|
|
||
| // GetCondition returns the condition of the given ClusterResourceBinding. | ||
| func (m *ClusterResourceBinding) GetCondition(conditionType string) *metav1.Condition { | ||
| return meta.FindStatusCondition(m.Status.Conditions, conditionType) | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&ClusterResourceBinding{}, &ClusterResourceBindingList{}) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.