diff --git a/apis/cluster/v1beta1/zz_generated.deepcopy.go b/apis/cluster/v1beta1/zz_generated.deepcopy.go index 6c25f0189..6d06cb15b 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 ( - v1 "k8s.io/api/core/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/override_types.go b/apis/placement/v1alpha1/override_types.go index 0343cb9fa..9459d10cc 100644 --- a/apis/placement/v1alpha1/override_types.go +++ b/apis/placement/v1alpha1/override_types.go @@ -34,6 +34,13 @@ type ClusterResourceOverride struct { // If the resource is selected by both ClusterResourceOverride and ResourceOverride, ResourceOverride will win when resolving // conflicts. type ClusterResourceOverrideSpec struct { + // Placement defines whether the override is applied to a specific placement or not. + // If set, the override will trigger the placement rollout immediately when the rollout strategy type is RollingUpdate. + // Otherwise, it will be applied to the next rollout. + // The recommended way is to set the placement so that the override can be rolled out immediately. + // +optional + Placement *PlacementRef `json:"placement,omitempty"` + // ClusterResourceSelectors is an array of selectors used to select cluster scoped resources. The selectors are `ORed`. // If a namespace is selected, ALL the resources under the namespace are selected automatically. // LabelSelector is not supported. @@ -50,6 +57,14 @@ type ClusterResourceOverrideSpec struct { Policy *OverridePolicy `json:"policy"` } +// PlacementRef is the reference to a placement. +// For now, we only support ClusterResourcePlacement. +type PlacementRef struct { + // Name is the reference to the name of placement. + // +required + Name string `json:"name"` +} + // OverridePolicy defines how to override the selected resources on the target clusters. // More is to be added. type OverridePolicy struct { @@ -122,6 +137,13 @@ type ResourceOverride struct { // If the resource is selected by both ClusterResourceOverride and ResourceOverride, ResourceOverride will win when resolving // conflicts. type ResourceOverrideSpec struct { + // Placement defines whether the override is applied to a specific placement or not. + // If set, the override will trigger the placement rollout immediately when the rollout strategy type is RollingUpdate. + // Otherwise, it will be applied to the next rollout. + // The recommended way is to set the placement so that the override can be rolled out immediately. + // +optional + Placement *PlacementRef `json:"placement,omitempty"` + // ResourceSelectors is an array of selectors used to select namespace scoped resources. The selectors are `ORed`. // You can have 1-20 selectors. // +kubebuilder:validation:Required diff --git a/apis/placement/v1alpha1/zz_generated.deepcopy.go b/apis/placement/v1alpha1/zz_generated.deepcopy.go index 1a3f72658..755b15f16 100644 --- a/apis/placement/v1alpha1/zz_generated.deepcopy.go +++ b/apis/placement/v1alpha1/zz_generated.deepcopy.go @@ -10,11 +10,10 @@ Licensed under the MIT license. package v1alpha1 import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "go.goms.io/fleet/apis/placement/v1beta1" + "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" - - "go.goms.io/fleet/apis/placement/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -291,6 +290,11 @@ func (in *ClusterResourceOverrideSnapshotSpec) DeepCopy() *ClusterResourceOverri // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterResourceOverrideSpec) DeepCopyInto(out *ClusterResourceOverrideSpec) { *out = *in + if in.Placement != nil { + in, out := &in.Placement, &out.Placement + *out = new(PlacementRef) + **out = **in + } if in.ClusterResourceSelectors != nil { in, out := &in.ClusterResourceSelectors, &out.ClusterResourceSelectors *out = make([]v1beta1.ClusterResourceSelector, len(*in)) @@ -708,6 +712,21 @@ 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 *PlacementRef) DeepCopyInto(out *PlacementRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlacementRef. +func (in *PlacementRef) DeepCopy() *PlacementRef { + if in == nil { + return nil + } + out := new(PlacementRef) + 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 @@ -848,6 +867,11 @@ func (in *ResourceOverrideSnapshotSpec) DeepCopy() *ResourceOverrideSnapshotSpec // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceOverrideSpec) DeepCopyInto(out *ResourceOverrideSpec) { *out = *in + if in.Placement != nil { + in, out := &in.Placement, &out.Placement + *out = new(PlacementRef) + **out = **in + } if in.ResourceSelectors != nil { in, out := &in.ResourceSelectors, &out.ResourceSelectors *out = make([]ResourceSelector, len(*in)) diff --git a/apis/placement/v1beta1/zz_generated.deepcopy.go b/apis/placement/v1beta1/zz_generated.deepcopy.go index 497454532..803ac0287 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 ( - v1 "k8s.io/apimachinery/pkg/apis/meta/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 ac4844274..0d4061551 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" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) diff --git a/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverrides.yaml b/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverrides.yaml index c047bcfee..3aa2b04c4 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverrides.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverrides.yaml @@ -129,6 +129,19 @@ spec: maxItems: 20 minItems: 1 type: array + placement: + description: |- + Placement defines whether the override is applied to a specific placement or not. + If set, the override will trigger the placement rollout immediately when the rollout strategy type is RollingUpdate. + Otherwise, it will be applied to the next rollout. + The recommended way is to set the placement so that the override can be rolled out immediately. + properties: + name: + description: Name is the reference to the name of placement. + type: string + required: + - name + type: object policy: description: Policy defines how to override the selected resources on the target clusters. diff --git a/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverridesnapshots.yaml b/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverridesnapshots.yaml index 4c9fa8682..d89c326a0 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverridesnapshots.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_clusterresourceoverridesnapshots.yaml @@ -143,6 +143,19 @@ spec: maxItems: 20 minItems: 1 type: array + placement: + description: |- + Placement defines whether the override is applied to a specific placement or not. + If set, the override will trigger the placement rollout immediately when the rollout strategy type is RollingUpdate. + Otherwise, it will be applied to the next rollout. + The recommended way is to set the placement so that the override can be rolled out immediately. + properties: + name: + description: Name is the reference to the name of placement. + type: string + required: + - name + type: object policy: description: Policy defines how to override the selected resources on the target clusters. diff --git a/config/crd/bases/placement.kubernetes-fleet.io_resourceoverrides.yaml b/config/crd/bases/placement.kubernetes-fleet.io_resourceoverrides.yaml index a61b71d69..6f1a80678 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_resourceoverrides.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_resourceoverrides.yaml @@ -44,6 +44,19 @@ spec: spec: description: The desired state of ResourceOverrideSpec. properties: + placement: + description: |- + Placement defines whether the override is applied to a specific placement or not. + If set, the override will trigger the placement rollout immediately when the rollout strategy type is RollingUpdate. + Otherwise, it will be applied to the next rollout. + The recommended way is to set the placement so that the override can be rolled out immediately. + properties: + name: + description: Name is the reference to the name of placement. + type: string + required: + - name + type: object policy: description: Policy defines how to override the selected resources on the target clusters. diff --git a/config/crd/bases/placement.kubernetes-fleet.io_resourceoverridesnapshots.yaml b/config/crd/bases/placement.kubernetes-fleet.io_resourceoverridesnapshots.yaml index 33cbe2b12..d502dd686 100644 --- a/config/crd/bases/placement.kubernetes-fleet.io_resourceoverridesnapshots.yaml +++ b/config/crd/bases/placement.kubernetes-fleet.io_resourceoverridesnapshots.yaml @@ -58,6 +58,19 @@ spec: overrideSpec: description: OverrideSpec stores the spec of ResourceOverride. properties: + placement: + description: |- + Placement defines whether the override is applied to a specific placement or not. + If set, the override will trigger the placement rollout immediately when the rollout strategy type is RollingUpdate. + Otherwise, it will be applied to the next rollout. + The recommended way is to set the placement so that the override can be rolled out immediately. + properties: + name: + description: Name is the reference to the name of placement. + type: string + required: + - name + type: object policy: description: Policy defines how to override the selected resources on the target clusters. diff --git a/test/apis/v1alpha1/zz_generated.deepcopy.go b/test/apis/v1alpha1/zz_generated.deepcopy.go index ef7e4433a..0b5d2e30b 100644 --- a/test/apis/v1alpha1/zz_generated.deepcopy.go +++ b/test/apis/v1alpha1/zz_generated.deepcopy.go @@ -10,7 +10,7 @@ Licensed under the MIT license. package v1alpha1 import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" )