@@ -148,6 +148,14 @@ type PlacementSpec struct {
148148 // +kubebuilder:default=10
149149 // +kubebuilder:validation:Optional
150150 RevisionHistoryLimit * int32 `json:"revisionHistoryLimit,omitempty"`
151+
152+ // EnableStatusProxy indicates whether a PlacementStatusProxy object should be created to mirror the placement status.
153+ // When enabled, PlacementStatusProxy objects will be created in the same namespaces selected by the ResourceSelectors.
154+ // This allows namespace-scoped access to the cluster-scoped ClusterResourcePlacement status.
155+ // Defaults to false.
156+ // +kubebuilder:default=false
157+ // +kubebuilder:validation:Optional
158+ EnableStatusProxy bool `json:"enableStatusProxy,omitempty"`
151159}
152160
153161// Tolerations returns tolerations for PlacementSpec to handle nil policy case.
@@ -1495,6 +1503,61 @@ func (rpl *ResourcePlacementList) GetPlacementObjs() []PlacementObj {
14951503 return objs
14961504}
14971505
1506+ // +genclient
1507+ // +genclient:Namespaced
1508+ // +kubebuilder:object:root=true
1509+ // +kubebuilder:resource:scope="Namespaced",shortName=psp,categories={fleet,fleet-placement}
1510+ // +kubebuilder:subresource:status
1511+ // +kubebuilder:storageversion
1512+ // +kubebuilder:printcolumn:JSONPath=`.status.observedResourceIndex`,name="Resource-Index",type=string
1513+ // +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date
1514+ // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1515+
1516+ // PlacementStatusProxy is a namespaced resource that mirrors the PlacementStatus of a corresponding
1517+ // ClusterResourcePlacement object. This allows namespace-scoped access to cluster-scoped placement status.
1518+ //
1519+ // This object will be created within the target namespace that contains resources being managed by the CRP.
1520+ // When multiple ClusterResourcePlacements target the same namespace, each PlacementStatusProxy within that
1521+ // namespace is uniquely identified by its object name, which corresponds to the specific ClusterResourcePlacement
1522+ // that created it.
1523+ //
1524+ // The name of this object should follow the template: <clusterResourcePlacementName>-status
1525+ // where <clusterResourcePlacementName> is the name of the corresponding ClusterResourcePlacement.
1526+ //
1527+ // For example, if you have a ClusterResourcePlacement named "my-app-crp", the corresponding
1528+ // PlacementStatusProxy should be named "my-app-crp-status".
1529+ type PlacementStatusProxy struct {
1530+ metav1.TypeMeta `json:",inline"`
1531+ metav1.ObjectMeta `json:"metadata,omitempty"`
1532+
1533+ // The observed status of PlacementStatusProxy which mirrors the PlacementStatus of the corresponding ClusterResourcePlacement.
1534+ // This includes information about the namespace and resources within that namespace that are being managed by the placement.
1535+ // The status will show placement details for resources selected by the ClusterResourcePlacement's ResourceSelectors.
1536+ // +kubebuilder:validation:Optional
1537+ Status PlacementStatus `json:"status,omitempty"`
1538+ }
1539+
1540+ // PlacementStatusProxyList contains a list of PlacementStatusProxy.
1541+ // +kubebuilder:resource:scope="Namespaced"
1542+ // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1543+ type PlacementStatusProxyList struct {
1544+ metav1.TypeMeta `json:",inline"`
1545+ metav1.ListMeta `json:"metadata,omitempty"`
1546+ Items []PlacementStatusProxy `json:"items"`
1547+ }
1548+
1549+ // SetConditions sets the conditions of the PlacementStatusProxy.
1550+ func (m * PlacementStatusProxy ) SetConditions (conditions ... metav1.Condition ) {
1551+ for _ , c := range conditions {
1552+ meta .SetStatusCondition (& m .Status .Conditions , c )
1553+ }
1554+ }
1555+
1556+ // GetCondition returns the condition of the PlacementStatusProxy objects.
1557+ func (m * PlacementStatusProxy ) GetCondition (conditionType string ) * metav1.Condition {
1558+ return meta .FindStatusCondition (m .Status .Conditions , conditionType )
1559+ }
1560+
14981561func init () {
1499- SchemeBuilder .Register (& ClusterResourcePlacement {}, & ClusterResourcePlacementList {}, & ResourcePlacement {}, & ResourcePlacementList {})
1562+ SchemeBuilder .Register (& ClusterResourcePlacement {}, & ClusterResourcePlacementList {}, & ResourcePlacement {}, & ResourcePlacementList {}, & PlacementStatusProxy {}, & PlacementStatusProxyList {} )
15001563}
0 commit comments