Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion apis/cluster/v1beta1/zz_generated.deepcopy.go

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

39 changes: 31 additions & 8 deletions apis/placement/v1beta1/clusterresourceplacement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@ type ApplyStrategy struct {
// differences. No actual apply ops would be executed, and resources will be left alone as they
// are on the member clusters.
//
// If configuration differences are found on a resource, Fleet will consider this as an apply
// error, which might block rollout depending on the specified rollout strategy.
//
// Use ComparisonOption setting to control how the difference is calculated.
//
// For a comparison between the different strategies and usage examples, refer to the
Expand All @@ -545,10 +548,14 @@ type ApplyStrategy struct {
// +kubebuilder:validation:Optional
Type ApplyStrategyType `json:"type,omitempty"`

// AllowCoOwnership defines whether to apply the resource if it already exists in the target cluster and is not
// solely owned by fleet (i.e., metadata.ownerReferences contains only fleet custom resources).
// If true, apply the resource and add fleet as a co-owner.
// If false, leave the resource unchanged and fail the apply.
// AllowCoOwnership controls whether co-ownership between Fleet and other agents are allowed
// on a Fleet-managed resource. If set to false, Fleet will refuse to apply manifests to
// a resource that has been owned by one or more non-Fleet agents.
//
// Note that Fleet does not support the case where one resource is being placed multiple
// times by different CRPs on the same member cluster. An apply error will be returned if
// Fleet finds that a resource has been owned by another placement attempt by Fleet, even
// with the AllowCoOwnership setting set to true.
AllowCoOwnership bool `json:"allowCoOwnership,omitempty"`

// ServerSideApplyConfig defines the configuration for server side apply. It is honored only when type is ServerSideApply.
Expand All @@ -571,8 +578,9 @@ type ApplyStrategy struct {
//
// * IfNoDiff: with this action, Fleet will apply the hub cluster manifests to the member
// clusters if (and only if) pre-existing resources look the same as the hub cluster manifests.
//
// This is a safer option as pre-existing resources that are inconsistent with the hub cluster
// manifests will not be overwritten; in fact, Fleet will ignore them until the inconsistencies
// manifests will not be overwritten; Fleet will ignore them until the inconsistencies
// are resolved properly: any change you make to the hub cluster manifests would not be
// applied, and if you delete the manifests or even the ClusterResourcePlacement itself
// from the hub cluster, these pre-existing resources would not be taken away.
Expand All @@ -597,6 +605,14 @@ type ApplyStrategy struct {
// If appropriate, you may also delete the object from the member cluster; Fleet will recreate
// it using the hub cluster manifest.
//
// * Never: with this action, Fleet will not apply the hub cluster manifests to the member
// clusters if there are corresponding pre-existing resources.
//
// This is the safest option; one will have to remove the pre-existing resources (so that
// Fleet can re-create them) or switch to a different
// WhenToTakeOver option before Fleet starts processing the corresponding hub cluster
// manifests.
//
// +kubebuilder:default=Always
// +kubebuilder:validation:Enum=Always;IfNoDiff
// +kubebuilder:validation:Optional
Expand Down Expand Up @@ -681,9 +697,13 @@ const (
// resources on the member cluster. Otherwise, we will report the difference.
WhenToTakeOverTypeIfNoDiff WhenToTakeOverType = "IfNoDiff"

// WhenToTakeOverTypeAlways will always apply the resource to the member cluster regardless
// WhenToTakeOverTypeAlways will always apply manifests to the member cluster regardless
// if there are differences between the resource on the hub cluster and the existing resources on the member cluster.
WhenToTakeOverTypeAlways WhenToTakeOverType = "Always"

// WhenToTakeOverTypeNever instructs Fleet to never apply manifests to a member cluster
// if there are corresponding pre-existing resources.
WhenToTakeOverTypeNever WhenToTakeOverType = "Never"
)

// +enum
Expand Down Expand Up @@ -978,8 +998,11 @@ type DiffedResourcePlacement struct {

// TargetClusterObservedGeneration is the generation of the resource on the target cluster
// that contains the configuration differences.
// +kubebuilder:validation:Required
TargetClusterObservedGeneration int64 `json:"targetClusterObservedGeneration"`
//
// This might be nil if the resource has not been created yet on the target cluster.
//
// +kubebuilder:validation:Optional
TargetClusterObservedGeneration *int64 `json:"targetClusterObservedGeneration"`

// FirstDiffedObservedTime is the first time the resource on the target cluster is
// observed to have configuration differences.
Expand Down
13 changes: 7 additions & 6 deletions apis/placement/v1beta1/work_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ type WorkResourceIdentifier struct {
// Kind is the kind of the resource.
Kind string `json:"kind,omitempty"`

// Resource is the resource type of the resource
// Resource is the resource type of the resource.
Resource string `json:"resource,omitempty"`

// Namespace is the namespace of the resource, the resource is cluster scoped if the value
// is empty
// is empty.
Namespace string `json:"namespace,omitempty"`

// Name is the name of the resource
// Name is the name of the resource.
Name string `json:"name,omitempty"`
}

Expand All @@ -124,7 +124,6 @@ type DriftDetails struct {

// ObservedInMemberClusterGeneration is the generation of the applied manifest on the member
// cluster side.
//
// +kubebuilder:validation:Required
ObservedInMemberClusterGeneration int64 `json:"observedInMemberClusterGeneration"`

Expand Down Expand Up @@ -157,8 +156,10 @@ type DiffDetails struct {
// ObservedInMemberClusterGeneration is the generation of the applied manifest on the member
// cluster side.
//
// +kubebuilder:validation:Required
ObservedInMemberClusterGeneration int64 `json:"observedInMemberClusterGeneration"`
// This might be nil if the resource has not been created yet in the member cluster.
//
// +kubebuilder:validation:Optional
ObservedInMemberClusterGeneration *int64 `json:"observedInMemberClusterGeneration"`

// FirsftDiffedObservedTime is the timestamp when the configuration difference
// was first detected.
Expand Down
12 changes: 11 additions & 1 deletion apis/placement/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion apis/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,20 @@ spec:
description: Kind is the kind of the resource.
type: string
name:
description: Name is the name of the resource
description: Name is the name of the resource.
type: string
namespace:
description: |-
Namespace is the namespace of the resource, the resource is cluster scoped if the value
is empty
is empty.
type: string
ordinal:
description: |-
Ordinal represents an index in manifests list, so the condition can still be linked
to a manifest even though manifest cannot be parsed successfully.
type: integer
resource:
description: Resource is the resource type of the resource
description: Resource is the resource type of the resource.
type: string
uid:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,15 @@ spec:
properties:
allowCoOwnership:
description: |-
AllowCoOwnership defines whether to apply the resource if it already exists in the target cluster and is not
solely owned by fleet (i.e., metadata.ownerReferences contains only fleet custom resources).
If true, apply the resource and add fleet as a co-owner.
If false, leave the resource unchanged and fail the apply.
AllowCoOwnership controls whether co-ownership between Fleet and other agents are allowed
on a Fleet-managed resource. If set to false, Fleet will refuse to apply manifests to
a resource that has been owned by one or more non-Fleet agents.


Note that Fleet does not support the case where one resource is being placed multiple
times by different CRPs on the same member cluster. An apply error will be returned if
Fleet finds that a resource has been owned by another placement attempt by Fleet, even
with the AllowCoOwnership setting set to true.
type: boolean
comparisonOption:
default: PartialComparison
Expand Down Expand Up @@ -533,6 +538,10 @@ spec:
are on the member clusters.


If configuration differences are found on a resource, Fleet will consider this as an apply
error, which might block rollout depending on the specified rollout strategy.


Use ComparisonOption setting to control how the difference is calculated.


Expand Down Expand Up @@ -618,8 +627,10 @@ spec:

* IfNoDiff: with this action, Fleet will apply the hub cluster manifests to the member
clusters if (and only if) pre-existing resources look the same as the hub cluster manifests.


This is a safer option as pre-existing resources that are inconsistent with the hub cluster
manifests will not be overwritten; in fact, Fleet will ignore them until the inconsistencies
manifests will not be overwritten; Fleet will ignore them until the inconsistencies
are resolved properly: any change you make to the hub cluster manifests would not be
applied, and if you delete the manifests or even the ClusterResourcePlacement itself
from the hub cluster, these pre-existing resources would not be taken away.
Expand Down Expand Up @@ -647,6 +658,16 @@ spec:

If appropriate, you may also delete the object from the member cluster; Fleet will recreate
it using the hub cluster manifest.


* Never: with this action, Fleet will not apply the hub cluster manifests to the member
clusters if there are corresponding pre-existing resources.


This is the safest option; one will have to remove the pre-existing resources (so that
Fleet can re-create them) or switch to a different
WhenToTakeOver option before Fleet starts processing the corresponding hub cluster
manifests.
enum:
- Always
- IfNoDiff
Expand Down Expand Up @@ -933,6 +954,9 @@ spec:
description: |-
TargetClusterObservedGeneration is the generation of the resource on the target cluster
that contains the configuration differences.


This might be nil if the resource has not been created yet on the target cluster.
format: int64
type: integer
version:
Expand All @@ -943,7 +967,6 @@ spec:
- kind
- name
- observationTime
- targetClusterObservedGeneration
- version
type: object
maxItems: 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1758,10 +1758,15 @@ spec:
properties:
allowCoOwnership:
description: |-
AllowCoOwnership defines whether to apply the resource if it already exists in the target cluster and is not
solely owned by fleet (i.e., metadata.ownerReferences contains only fleet custom resources).
If true, apply the resource and add fleet as a co-owner.
If false, leave the resource unchanged and fail the apply.
AllowCoOwnership controls whether co-ownership between Fleet and other agents are allowed
on a Fleet-managed resource. If set to false, Fleet will refuse to apply manifests to
a resource that has been owned by one or more non-Fleet agents.


Note that Fleet does not support the case where one resource is being placed multiple
times by different CRPs on the same member cluster. An apply error will be returned if
Fleet finds that a resource has been owned by another placement attempt by Fleet, even
with the AllowCoOwnership setting set to true.
type: boolean
comparisonOption:
default: PartialComparison
Expand Down Expand Up @@ -1861,6 +1866,10 @@ spec:
are on the member clusters.


If configuration differences are found on a resource, Fleet will consider this as an apply
error, which might block rollout depending on the specified rollout strategy.


Use ComparisonOption setting to control how the difference is calculated.


Expand Down Expand Up @@ -1946,8 +1955,10 @@ spec:

* IfNoDiff: with this action, Fleet will apply the hub cluster manifests to the member
clusters if (and only if) pre-existing resources look the same as the hub cluster manifests.


This is a safer option as pre-existing resources that are inconsistent with the hub cluster
manifests will not be overwritten; in fact, Fleet will ignore them until the inconsistencies
manifests will not be overwritten; Fleet will ignore them until the inconsistencies
are resolved properly: any change you make to the hub cluster manifests would not be
applied, and if you delete the manifests or even the ClusterResourcePlacement itself
from the hub cluster, these pre-existing resources would not be taken away.
Expand Down Expand Up @@ -1975,6 +1986,16 @@ spec:

If appropriate, you may also delete the object from the member cluster; Fleet will recreate
it using the hub cluster manifest.


* Never: with this action, Fleet will not apply the hub cluster manifests to the member
clusters if there are corresponding pre-existing resources.


This is the safest option; one will have to remove the pre-existing resources (so that
Fleet can re-create them) or switch to a different
WhenToTakeOver option before Fleet starts processing the corresponding hub cluster
manifests.
enum:
- Always
- IfNoDiff
Expand Down Expand Up @@ -2371,6 +2392,9 @@ spec:
description: |-
TargetClusterObservedGeneration is the generation of the resource on the target cluster
that contains the configuration differences.


This might be nil if the resource has not been created yet on the target cluster.
format: int64
type: integer
version:
Expand All @@ -2381,7 +2405,6 @@ spec:
- kind
- name
- observationTime
- targetClusterObservedGeneration
- version
type: object
maxItems: 100
Expand Down
Loading
Loading