Skip to content

Commit a2190f1

Browse files
authored
interface: support multiple resourceSnapshot versions across clusters (#33)
1 parent 62f0d28 commit a2190f1

File tree

2 files changed

+43
-17
lines changed

2 files changed

+43
-17
lines changed

apis/placement/v1beta1/clusterresourceplacement_types.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ type RollingUpdateConfig struct {
813813
// ClusterResourcePlacementStatus defines the observed state of the ClusterResourcePlacement object.
814814
type ClusterResourcePlacementStatus struct {
815815
// SelectedResources contains a list of resources selected by ResourceSelectors.
816+
// This field is only meaningful if the `ObservedResourceIndex` is not empty.
816817
// +kubebuilder:validation:Optional
817818
SelectedResources []ResourceIdentifier `json:"selectedResources,omitempty"`
818819

@@ -821,15 +822,15 @@ type ClusterResourcePlacementStatus struct {
821822
// Each snapshot has a different resource index.
822823
// One resource snapshot can contain multiple clusterResourceSnapshots CRs in order to store large amount of resources.
823824
// To get clusterResourceSnapshot of a given resource index, use the following command:
824-
// `kubectl get ClusterResourceSnapshot --selector=kubernetes-fleet.io/resource-index=$ObservedResourceIndex `
825-
// ObservedResourceIndex is the resource index that the conditions in the ClusterResourcePlacementStatus observe.
826-
// For example, a condition of `ClusterResourcePlacementWorkSynchronized` type
827-
// is observing the synchronization status of the resource snapshot with the resource index $ObservedResourceIndex.
825+
// `kubectl get ClusterResourceSnapshot --selector=kubernetes-fleet.io/resource-index=$ObservedResourceIndex`
826+
// If the rollout strategy type is `RollingUpdate`, `ObservedResourceIndex` is the default-latest resource snapshot index.
827+
// If the rollout strategy type is `External`, rollout and version control are managed by an external controller,
828+
// and this field is not empty only if all targeted clusters observe the same resource index in `PlacementStatuses`.
828829
// +kubebuilder:validation:Optional
829830
ObservedResourceIndex string `json:"observedResourceIndex,omitempty"`
830831

831832
// PlacementStatuses contains a list of placement status on the clusters that are selected by PlacementPolicy.
832-
// Each selected cluster according to the latest resource placement is guaranteed to have a corresponding placementStatuses.
833+
// Each selected cluster according to the observed resource placement is guaranteed to have a corresponding placementStatuses.
833834
// In the pickN case, there are N placement statuses where N = NumberOfClusters; Or in the pickFixed case, there are
834835
// N placement statuses where N = ClusterNames.
835836
// In these cases, some of them may not have assigned clusters when we cannot fill the required number of clusters.
@@ -843,6 +844,11 @@ type ClusterResourcePlacementStatus struct {
843844
// +listMapKey=type
844845

845846
// Conditions is an array of current observed conditions for ClusterResourcePlacement.
847+
// All conditions except `ClusterResourcePlacementScheduled` correspond to the resource snapshot at the index specified by `ObservedResourceIndex`.
848+
// For example, a condition of `ClusterResourcePlacementWorkSynchronized` type
849+
// is observing the synchronization status of the resource snapshot with index `ObservedResourceIndex`.
850+
// If the rollout strategy type is `External`, and `ObservedResourceIndex` is unset due to clusters reporting different resource indices,
851+
// conditions except `ClusterResourcePlacementScheduled` will be empty or set to Unknown.
846852
// +kubebuilder:validation:Optional
847853
Conditions []metav1.Condition `json:"conditions,omitempty"`
848854
}
@@ -907,6 +913,11 @@ type ResourcePlacementStatus struct {
907913
// +kubebuilder:validation:Optional
908914
ClusterName string `json:"clusterName,omitempty"`
909915

916+
// ObservedResourceIndex is the index of the resource snapshot that is currently being rolled out to the given cluster.
917+
// This field is only meaningful if the `ClusterName` is not empty.
918+
// +kubebuilder:validation:Optional
919+
ObservedResourceIndex string `json:"observedResourceIndex,omitempty"`
920+
910921
// ApplicableResourceOverrides contains a list of applicable ResourceOverride snapshots associated with the selected
911922
// resources.
912923
//
@@ -954,7 +965,9 @@ type ResourcePlacementStatus struct {
954965
// +kubebuilder:validation:MaxItems=100
955966
DiffedPlacements []DiffedResourcePlacement `json:"diffedPlacements,omitempty"`
956967

957-
// Conditions is an array of current observed conditions for ResourcePlacementStatus.
968+
// Conditions is an array of current observed conditions on the cluster.
969+
// Each condition corresponds to the resource snapshot at the index specified by `ObservedResourceIndex`.
970+
// For example, the condition of type `RolloutStarted` is observing the rollout status of the resource snapshot with index `ObservedResourceIndex`.
958971
// +kubebuilder:validation:Optional
959972
Conditions []metav1.Condition `json:"conditions,omitempty"`
960973
}

config/crd/bases/placement.kubernetes-fleet.io_clusterresourceplacements.yaml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,8 +1976,13 @@ spec:
19761976
description: The observed status of ClusterResourcePlacement.
19771977
properties:
19781978
conditions:
1979-
description: Conditions is an array of current observed conditions
1980-
for ClusterResourcePlacement.
1979+
description: |-
1980+
Conditions is an array of current observed conditions for ClusterResourcePlacement.
1981+
All conditions except `ClusterResourcePlacementScheduled` correspond to the resource snapshot at the index specified by `ObservedResourceIndex`.
1982+
For example, a condition of `ClusterResourcePlacementWorkSynchronized` type
1983+
is observing the synchronization status of the resource snapshot with index `ObservedResourceIndex`.
1984+
If the rollout strategy type is `External`, and `ObservedResourceIndex` is unset due to clusters reporting different resource indices,
1985+
conditions except `ClusterResourcePlacementScheduled` will be empty or set to Unknown.
19811986
items:
19821987
description: Condition contains details for one aspect of the current
19831988
state of this API Resource.
@@ -2043,15 +2048,15 @@ spec:
20432048
Each snapshot has a different resource index.
20442049
One resource snapshot can contain multiple clusterResourceSnapshots CRs in order to store large amount of resources.
20452050
To get clusterResourceSnapshot of a given resource index, use the following command:
2046-
`kubectl get ClusterResourceSnapshot --selector=kubernetes-fleet.io/resource-index=$ObservedResourceIndex `
2047-
ObservedResourceIndex is the resource index that the conditions in the ClusterResourcePlacementStatus observe.
2048-
For example, a condition of `ClusterResourcePlacementWorkSynchronized` type
2049-
is observing the synchronization status of the resource snapshot with the resource index $ObservedResourceIndex.
2051+
`kubectl get ClusterResourceSnapshot --selector=kubernetes-fleet.io/resource-index=$ObservedResourceIndex`
2052+
If the rollout strategy type is `RollingUpdate`, `ObservedResourceIndex` is the default-latest resource snapshot index.
2053+
If the rollout strategy type is `External`, rollout and version control are managed by an external controller,
2054+
and this field is not empty only if all targeted clusters observe the same resource index in `PlacementStatuses`.
20502055
type: string
20512056
placementStatuses:
20522057
description: |-
20532058
PlacementStatuses contains a list of placement status on the clusters that are selected by PlacementPolicy.
2054-
Each selected cluster according to the latest resource placement is guaranteed to have a corresponding placementStatuses.
2059+
Each selected cluster according to the observed resource placement is guaranteed to have a corresponding placementStatuses.
20552060
In the pickN case, there are N placement statuses where N = NumberOfClusters; Or in the pickFixed case, there are
20562061
N placement statuses where N = ClusterNames.
20572062
In these cases, some of them may not have assigned clusters when we cannot fill the required number of clusters.
@@ -2097,8 +2102,10 @@ spec:
20972102
If it is not empty, its value should be unique cross all placement decisions for the Placement.
20982103
type: string
20992104
conditions:
2100-
description: Conditions is an array of current observed conditions
2101-
for ResourcePlacementStatus.
2105+
description: |-
2106+
Conditions is an array of current observed conditions on the cluster.
2107+
Each condition corresponds to the resource snapshot at the index specified by `ObservedResourceIndex`.
2108+
For example, the condition of type `RolloutStarted` is observing the rollout status of the resource snapshot with index `ObservedResourceIndex`.
21022109
items:
21032110
description: Condition contains details for one aspect of
21042111
the current state of this API Resource.
@@ -2500,11 +2507,17 @@ spec:
25002507
type: object
25012508
maxItems: 100
25022509
type: array
2510+
observedResourceIndex:
2511+
description: |-
2512+
ObservedResourceIndex is the index of the resource snapshot that is currently being rolled out to the given cluster.
2513+
This field is only meaningful if the `ClusterName` is not empty.
2514+
type: string
25032515
type: object
25042516
type: array
25052517
selectedResources:
2506-
description: SelectedResources contains a list of resources selected
2507-
by ResourceSelectors.
2518+
description: |-
2519+
SelectedResources contains a list of resources selected by ResourceSelectors.
2520+
This field is only meaningful if the `ObservedResourceIndex` is not empty.
25082521
items:
25092522
description: ResourceIdentifier identifies one Kubernetes resource.
25102523
properties:

0 commit comments

Comments
 (0)