Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion apis/placement/v1beta1/clusterresourceplacement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,40 @@ func (rpl *ResourcePlacementList) GetPlacementObjs() []PlacementObj {
return objs
}

// +genclient
// +genclient:Namespaced
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope="Namespaced"
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ManagedNamespacePlacement is used to represent which clusters the namespace has been placed on to.
type ManagedNamespacePlacement struct {
Comment thread
britaniar marked this conversation as resolved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use managednamespace as a prefix? Should this object exist for namespaces placed by a CRP?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you know which CRP this status is for? Can one namespace selected/placed by N CRPs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this object won't exist when there are N CRPs, provide a comment.

metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// The observed status of the ManagedNamespacePlacement.
// +kubebuilder:validation:Optional
Status ManagedNamespacePlacementStatus `json:"status,omitempty"`
}

// ManagedNamespacePlacementStatus represents the status of a ManagedNamespacePlacement.
type ManagedNamespacePlacementStatus struct {
// ResourcePlacements contains the placement statuses for the namespace.
// +kubebuilder:validation:Optional
ResourcePlacements []ResourcePlacementStatus `json:"resourcePlacements,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the status represent? Only the status of the namespace or namespace+resources as selected by the CRP?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is a copy of the ResourcePlacementStatus list from CRP. If so, I would recommend to copy the whole status as SelectedResources and ObservedResourceIndex are also critical information to understand the conditions.

}

// ManagedNamespacePlacementList contains a list of ManagedNamespacePlacement.
// +kubebuilder:resource:scope="Namespaced"
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type ManagedNamespacePlacementList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ManagedNamespacePlacement `json:"items"`
}

func init() {
SchemeBuilder.Register(&ClusterResourcePlacement{}, &ClusterResourcePlacementList{}, &ResourcePlacement{}, &ResourcePlacementList{})
SchemeBuilder.Register(&ClusterResourcePlacement{}, &ClusterResourcePlacementList{}, &ResourcePlacement{}, &ResourcePlacementList{}, &ManagedNamespacePlacement{}, &ManagedNamespacePlacementList{})
}
80 changes: 80 additions & 0 deletions apis/placement/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crdinstaller/utils/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func runTest(t *testing.T, crdPath string) {
name: "hub mode v1beta1 with actual directory",
mode: "hub",
wantedCRDNames: []string{
"managednamespaceplacements.placement.kubernetes-fleet.io",
"memberclusters.cluster.kubernetes-fleet.io",
"internalmemberclusters.cluster.kubernetes-fleet.io",
"clusterapprovalrequests.placement.kubernetes-fleet.io",
Expand Down
Loading
Loading