forked from Azure/fleet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interface: Policy scheduling API (Azure#367)
policy scheduling api
- Loading branch information
1 parent
6107234
commit 9731ec4
Showing
42 changed files
with
3,953 additions
and
72 deletions.
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ on: | |
|
||
env: | ||
# Common versions | ||
GO_VERSION: '1.18' | ||
GO_VERSION: '1.20' | ||
|
||
jobs: | ||
|
||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
run: | ||
deadline: 10m | ||
go: '1.18' | ||
go: '1.20' | ||
|
||
linters: | ||
disable-all: true | ||
|
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,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"` | ||
} | ||
|
||
// 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.