diff --git a/apis/cluster/v1beta1/zz_generated.deepcopy.go b/apis/cluster/v1beta1/zz_generated.deepcopy.go index 6d06cb15b..6c25f0189 100644 --- a/apis/cluster/v1beta1/zz_generated.deepcopy.go +++ b/apis/cluster/v1beta1/zz_generated.deepcopy.go @@ -10,7 +10,7 @@ Licensed under the MIT license. package v1beta1 import ( - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/apis/placement/v1alpha1/stagedupdate_types.go b/apis/placement/v1alpha1/stagedupdate_types.go index 6c0b572e0..867ba3840 100644 --- a/apis/placement/v1alpha1/stagedupdate_types.go +++ b/apis/placement/v1alpha1/stagedupdate_types.go @@ -12,27 +12,28 @@ import ( ) // +genclient -// +genclient:namespaced +// +genclient:Cluster // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:resource:scope="Namespaced",categories={fleet,fleet-placement} +// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=crsur // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// StagedUpdateRun represents a stage by stage update process that applies selected resources to specified clusters. +// ClusterStagedUpdateRun represents a stage by stage update process that applies ClusterResourcePlacement +// selected resources to specified clusters. // Resources from unselected clusters are removed after all stages in the update strategy are completed. -// Each StagedUpdateRun object corresponds to a single release of a specific resource version. -// The release is abandoned if the StagedUpdateRun object is deleted or the scheduling decision changes. -// The name of the StagedUpdateRun must conform to RFC 1123. -type StagedUpdateRun struct { +// Each ClusterStagedUpdateRun object corresponds to a single release of a specific resource version. +// The release is abandoned if the ClusterStagedUpdateRun object is deleted or the scheduling decision changes. +// The name of the ClusterStagedUpdateRun must conform to RFC 1123. +type ClusterStagedUpdateRun struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // The desired state of StagedUpdateRun. The spec is immutable. + // The desired state of ClusterStagedUpdateRun. The spec is immutable. // +kubebuilder:validation:Required // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="The spec field is immutable" Spec StagedUpdateRunSpec `json:"spec"` - // The observed status of StagedUpdateRun. + // The observed status of ClusterStagedUpdateRun. // +kubebuilder:validation:Optional Status StagedUpdateRunStatus `json:"status,omitempty"` } @@ -40,46 +41,40 @@ type StagedUpdateRun struct { // StagedUpdateRunSpec defines the desired rollout strategy and the snapshot indices of the resources to be updated. // It specifies a stage-by-stage update process across selected clusters for the given ResourcePlacement object. type StagedUpdateRunSpec struct { - // A reference to the placement that this update run is applied to. + // PlacementName is the name of placement that this update run is applied to. // There can be multiple active update runs for each placement, but // it's up to the DevOps team to ensure they don't conflict with each other. // +kubebuilder:validation:Required - PlacementRef PlacementReference `json:"placementRef"` + // +kubebuilder:validation:MaxLength=255 + PlacementName string `json:"placementName"` // The resource snapshot index of the selected resources to be updated across clusters. // The index represents a group of resource snapshots that includes all the resources a ResourcePlacement selected. // +kubebuilder:validation:Required ResourceSnapshotIndex string `json:"resourceSnapshotIndex"` - // The reference to the update strategy that specifies the stages and the sequence + // The name of the update strategy that specifies the stages and the sequence // in which the selected resources will be updated on the member clusters. The stages // are computed according to the referenced strategy when the update run starts // and recorded in the status field. // +kubebuilder:validation:Required - StagedUpdateStrategyRef v1beta1.NamespacedName `json:"stagedRolloutStrategyRef"` -} - -// PlacementReference is a reference to a placement object. -type PlacementReference struct { - // Name is the name of the referenced placement. - // +kubebuilder:validation:Required - Name string `json:"name"` + StagedUpdateStrategyName string `json:"stagedRolloutStrategyName"` } // +genclient -// +genclient:namespaced +// +genclient:cluster // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:resource:scope="Namespaced",categories={fleet,fleet-placement} +// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=sus // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// StagedUpdateStrategy defines a reusable strategy that specifies the stages and the sequence -// in which the selected resources will be updated on the member clusters. -type StagedUpdateStrategy struct { +// ClusterStagedUpdateStrategy defines a reusable strategy that specifies the stages and the sequence +// in which the selected cluster resources will be updated on the member clusters. +type ClusterStagedUpdateStrategy struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // The desired state of StagedUpdateStrategy. + // The desired state of ClusterStagedUpdateStrategy. // +kubebuilder:validation:Required Spec StagedUpdateStrategySpec `json:"spec"` } @@ -92,13 +87,13 @@ type StagedUpdateStrategySpec struct { Stages []StageConfig `json:"stages"` } -// StagedUpdateStrategyList contains a list of StagedUpdateStrategy. -// +kubebuilder:resource:scope="Namespaced" +// ClusterStagedUpdateStrategyList contains a list of StagedUpdateStrategy. +// +kubebuilder:resource:scope=Cluster // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type StagedUpdateStrategyList struct { +type ClusterStagedUpdateStrategyList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []StagedUpdateStrategy `json:"items"` + Items []ClusterStagedUpdateStrategy `json:"items"` } // StageConfig describes a single update stage. @@ -146,7 +141,7 @@ type AfterStageTask struct { WaitTime metav1.Duration `json:"waitTime,omitempty"` } -// StagedUpdateRunStatus defines the observed state of the StagedUpdateRun. +// StagedUpdateRunStatus defines the observed state of the ClusterStagedUpdateRun. type StagedUpdateRunStatus struct { // PolicySnapShotIndexUsed records the policy snapshot index of the ClusterResourcePlacement (CRP) that // the update run is based on. The index represents the latest policy snapshot at the start of the update run. @@ -157,11 +152,17 @@ type StagedUpdateRunStatus struct { // +kubebuilder:validation:Optional PolicySnapshotIndexUsed string `json:"policySnapshotIndexUsed,omitempty"` + // PolicyObservedClusterCount records the number of observed clusters in the policy snapshot. + // It is recorded at the beginning of the update run from the policy snapshot object. + // If the `ObservedClusterCount` value is updated during the update run, the update run is abandoned. + // +kubebuilder:validation:Optional + PolicyObservedClusterCount int `json:"policyObservedClusterCount,omitempty"` + // ApplyStrategy is the apply strategy that the stagedUpdateRun is using. // It is the same as the apply strategy in the CRP when the staged update run starts. // The apply strategy is not updated during the update run even if it changes in the CRP. // +kubebuilder:validation:Optional - ApplyStrategy v1beta1.ApplyStrategy `json:"appliedStrategy,omitempty"` + ApplyStrategy *v1beta1.ApplyStrategy `json:"appliedStrategy,omitempty"` // StagedUpdateStrategySnapshot is the snapshot of the StagedUpdateStrategy used for the update run. // The snapshot is immutable during the update run. @@ -169,7 +170,7 @@ type StagedUpdateRunStatus struct { // The update run fails to initialize if the strategy fails to produce a valid list of stages where each selected // cluster is included in exactly one stage. // +kubebuilder:validation:Optional - StagedUpdateStrategySnapshot StagedUpdateStrategySpec `json:"stagedUpdateStrategySnapshot,omitempty"` + StagedUpdateStrategySnapshot *StagedUpdateStrategySpec `json:"stagedUpdateStrategySnapshot,omitempty"` // StagesStatus lists the current updating status of each stage. // The list is empty if the update run is not started or failed to initialize. @@ -180,7 +181,7 @@ type StagedUpdateRunStatus struct { // removes all the resources from the clusters that are not selected by the // current policy after all the update stages are completed. // +kubebuilder:validation:Optional - DeletionStageStatus StageUpdatingStatus `json:"deletionStageStatus,omitempty"` + DeletionStageStatus *StageUpdatingStatus `json:"deletionStageStatus,omitempty"` // +patchMergeKey=type // +patchStrategy=merge @@ -201,8 +202,9 @@ const ( // StagedUpdateRunConditionInitialized indicates whether the staged update run is initialized, meaning it // has computed all the stages according to the referenced strategy and is ready to start the update. // Its condition status can be one of the following: - // - "True": The staged update run is initialized. - // - "False": The staged update run encountered an error during initialization. + // - "True": The staged update run is initialized successfully. + // - "False": The staged update run encountered an error during initialization and aborted. + // - "Unknown": The staged update run initialization has started. StagedUpdateRunConditionInitialized StagedUpdateRunConditionType = "Initialized" // StagedUpdateRunConditionProgressing indicates whether the staged update run is making progress. @@ -269,11 +271,11 @@ const ( // - "False": The stage updating is waiting/pausing. StageUpdatingConditionProgressing StageUpdatingConditionType = "Progressing" - // ClusterUpdatingStatusConditionSucceeded indicates whether the stage updating is completed successfully. + // StageUpdatingConditionSucceeded indicates whether the stage updating is completed successfully. // Its condition status can be one of the following: // - "True": The stage updating is completed successfully. // - "False": The stage updating encountered an error and stopped. - ClusterUpdatingStatusConditionSucceeded StageUpdatingConditionType = "Succeeded" + StageUpdatingConditionSucceeded StageUpdatingConditionType = "Succeeded" ) // ClusterUpdatingStatus defines the status of the update run on a cluster. @@ -311,17 +313,16 @@ type ClusterUpdatingStatus struct { type ClusterUpdatingStatusConditionType string const ( - // UpdatingStatusConditionTypeStarted indicates whether the cluster updating has started. + // ClusterUpdatingConditionStarted indicates whether the cluster updating has started. // Its condition status can be one of the following: // - "True": The cluster updating has started. - // - "False": The stage updating has not started. - UpdatingStatusConditionTypeStarted ClusterUpdatingStatusConditionType = "Started" + ClusterUpdatingConditionStarted ClusterUpdatingStatusConditionType = "Started" - // UpdatingStatusConditionTypeSucceeded indicates whether the cluster updating is completed successfully. + // ClusterUpdatingConditionSucceeded indicates whether the cluster updating is completed successfully. // Its condition status can be one of the following: // - "True": The cluster updating is completed successfully. // - "False": The cluster updating encountered an error and stopped. - UpdatingStatusConditionTypeSucceeded ClusterUpdatingStatusConditionType = "Succeeded" + ClusterUpdatingConditionSucceeded ClusterUpdatingStatusConditionType = "Succeeded" ) type AfterStageTaskStatus struct { @@ -366,54 +367,52 @@ const ( // AfterStageTaskConditionApprovalRequestCreated indicates if the approval request has been created. // Its condition status can be: // - "True": The approval request has been created. - // - "False": The approval request has not been created. AfterStageTaskConditionApprovalRequestCreated AfterStageTaskConditionType = "ApprovalRequestCreated" // AfterStageTaskConditionApprovalRequestApproved indicates if the approval request has been approved. // Its condition status can be: // - "True": The approval request has been approved. - // - "False": The approval request has not been approved. AfterStageTaskConditionApprovalRequestApproved AfterStageTaskConditionType = "ApprovalRequestApproved" - // AfterStageTaskConditionApprovalWaitTimeElapsed indicates if the wait time after each stage has elapsed. + // AfterStageTaskConditionWaitTimeElapsed indicates if the wait time after each stage has elapsed. // If the status is "False", the condition message will include the remaining wait time. // Its condition status can be: // - "True": The wait time has elapsed. // - "False": The wait time has not elapsed. - AfterStageTaskConditionApprovalWaitTimeElapsed AfterStageTaskConditionType = "WaitTimeElapsed" + AfterStageTaskConditionWaitTimeElapsed AfterStageTaskConditionType = "WaitTimeElapsed" ) -// StagedUpdateRunList contains a list of StagedUpdateRun. -// +kubebuilder:resource:scope="Namespaced" +// ClusterStagedUpdateRunList contains a list of ClusterStagedUpdateRun. +// +kubebuilder:resource:scope=Cluster // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type StagedUpdateRunList struct { +type ClusterStagedUpdateRunList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []StagedUpdateRun `json:"items"` + Items []ClusterStagedUpdateRun `json:"items"` } // +genclient -// +genclient:namespaced +// +genclient:Cluster // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:resource:scope="Namespaced",categories={fleet,fleet-placement} +// +kubebuilder:resource:scope=Cluster,categories={fleet,fleet-placement},shortName=careq // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// ApprovalRequest defines a request for user approval. +// ClusterApprovalRequest defines a request for user approval for cluster staged update run. // The request object MUST have the following labels: -// - `TargetUpdateRun`: Points to the update run that this approval request is for. +// - `TargetUpdateRun`: Points to the cluster staged update run that this approval request is for. // - `TargetStage`: The name of the stage that this approval request is for. // - `IsLatestUpdateRunApproval`: Indicates whether this approval request is the latest one related to this update run. -type ApprovalRequest struct { +type ClusterApprovalRequest struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - // The desired state of ApprovalRequest. + // The desired state of ClusterApprovalRequest. // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="The spec field is immutable" // +kubebuilder:validation:Required Spec ApprovalRequestSpec `json:"spec"` - // The observed state of ApprovalRequest. + // The observed state of ClusterApprovalRequest. // +kubebuilder:validation:Optional Status ApprovalRequestStatus `json:"status,omitempty"` } @@ -430,7 +429,7 @@ type ApprovalRequestSpec struct { TargetStage string `json:"targetStage"` } -// ApprovalRequestStatus defines the observed state of the ApprovalRequest. +// ApprovalRequestStatus defines the observed state of the ClusterApprovalRequest. type ApprovalRequestStatus struct { // +patchMergeKey=type // +patchStrategy=merge @@ -443,35 +442,27 @@ type ApprovalRequestStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty"` } -// ApprovalRequestConditionType identifies a specific condition of the ApprovalRequest. +// ApprovalRequestConditionType identifies a specific condition of the ClusterApprovalRequest. type ApprovalRequestConditionType string const ( // ApprovalRequestConditionApproved indicates if the approval request was approved. // Its condition status can be: // - "True": The request is approved. - // - "False": The request is not approved. ApprovalRequestConditionApproved ApprovalRequestConditionType = "Approved" - - // ApprovalRequestConditionApprovalAccepted indicates whether the approval request is accepted by the update process. - // Its condition status can be: - // - "True": The approval request is accepted. - // - "False": The approval request is not accepted. - // - "Unknown": The approval request is not yet approved. - ApprovalRequestConditionApprovalAccepted ApprovalRequestConditionType = "ApprovalAccepted" ) -// ApprovalRequestList contains a list of ApprovalRequest. -// +kubebuilder:resource:scope="Namespaced" +// ClusterApprovalRequestList contains a list of ClusterApprovalRequest. +// +kubebuilder:resource:scope=Cluster // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type ApprovalRequestList struct { +type ClusterApprovalRequestList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []ApprovalRequest `json:"items"` + Items []ClusterApprovalRequest `json:"items"` } func init() { SchemeBuilder.Register( - &StagedUpdateRun{}, &StagedUpdateRunList{}, &StagedUpdateStrategy{}, &StagedUpdateStrategyList{}, &ApprovalRequest{}, &ApprovalRequestList{}, + &ClusterStagedUpdateRun{}, &ClusterStagedUpdateRunList{}, &ClusterStagedUpdateStrategy{}, &ClusterStagedUpdateStrategyList{}, &ClusterApprovalRequest{}, &ClusterApprovalRequestList{}, ) } diff --git a/apis/placement/v1alpha1/zz_generated.deepcopy.go b/apis/placement/v1alpha1/zz_generated.deepcopy.go index d9caa6b5c..d26fe49a5 100644 --- a/apis/placement/v1alpha1/zz_generated.deepcopy.go +++ b/apis/placement/v1alpha1/zz_generated.deepcopy.go @@ -55,101 +55,101 @@ func (in *AfterStageTaskStatus) DeepCopy() *AfterStageTaskStatus { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApprovalRequest) DeepCopyInto(out *ApprovalRequest) { +func (in *ApprovalRequestSpec) DeepCopyInto(out *ApprovalRequestSpec) { *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApprovalRequest. -func (in *ApprovalRequest) DeepCopy() *ApprovalRequest { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApprovalRequestSpec. +func (in *ApprovalRequestSpec) DeepCopy() *ApprovalRequestSpec { if in == nil { return nil } - out := new(ApprovalRequest) + out := new(ApprovalRequestSpec) in.DeepCopyInto(out) return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApprovalRequest) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApprovalRequestList) DeepCopyInto(out *ApprovalRequestList) { +func (in *ApprovalRequestStatus) DeepCopyInto(out *ApprovalRequestStatus) { *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ApprovalRequest, len(*in)) + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApprovalRequestList. -func (in *ApprovalRequestList) DeepCopy() *ApprovalRequestList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApprovalRequestStatus. +func (in *ApprovalRequestStatus) DeepCopy() *ApprovalRequestStatus { if in == nil { return nil } - out := new(ApprovalRequestList) + out := new(ApprovalRequestStatus) in.DeepCopyInto(out) return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApprovalRequestList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApprovalRequestSpec) DeepCopyInto(out *ApprovalRequestSpec) { +func (in *ClusterApprovalRequest) DeepCopyInto(out *ClusterApprovalRequest) { *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApprovalRequestSpec. -func (in *ApprovalRequestSpec) DeepCopy() *ApprovalRequestSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterApprovalRequest. +func (in *ClusterApprovalRequest) DeepCopy() *ClusterApprovalRequest { if in == nil { return nil } - out := new(ApprovalRequestSpec) + out := new(ClusterApprovalRequest) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterApprovalRequest) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApprovalRequestStatus) DeepCopyInto(out *ApprovalRequestStatus) { +func (in *ClusterApprovalRequestList) DeepCopyInto(out *ClusterApprovalRequestList) { *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterApprovalRequest, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApprovalRequestStatus. -func (in *ApprovalRequestStatus) DeepCopy() *ApprovalRequestStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterApprovalRequestList. +func (in *ClusterApprovalRequestList) DeepCopy() *ClusterApprovalRequestList { if in == nil { return nil } - out := new(ApprovalRequestStatus) + out := new(ClusterApprovalRequestList) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterApprovalRequestList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterResourceOverride) DeepCopyInto(out *ClusterResourceOverride) { *out = *in @@ -431,6 +431,123 @@ func (in *ClusterResourcePlacementEvictionList) DeepCopyObject() runtime.Object return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterStagedUpdateRun) DeepCopyInto(out *ClusterStagedUpdateRun) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStagedUpdateRun. +func (in *ClusterStagedUpdateRun) DeepCopy() *ClusterStagedUpdateRun { + if in == nil { + return nil + } + out := new(ClusterStagedUpdateRun) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterStagedUpdateRun) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterStagedUpdateRunList) DeepCopyInto(out *ClusterStagedUpdateRunList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterStagedUpdateRun, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStagedUpdateRunList. +func (in *ClusterStagedUpdateRunList) DeepCopy() *ClusterStagedUpdateRunList { + if in == nil { + return nil + } + out := new(ClusterStagedUpdateRunList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterStagedUpdateRunList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterStagedUpdateStrategy) DeepCopyInto(out *ClusterStagedUpdateStrategy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStagedUpdateStrategy. +func (in *ClusterStagedUpdateStrategy) DeepCopy() *ClusterStagedUpdateStrategy { + if in == nil { + return nil + } + out := new(ClusterStagedUpdateStrategy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterStagedUpdateStrategy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterStagedUpdateStrategyList) DeepCopyInto(out *ClusterStagedUpdateStrategyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterStagedUpdateStrategy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStagedUpdateStrategyList. +func (in *ClusterStagedUpdateStrategyList) DeepCopy() *ClusterStagedUpdateStrategyList { + if in == nil { + return nil + } + out := new(ClusterStagedUpdateStrategyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterStagedUpdateStrategyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterUpdatingStatus) DeepCopyInto(out *ClusterUpdatingStatus) { *out = *in @@ -590,21 +707,6 @@ func (in *PlacementEvictionStatus) DeepCopy() *PlacementEvictionStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PlacementReference) DeepCopyInto(out *PlacementReference) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlacementReference. -func (in *PlacementReference) DeepCopy() *PlacementReference { - if in == nil { - return nil - } - out := new(PlacementReference) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceOverride) DeepCopyInto(out *ResourceOverride) { *out = *in @@ -856,70 +958,9 @@ func (in *StageUpdatingStatus) DeepCopy() *StageUpdatingStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StagedUpdateRun) DeepCopyInto(out *StagedUpdateRun) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StagedUpdateRun. -func (in *StagedUpdateRun) DeepCopy() *StagedUpdateRun { - if in == nil { - return nil - } - out := new(StagedUpdateRun) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *StagedUpdateRun) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StagedUpdateRunList) DeepCopyInto(out *StagedUpdateRunList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]StagedUpdateRun, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StagedUpdateRunList. -func (in *StagedUpdateRunList) DeepCopy() *StagedUpdateRunList { - if in == nil { - return nil - } - out := new(StagedUpdateRunList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *StagedUpdateRunList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StagedUpdateRunSpec) DeepCopyInto(out *StagedUpdateRunSpec) { *out = *in - out.PlacementRef = in.PlacementRef - out.StagedUpdateStrategyRef = in.StagedUpdateStrategyRef } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StagedUpdateRunSpec. @@ -935,8 +976,16 @@ func (in *StagedUpdateRunSpec) DeepCopy() *StagedUpdateRunSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StagedUpdateRunStatus) DeepCopyInto(out *StagedUpdateRunStatus) { *out = *in - in.ApplyStrategy.DeepCopyInto(&out.ApplyStrategy) - in.StagedUpdateStrategySnapshot.DeepCopyInto(&out.StagedUpdateStrategySnapshot) + if in.ApplyStrategy != nil { + in, out := &in.ApplyStrategy, &out.ApplyStrategy + *out = new(v1beta1.ApplyStrategy) + (*in).DeepCopyInto(*out) + } + if in.StagedUpdateStrategySnapshot != nil { + in, out := &in.StagedUpdateStrategySnapshot, &out.StagedUpdateStrategySnapshot + *out = new(StagedUpdateStrategySpec) + (*in).DeepCopyInto(*out) + } if in.StagesStatus != nil { in, out := &in.StagesStatus, &out.StagesStatus *out = make([]StageUpdatingStatus, len(*in)) @@ -944,7 +993,11 @@ func (in *StagedUpdateRunStatus) DeepCopyInto(out *StagedUpdateRunStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.DeletionStageStatus.DeepCopyInto(&out.DeletionStageStatus) + if in.DeletionStageStatus != nil { + in, out := &in.DeletionStageStatus, &out.DeletionStageStatus + *out = new(StageUpdatingStatus) + (*in).DeepCopyInto(*out) + } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]v1.Condition, len(*in)) @@ -964,64 +1017,6 @@ func (in *StagedUpdateRunStatus) DeepCopy() *StagedUpdateRunStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StagedUpdateStrategy) DeepCopyInto(out *StagedUpdateStrategy) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StagedUpdateStrategy. -func (in *StagedUpdateStrategy) DeepCopy() *StagedUpdateStrategy { - if in == nil { - return nil - } - out := new(StagedUpdateStrategy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *StagedUpdateStrategy) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StagedUpdateStrategyList) DeepCopyInto(out *StagedUpdateStrategyList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]StagedUpdateStrategy, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StagedUpdateStrategyList. -func (in *StagedUpdateStrategyList) DeepCopy() *StagedUpdateStrategyList { - if in == nil { - return nil - } - out := new(StagedUpdateStrategyList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *StagedUpdateStrategyList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StagedUpdateStrategySpec) DeepCopyInto(out *StagedUpdateStrategySpec) { *out = *in diff --git a/apis/placement/v1beta1/zz_generated.deepcopy.go b/apis/placement/v1beta1/zz_generated.deepcopy.go index 48d0fdc6a..53b87d2fb 100644 --- a/apis/placement/v1beta1/zz_generated.deepcopy.go +++ b/apis/placement/v1beta1/zz_generated.deepcopy.go @@ -10,7 +10,7 @@ Licensed under the MIT license. package v1beta1 import ( - "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" ) diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 0d4061551..ac4844274 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -11,7 +11,7 @@ package v1alpha1 import ( corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/config/crd/bases/placement.kubernetes-fleet.io_approvalrequests.yaml b/config/crd/bases/placement.kubernetes-fleet.io_clusterapprovalrequests.yaml similarity index 91% rename from config/crd/bases/placement.kubernetes-fleet.io_approvalrequests.yaml rename to config/crd/bases/placement.kubernetes-fleet.io_clusterapprovalrequests.yaml index 1c199f1b8..03d208d0a 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_approvalrequests.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_clusterapprovalrequests.yaml @@ -4,26 +4,28 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.15.0 - name: approvalrequests.placement.kubernetes-fleet.io + name: clusterapprovalrequests.placement.kubernetes-fleet.io spec: group: placement.kubernetes-fleet.io names: categories: - fleet - fleet-placement - kind: ApprovalRequest - listKind: ApprovalRequestList - plural: approvalrequests - singular: approvalrequest - scope: Namespaced + kind: ClusterApprovalRequest + listKind: ClusterApprovalRequestList + plural: clusterapprovalrequests + shortNames: + - careq + singular: clusterapprovalrequest + scope: Cluster versions: - name: v1alpha1 schema: openAPIV3Schema: description: |- - ApprovalRequest defines a request for user approval. + ClusterApprovalRequest defines a request for user approval for cluster staged update run. The request object MUST have the following labels: - - `TargetUpdateRun`: Points to the update run that this approval request is for. + - `TargetUpdateRun`: Points to the cluster staged update run that this approval request is for. - `TargetStage`: The name of the stage that this approval request is for. - `IsLatestUpdateRunApproval`: Indicates whether this approval request is the latest one related to this update run. properties: @@ -45,7 +47,7 @@ spec: metadata: type: object spec: - description: The desired state of ApprovalRequest. + description: The desired state of ClusterApprovalRequest. properties: parentStageRollout: description: The name of the staged update run that this approval @@ -63,7 +65,7 @@ spec: - message: The spec field is immutable rule: self == oldSelf status: - description: The observed state of ApprovalRequest. + description: The observed state of ClusterApprovalRequest. properties: conditions: description: |- diff --git a/config/crd/bases/placement.kubernetes-fleet.io_stagedupdateruns.yaml b/config/crd/bases/placement.kubernetes-fleet.io_clusterstagedupdateruns.yaml similarity index 97% rename from config/crd/bases/placement.kubernetes-fleet.io_stagedupdateruns.yaml rename to config/crd/bases/placement.kubernetes-fleet.io_clusterstagedupdateruns.yaml index 69cdd278f..f149b3e98 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_stagedupdateruns.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_clusterstagedupdateruns.yaml @@ -4,28 +4,31 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.15.0 - name: stagedupdateruns.placement.kubernetes-fleet.io + name: clusterstagedupdateruns.placement.kubernetes-fleet.io spec: group: placement.kubernetes-fleet.io names: categories: - fleet - fleet-placement - kind: StagedUpdateRun - listKind: StagedUpdateRunList - plural: stagedupdateruns - singular: stagedupdaterun - scope: Namespaced + kind: ClusterStagedUpdateRun + listKind: ClusterStagedUpdateRunList + plural: clusterstagedupdateruns + shortNames: + - crsur + singular: clusterstagedupdaterun + scope: Cluster versions: - name: v1alpha1 schema: openAPIV3Schema: description: |- - StagedUpdateRun represents a stage by stage update process that applies selected resources to specified clusters. + ClusterStagedUpdateRun represents a stage by stage update process that applies ClusterResourcePlacement + selected resources to specified clusters. Resources from unselected clusters are removed after all stages in the update strategy are completed. - Each StagedUpdateRun object corresponds to a single release of a specific resource version. - The release is abandoned if the StagedUpdateRun object is deleted or the scheduling decision changes. - The name of the StagedUpdateRun must conform to RFC 1123. + Each ClusterStagedUpdateRun object corresponds to a single release of a specific resource version. + The release is abandoned if the ClusterStagedUpdateRun object is deleted or the scheduling decision changes. + The name of the ClusterStagedUpdateRun must conform to RFC 1123. properties: apiVersion: description: |- @@ -45,52 +48,38 @@ spec: metadata: type: object spec: - description: The desired state of StagedUpdateRun. The spec is immutable. + description: The desired state of ClusterStagedUpdateRun. The spec is + immutable. properties: - placementRef: + placementName: description: |- - A reference to the placement that this update run is applied to. + PlacementName is the name of placement that this update run is applied to. There can be multiple active update runs for each placement, but it's up to the DevOps team to ensure they don't conflict with each other. - properties: - name: - description: Name is the name of the referenced placement. - type: string - required: - - name - type: object + maxLength: 255 + type: string resourceSnapshotIndex: description: |- The resource snapshot index of the selected resources to be updated across clusters. The index represents a group of resource snapshots that includes all the resources a ResourcePlacement selected. type: string - stagedRolloutStrategyRef: + stagedRolloutStrategyName: description: |- - The reference to the update strategy that specifies the stages and the sequence + The name of the update strategy that specifies the stages and the sequence in which the selected resources will be updated on the member clusters. The stages are computed according to the referenced strategy when the update run starts and recorded in the status field. - properties: - name: - description: Name is the name of the namespaced scope resource. - type: string - namespace: - description: Namespace is namespace of the namespaced scope resource. - type: string - required: - - name - - namespace - type: object + type: string required: - - placementRef + - placementName - resourceSnapshotIndex - - stagedRolloutStrategyRef + - stagedRolloutStrategyName type: object x-kubernetes-validations: - message: The spec field is immutable rule: self == oldSelf status: - description: The observed status of StagedUpdateRun. + description: The observed status of ClusterStagedUpdateRun. properties: appliedStrategy: description: |- @@ -720,6 +709,12 @@ spec: - clusters - stageName type: object + policyObservedClusterCount: + description: |- + PolicyObservedClusterCount records the number of observed clusters in the policy snapshot. + It is recorded at the beginning of the update run from the policy snapshot object. + If the `ObservedClusterCount` value is updated during the update run, the update run is abandoned. + type: integer policySnapshotIndexUsed: description: |- PolicySnapShotIndexUsed records the policy snapshot index of the ClusterResourcePlacement (CRP) that diff --git a/config/crd/bases/placement.kubernetes-fleet.io_stagedupdatestrategies.yaml b/config/crd/bases/placement.kubernetes-fleet.io_clusterstagedupdatestrategies.yaml similarity index 92% rename from config/crd/bases/placement.kubernetes-fleet.io_stagedupdatestrategies.yaml rename to config/crd/bases/placement.kubernetes-fleet.io_clusterstagedupdatestrategies.yaml index 63c97c2b3..673ce5ce5 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_stagedupdatestrategies.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_clusterstagedupdatestrategies.yaml @@ -4,25 +4,27 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.15.0 - name: stagedupdatestrategies.placement.kubernetes-fleet.io + name: clusterstagedupdatestrategies.placement.kubernetes-fleet.io spec: group: placement.kubernetes-fleet.io names: categories: - fleet - fleet-placement - kind: StagedUpdateStrategy - listKind: StagedUpdateStrategyList - plural: stagedupdatestrategies - singular: stagedupdatestrategy - scope: Namespaced + kind: ClusterStagedUpdateStrategy + listKind: ClusterStagedUpdateStrategyList + plural: clusterstagedupdatestrategies + shortNames: + - sus + singular: clusterstagedupdatestrategy + scope: Cluster versions: - name: v1alpha1 schema: openAPIV3Schema: description: |- - StagedUpdateStrategy defines a reusable strategy that specifies the stages and the sequence - in which the selected resources will be updated on the member clusters. + ClusterStagedUpdateStrategy defines a reusable strategy that specifies the stages and the sequence + in which the selected cluster resources will be updated on the member clusters. properties: apiVersion: description: |- @@ -42,7 +44,7 @@ spec: metadata: type: object spec: - description: The desired state of StagedUpdateStrategy. + description: The desired state of ClusterStagedUpdateStrategy. properties: stages: description: Stage specifies the configuration for each update stage.