Skip to content

Commit 76ee739

Browse files
interface: experimental: status back-reporting (#255)
* added some API changes Signed-off-by: michaelawyu <chenyu1@microsoft.com> * Minor fixes Signed-off-by: michaelawyu <chenyu1@microsoft.com> * Minor fixes Signed-off-by: michaelawyu <chenyu1@microsoft.com> * Minor fixes Signed-off-by: michaelawyu <chenyu1@microsoft.com> * Applied recommended changes Signed-off-by: michaelawyu <chenyu1@microsoft.com> * Minor fixes Signed-off-by: michaelawyu <chenyu1@microsoft.com> * Minor fixes Signed-off-by: michaelawyu <chenyu1@microsoft.com> * Minor fixes Signed-off-by: michaelawyu <chenyu1@microsoft.com> --------- Signed-off-by: michaelawyu <chenyu1@microsoft.com> Co-authored-by: Ryan Zhang <yangzhangrice@hotmail.com>
1 parent 56d65f6 commit 76ee739

10 files changed

+295
-10
lines changed

apis/cluster/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/placement/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/placement/v1beta1/clusterresourceplacement_types.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,11 @@ type RolloutStrategy struct {
539539
// DeleteStrategy configures the deletion behavior when the ClusterResourcePlacement is deleted.
540540
// +kubebuilder:validation:Optional
541541
DeleteStrategy *DeleteStrategy `json:"deleteStrategy,omitempty"`
542+
543+
// ReportBackStrategy describes how to report back the status of applied resources on the member cluster.
544+
// +kubebuilder:validation:Optional
545+
// +kubebuilder:validation:XValidation:rule="(self == null) || (self.type == 'Mirror' ? size(self.destination) != 0 : true)",message="when reportBackStrategy.type is 'Mirror', a destination must be specified"
546+
ReportBackStrategy *ReportBackStrategy `json:"reportBackStrategy,omitempty"`
542547
}
543548

544549
// ApplyStrategy describes when and how to apply the selected resource to the target cluster.
@@ -1480,6 +1485,66 @@ const (
14801485
DeletePropagationPolicyDelete DeletePropagationPolicy = "Delete"
14811486
)
14821487

1488+
type ReportBackStrategyType string
1489+
1490+
const (
1491+
// ReportBackStrategyTypeDisabled disables status back-reporting from the member clusters.
1492+
ReportBackStrategyTypeDisabled ReportBackStrategyType = "Disabled"
1493+
1494+
// ReportBackStrategyTypeMirror enables status back-reporting by
1495+
// copying the status fields verbatim to some destination on the hub cluster side.
1496+
ReportBackStrategyTypeMirror ReportBackStrategyType = "Mirror"
1497+
)
1498+
1499+
type ReportBackDestination string
1500+
1501+
const (
1502+
// ReportBackDestinationOriginalResource implies the status fields will be copied verbatim to the
1503+
// the original resource on the hub cluster side. This is only performed when the placement object has a
1504+
// scheduling policy that selects exactly one member cluster (i.e., a pickFixed scheduling policy with
1505+
// exactly one cluster name, or a pickN scheduling policy with the numberOfClusters field set to 1).
1506+
ReportBackDestinationOriginalResource ReportBackDestination = "OriginalResource"
1507+
1508+
// ReportBackDestinationWorkAPI implies the status fields will be copied verbatim via the Work API
1509+
// on the hub cluster side. Users may look up the status of a specific resource applied to a specific
1510+
// member cluster by inspecting the corresponding Work object on the hub cluster side.
1511+
ReportBackDestinationWorkAPI ReportBackDestination = "WorkAPI"
1512+
)
1513+
1514+
// ReportBackStrategy describes how to report back the resource status from member clusters.
1515+
type ReportBackStrategy struct {
1516+
// Type dictates the type of the report back strategy to use.
1517+
//
1518+
// Available options include:
1519+
//
1520+
// * Disabled: status back-reporting is disabled. This is the default behavior.
1521+
//
1522+
// * Mirror: status back-reporting is enabled by copying the status fields verbatim to
1523+
// a destination on the hub cluster side; see the Destination field for more information.
1524+
//
1525+
// +kubebuilder:default=Disabled
1526+
// +kubebuilder:validation:Enum=Disabled;Mirror
1527+
// +kubebuilder:validation:Required
1528+
Type ReportBackStrategyType `json:"type"`
1529+
1530+
// Destination dictates where to copy the status fields to when the report back strategy type is Mirror.
1531+
//
1532+
// Available options include:
1533+
//
1534+
// * OriginalResource: the status fields will be copied verbatim to the original resource on the hub cluster side.
1535+
// This is only performed when the placement object has a scheduling policy that selects exactly one member cluster
1536+
// (i.e., a pickFixed scheduling policy with exactly one cluster name, or a pickN scheduling policy with the numberOfClusters
1537+
// field set to 1).
1538+
//
1539+
// * WorkAPI: the status fields will be copied verbatim via the Work API on the hub cluster side. Users may look up
1540+
// the status of a specific resource applied to a specific member cluster by inspecting the corresponding Work object
1541+
// on the hub cluster side. This is the default behavior.
1542+
//
1543+
// +kubebuilder:validation:Enum=OriginalResource;WorkAPI
1544+
// +kubebuilder:validation:Optional
1545+
Destination *ReportBackDestination `json:"destination,omitempty"`
1546+
}
1547+
14831548
// ClusterResourcePlacementList contains a list of ClusterResourcePlacement.
14841549
// +kubebuilder:resource:scope="Cluster"
14851550
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

apis/placement/v1beta1/work_types.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ type WorkSpec struct {
6868
// and is owned by other appliers.
6969
// +optional
7070
ApplyStrategy *ApplyStrategy `json:"applyStrategy,omitempty"`
71+
72+
// ReportBackStrategy describes how to report back the status of applied resources on the member cluster.
73+
// +optional
74+
ReportBackStrategy *ReportBackStrategy `json:"reportBackStrategy,omitempty"`
7175
}
7276

7377
// WorkloadTemplate represents the manifest workload to be deployed on spoke cluster
@@ -142,7 +146,7 @@ type DriftDetails struct {
142146
// +kubebuilder:validation:Required
143147
ObservedInMemberClusterGeneration int64 `json:"observedInMemberClusterGeneration"`
144148

145-
// FirsftDriftedObservedTime is the timestamp when the drift was first detected.
149+
// FirstDriftedObservedTime is the timestamp when the drift was first detected.
146150
//
147151
// +kubebuilder:validation:Required
148152
// +kubebuilder:validation:Type=string
@@ -176,7 +180,7 @@ type DiffDetails struct {
176180
// +kubebuilder:validation:Optional
177181
ObservedInMemberClusterGeneration *int64 `json:"observedInMemberClusterGeneration"`
178182

179-
// FirsftDiffedObservedTime is the timestamp when the configuration difference
183+
// FirstDiffedObservedTime is the timestamp when the configuration difference
180184
// was first detected.
181185
//
182186
// +kubebuilder:validation:Required
@@ -196,6 +200,19 @@ type DiffDetails struct {
196200
ObservedDiffs []PatchDetail `json:"observedDiffs,omitempty"`
197201
}
198202

203+
type BackReportedStatus struct {
204+
// +kubebuilder:validation:EmbeddedResource
205+
// +kubebuilder:pruning:PreserveUnknownFields
206+
ObservedStatus runtime.RawExtension `json:"observedStatus,omitempty"`
207+
208+
// ObservationTime is the timestamp when the status was last back reported.
209+
//
210+
// +kubebuilder:validation:Required
211+
// +kubebuilder:validation:Type=string
212+
// +kubebuilder:validation:Format=date-time
213+
ObservationTime metav1.Time `json:"observationTime"`
214+
}
215+
199216
// ManifestCondition represents the conditions of the resources deployed on
200217
// spoke cluster.
201218
type ManifestCondition struct {
@@ -228,6 +245,11 @@ type ManifestCondition struct {
228245
//
229246
// +kubebuilder:validation:Optional
230247
DiffDetails *DiffDetails `json:"diffDetails,omitempty"`
248+
249+
// BackReportedStatus is the status reported back from the member cluster (if applicable).
250+
//
251+
// +kubebuilder:validation:Optional
252+
BackReportedStatus *BackReportedStatus `json:"backReportedStatus,omitempty"`
231253
}
232254

233255
// +genclient

apis/placement/v1beta1/zz_generated.deepcopy.go

Lines changed: 53 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1947,6 +1947,51 @@ spec:
19471947
- Delete
19481948
type: string
19491949
type: object
1950+
reportBackStrategy:
1951+
description: ReportBackStrategy describes how to report back the
1952+
status of applied resources on the member cluster.
1953+
properties:
1954+
destination:
1955+
description: |-
1956+
Destination dictates where to copy the status fields to when the report back strategy type is Mirror.
1957+
1958+
Available options include:
1959+
1960+
* OriginalResource: the status fields will be copied verbatim to the original resource on the hub cluster side.
1961+
This is only performed when the placement object has a scheduling policy that selects exactly one member cluster
1962+
(i.e., a pickFixed scheduling policy with exactly one cluster name, or a pickN scheduling policy with the numberOfClusters
1963+
field set to 1).
1964+
1965+
* WorkAPI: the status fields will be copied verbatim via the Work API on the hub cluster side. Users may look up
1966+
the status of a specific resource applied to a specific member cluster by inspecting the corresponding Work object
1967+
on the hub cluster side. This is the default behavior.
1968+
enum:
1969+
- OriginalResource
1970+
- WorkAPI
1971+
type: string
1972+
type:
1973+
default: Disabled
1974+
description: |-
1975+
Type dictates the type of the report back strategy to use.
1976+
1977+
Available options include:
1978+
1979+
* Disabled: status back-reporting is disabled. This is the default behavior.
1980+
1981+
* Mirror: status back-reporting is enabled by copying the status fields verbatim to
1982+
a destination on the hub cluster side; see the Destination field for more information.
1983+
enum:
1984+
- Disabled
1985+
- Mirror
1986+
type: string
1987+
required:
1988+
- type
1989+
type: object
1990+
x-kubernetes-validations:
1991+
- message: when reportBackStrategy.type is 'Mirror', a destination
1992+
must be specified
1993+
rule: '(self == null) || (self.type == ''Mirror'' ? size(self.destination)
1994+
!= 0 : true)'
19501995
rollingUpdate:
19511996
description: Rolling update config params. Present only if RolloutStrategyType
19521997
= RollingUpdate.

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,51 @@ spec:
882882
- Delete
883883
type: string
884884
type: object
885+
reportBackStrategy:
886+
description: ReportBackStrategy describes how to report back the
887+
status of applied resources on the member cluster.
888+
properties:
889+
destination:
890+
description: |-
891+
Destination dictates where to copy the status fields to when the report back strategy type is Mirror.
892+
893+
Available options include:
894+
895+
* OriginalResource: the status fields will be copied verbatim to the original resource on the hub cluster side.
896+
This is only performed when the placement object has a scheduling policy that selects exactly one member cluster
897+
(i.e., a pickFixed scheduling policy with exactly one cluster name, or a pickN scheduling policy with the numberOfClusters
898+
field set to 1).
899+
900+
* WorkAPI: the status fields will be copied verbatim via the Work API on the hub cluster side. Users may look up
901+
the status of a specific resource applied to a specific member cluster by inspecting the corresponding Work object
902+
on the hub cluster side. This is the default behavior.
903+
enum:
904+
- OriginalResource
905+
- WorkAPI
906+
type: string
907+
type:
908+
default: Disabled
909+
description: |-
910+
Type dictates the type of the report back strategy to use.
911+
912+
Available options include:
913+
914+
* Disabled: status back-reporting is disabled. This is the default behavior.
915+
916+
* Mirror: status back-reporting is enabled by copying the status fields verbatim to
917+
a destination on the hub cluster side; see the Destination field for more information.
918+
enum:
919+
- Disabled
920+
- Mirror
921+
type: string
922+
required:
923+
- type
924+
type: object
925+
x-kubernetes-validations:
926+
- message: when reportBackStrategy.type is 'Mirror', a destination
927+
must be specified
928+
rule: '(self == null) || (self.type == ''Mirror'' ? size(self.destination)
929+
!= 0 : true)'
885930
rollingUpdate:
886931
description: Rolling update config params. Present only if RolloutStrategyType
887932
= RollingUpdate.

0 commit comments

Comments
 (0)