@@ -24,42 +24,121 @@ import (
2424const (
2525 ClusterExtensionRevisionKind = "ClusterExtensionRevision"
2626
27- // Condition Types
27+ // ClusterExtensionRevisionTypeAvailable is the condition type that represents whether the
28+ // ClusterExtensionRevision is available and has been successfully rolled out.
2829 ClusterExtensionRevisionTypeAvailable = "Available"
30+
31+ // ClusterExtensionRevisionTypeSucceeded is the condition type that represents whether the
32+ // ClusterExtensionRevision rollout has succeeded at least once.
2933 ClusterExtensionRevisionTypeSucceeded = "Succeeded"
3034
31- // Condition Reasons
32- ClusterExtensionRevisionReasonAvailable = "Available"
33- ClusterExtensionRevisionReasonReconcileFailure = "ReconcileFailure"
35+ // ClusterExtensionRevisionReasonAvailable is set when the revision is available
36+ // and passes all probes after a successful rollout.
37+ // Condition: Available, Status: True
38+ ClusterExtensionRevisionReasonAvailable = "Available"
39+
40+ // ClusterExtensionRevisionReasonReconcileFailure is set when the ClusterExtensionRevision
41+ // encounters a general reconciliation failure, such as errors ensuring finalizers or
42+ // establishing watches.
43+ // Condition: Available, Status: False
44+ ClusterExtensionRevisionReasonReconcileFailure = "ReconcileFailure"
45+
46+ // ClusterExtensionRevisionReasonRevisionValidationFailure is set when the revision
47+ // fails preflight validation checks at the revision level.
48+ // Condition: Available, Status: False
3449 ClusterExtensionRevisionReasonRevisionValidationFailure = "RevisionValidationFailure"
35- ClusterExtensionRevisionReasonPhaseValidationError = "PhaseValidationError"
36- ClusterExtensionRevisionReasonObjectCollisions = "ObjectCollisions"
37- ClusterExtensionRevisionReasonRolloutSuccess = "RolloutSuccess"
38- ClusterExtensionRevisionReasonProbeFailure = "ProbeFailure"
39- ClusterExtensionRevisionReasonIncomplete = "Incomplete"
40- ClusterExtensionRevisionReasonProgressing = "Progressing"
41- ClusterExtensionRevisionReasonArchived = "Archived"
42- ClusterExtensionRevisionReasonMigrated = "Migrated"
50+
51+ // ClusterExtensionRevisionReasonPhaseValidationError is set when a phase within
52+ // the revision fails preflight validation checks.
53+ // Condition: Available, Status: False
54+ ClusterExtensionRevisionReasonPhaseValidationError = "PhaseValidationError"
55+
56+ // ClusterExtensionRevisionReasonObjectCollisions is set when objects in the revision
57+ // collide with existing objects on the cluster that cannot be adopted based on
58+ // the configured collision protection policy.
59+ // Condition: Available, Status: False
60+ ClusterExtensionRevisionReasonObjectCollisions = "ObjectCollisions"
61+
62+ // ClusterExtensionRevisionReasonRolloutSuccess is set when the revision has
63+ // successfully completed its rollout for the first time.
64+ // Condition: Succeeded, Status: True
65+ ClusterExtensionRevisionReasonRolloutSuccess = "RolloutSuccess"
66+
67+ // ClusterExtensionRevisionReasonProbeFailure is set when one or more objects
68+ // in the revision fail their readiness probes during rollout.
69+ // Condition: Available, Status: False
70+ ClusterExtensionRevisionReasonProbeFailure = "ProbeFailure"
71+
72+ // ClusterExtensionRevisionReasonIncomplete is set when the revision rollout
73+ // has not completed but no specific probe failures have been detected.
74+ // Condition: Available, Status: False
75+ ClusterExtensionRevisionReasonIncomplete = "Incomplete"
76+
77+ // ClusterExtensionRevisionReasonProgressing is set when the revision rollout
78+ // is actively making progress and is in transition.
79+ // Condition: Progressing, Status: True
80+ ClusterExtensionRevisionReasonProgressing = "Progressing"
81+
82+ // ClusterExtensionRevisionReasonArchived is set when the revision has been
83+ // archived and its objects have been torn down.
84+ // Condition: Available, Status: Unknown
85+ ClusterExtensionRevisionReasonArchived = "Archived"
86+
87+ // ClusterExtensionRevisionReasonMigrated is set when the revision was
88+ // migrated from an existing Helm release to a ClusterExtensionRevision.
89+ // Condition: Available, Status: Unknown
90+ ClusterExtensionRevisionReasonMigrated = "Migrated"
4391)
4492
4593// ClusterExtensionRevisionSpec defines the desired state of ClusterExtensionRevision.
94+ //
95+ // A ClusterExtensionRevision represents a specific immutable snapshot of the objects
96+ // to be installed for a ClusterExtension. Each revision is rolled out in phases,
97+ // with objects organized by their Group-Kind into well-known phases such as namespaces,
98+ // rbac, crds, and deploy.
4699type ClusterExtensionRevisionSpec struct {
47- // Specifies the lifecycle state of the ClusterExtensionRevision.
100+ // The lifecycleState field specifies the lifecycle state of the ClusterExtensionRevision.
101+ //
102+ // When set to "Active" (the default), the revision is actively managed and reconciled.
103+ // When set to "Paused", reconciliation is disabled but status updates continue.
104+ // When set to "Archived", the revision is torn down and scaled to zero.
105+ // The revision is removed from the owner list of all objects previously under management.
106+ // All objects that did not transition to a succeeding revision are deleted.
107+ //
108+ // Once a revision is set to "Archived", it cannot be un-archived.
48109 //
49110 // +kubebuilder:default="Active"
50111 // +kubebuilder:validation:Enum=Active;Paused;Archived
51112 // +kubebuilder:validation:XValidation:rule="oldSelf == 'Active' || oldSelf == 'Paused' || oldSelf == 'Archived' && oldSelf == self", message="can not un-archive"
52113 LifecycleState ClusterExtensionRevisionLifecycleState `json:"lifecycleState,omitempty"`
53- // Revision is a sequence number representing a specific revision of the ClusterExtension instance.
54- // Must be positive. Each ClusterExtensionRevision of the same parent ClusterExtension needs to have
55- // a unique value assigned. It is immutable after creation. The new revision number must always be previous revision +1.
114+
115+ // The revision field is a required, immutable sequence number representing a specific revision
116+ // of the parent ClusterExtension.
117+ //
118+ // The revision field must be a positive integer.
119+ // Each ClusterExtensionRevision belonging to the same parent ClusterExtension must have a unique revision number.
120+ // The revision number must always be the previous revision number plus one, or 1 for the first revision.
56121 //
57122 // +kubebuilder:validation:Required
58123 // +kubebuilder:validation:Minimum:=1
59124 // +kubebuilder:validation:XValidation:rule="self == oldSelf", message="revision is immutable"
60125 Revision int64 `json:"revision"`
61- // Phases are groups of objects that will be applied at the same time.
62- // All objects in the phase will have to pass their probes in order to progress to the next phase.
126+
127+ // The phases field is an optional, immutable list of phases that group objects to be applied together.
128+ //
129+ // Objects are organized into phases based on their Group-Kind. Common phases include:
130+ // - namespaces: Namespace objects
131+ // - policies: ResourceQuota, LimitRange, NetworkPolicy objects
132+ // - rbac: ServiceAccount, Role, RoleBinding, ClusterRole, ClusterRoleBinding objects
133+ // - crds: CustomResourceDefinition objects
134+ // - storage: PersistentVolume, PersistentVolumeClaim, StorageClass objects
135+ // - deploy: Deployment, StatefulSet, DaemonSet, Service, ConfigMap, Secret objects
136+ // - publish: Ingress, APIService, Route, Webhook objects
137+ //
138+ // All objects in a phase are applied simultaneously.
139+ // The revision progresses to the next phase only after all objects in the current phase pass their readiness probes.
140+ //
141+ // Once set (even if empty), the phases field is immutable.
63142 //
64143 // +kubebuilder:validation:XValidation:rule="self == oldSelf || oldSelf.size() == 0", message="phases is immutable"
65144 // +listType=map
@@ -75,33 +154,68 @@ const (
75154 // ClusterExtensionRevisionLifecycleStateActive / "Active" is the default lifecycle state.
76155 ClusterExtensionRevisionLifecycleStateActive ClusterExtensionRevisionLifecycleState = "Active"
77156 // ClusterExtensionRevisionLifecycleStatePaused / "Paused" disables reconciliation of the ClusterExtensionRevision.
78- // Only Status updates will still propagated, but object changes will not be reconciled .
157+ // Object changes will not be reconciled. However, status updates will be propagated .
79158 ClusterExtensionRevisionLifecycleStatePaused ClusterExtensionRevisionLifecycleState = "Paused"
80- // ClusterExtensionRevisionLifecycleStateArchived / "Archived" disables reconciliation while also "scaling to zero",
81- // which deletes all objects that are not excluded via the pausedFor property and
82- // removes itself from the owner list of all other objects previously under management .
159+ // ClusterExtensionRevisionLifecycleStateArchived / "Archived" archives the revision for historical or auditing purposes.
160+ // The revision is removed from the owner list of all other objects previously under management and all objects
161+ // that did not transition to a succeeding revision are deleted .
83162 ClusterExtensionRevisionLifecycleStateArchived ClusterExtensionRevisionLifecycleState = "Archived"
84163)
85164
86- // ClusterExtensionRevisionPhase are groups of objects that will be applied at the same time.
87- // All objects in the a phase will have to pass their probes in order to progress to the next phase.
165+ // ClusterExtensionRevisionPhase represents a group of objects that are applied together.
166+ //
167+ // Objects in a phase are applied simultaneously.
168+ // All objects must pass their readiness probes before the revision progresses to the next phase.
169+ // Phases are applied in a defined order based on the types of objects they contain.
88170type ClusterExtensionRevisionPhase struct {
89- // Name identifies this phase.
171+ // The name field is a required identifier for this phase.
172+ //
173+ // Phase names must follow the DNS label standard as defined in [RFC 1123].
174+ // They must contain only lowercase alphanumeric characters or hyphens (-),
175+ // start and end with an alphanumeric character, and be no longer than 63 characters.
176+ //
177+ // Common phase names include: namespaces, policies, rbac, crds, storage, deploy, publish.
178+ //
179+ // [RFC 1123]: https://tools.ietf.org/html/rfc1123
90180 //
91181 // +kubebuilder:validation:MaxLength=63
92182 // +kubebuilder:validation:Pattern=`^[a-z]([-a-z0-9]*[a-z0-9])?$`
93183 Name string `json:"name"`
94- // Objects are a list of all the objects within this phase.
184+
185+ // The objects field is a required list of all Kubernetes objects in this phase.
186+ //
187+ // All objects in this list are applied to the cluster simultaneously.
188+ // The phase is considered complete only after all objects pass their readiness probes.
95189 Objects []ClusterExtensionRevisionObject `json:"objects"`
96190}
97191
98- // ClusterExtensionRevisionObject contains an object and settings for it.
192+ // ClusterExtensionRevisionObject represents a Kubernetes object to be applied as part
193+ // of a ClusterExtensionRevision, along with its collision protection settings.
99194type ClusterExtensionRevisionObject struct {
195+ // The object field is a required embedded Kubernetes object to be applied.
196+ //
197+ // This object must be a valid Kubernetes resource with apiVersion, kind, and metadata fields.
198+ // Status fields are not permitted and are removed if present.
199+ // Only specific metadata fields are preserved: name, namespace, labels, and annotations.
200+ //
100201 // +kubebuilder:validation:EmbeddedResource
101202 // +kubebuilder:pruning:PreserveUnknownFields
102203 Object unstructured.Unstructured `json:"object"`
103- // CollisionProtection controls whether OLM can adopt and modify objects
104- // already existing on the cluster or even owned by another controller.
204+
205+ // The collisionProtection field controls whether the operator can adopt and modify objects
206+ // that already exist on the cluster.
207+ //
208+ // When set to "Prevent" (the default), the operator only manages objects it created itself.
209+ // This prevents ownership collisions.
210+ //
211+ // When set to "IfNoController", the operator can adopt and modify pre-existing objects
212+ // that are not owned by another controller.
213+ // This is useful for taking over management of manually-created resources.
214+ //
215+ // When set to "None", the operator can adopt and modify any pre-existing object, even if
216+ // owned by another controller.
217+ // Use this setting with extreme caution as it may cause multiple controllers to fight over
218+ // the same resource, resulting in increased load on the API server and etcd.
105219 //
106220 // +kubebuilder:default="Prevent"
107221 // +kubebuilder:validation:Enum=Prevent;IfNoController;None
@@ -128,6 +242,27 @@ const (
128242
129243// ClusterExtensionRevisionStatus defines the observed state of a ClusterExtensionRevision.
130244type ClusterExtensionRevisionStatus struct {
245+ // conditions is an optional list of status conditions describing the state of the
246+ // ClusterExtensionRevision.
247+ //
248+ // The Progressing condition represents whether the revision is actively rolling out:
249+ // - When status is True and reason is Progressing, the revision rollout is actively making progress and is in transition.
250+ // - When Progressing is not present, the revision is not currently in transition.
251+ //
252+ // The Available condition represents whether the revision has been successfully rolled out and is available:
253+ // - When status is True and reason is Available, the revision has been successfully rolled out and all objects pass their readiness probes.
254+ // - When status is False and reason is Incomplete, the revision rollout has not yet completed but no specific failures have been detected.
255+ // - When status is False and reason is ProbeFailure, one or more objects are failing their readiness probes during rollout.
256+ // - When status is False and reason is ReconcileFailure, the revision has encountered a general reconciliation failure.
257+ // - When status is False and reason is RevisionValidationFailure, the revision failed preflight validation checks.
258+ // - When status is False and reason is PhaseValidationError, a phase within the revision failed preflight validation checks.
259+ // - When status is False and reason is ObjectCollisions, objects in the revision collide with existing cluster objects that cannot be adopted.
260+ // - When status is Unknown and reason is Archived, the revision has been archived and its objects have been torn down.
261+ // - When status is Unknown and reason is Migrated, the revision was migrated from an existing release and object status probe results have not yet been observed.
262+ //
263+ // The Succeeded condition represents whether the revision has successfully completed its rollout at least once:
264+ // - When status is True and reason is RolloutSuccess, the revision has successfully completed its rollout. This condition is set once and persists even if the revision later becomes unavailable.
265+ //
131266 // +listType=map
132267 // +listMapKey=type
133268 // +optional
@@ -137,19 +272,38 @@ type ClusterExtensionRevisionStatus struct {
137272// +kubebuilder:object:root=true
138273// +kubebuilder:resource:scope=Cluster
139274// +kubebuilder:subresource:status
140-
141- // ClusterExtensionRevision is the Schema for the clusterextensionrevisions API
142275// +kubebuilder:printcolumn:name="Available",type=string,JSONPath=`.status.conditions[?(@.type=='Available')].status`
143276// +kubebuilder:printcolumn:name=Age,type=date,JSONPath=`.metadata.creationTimestamp`
277+
278+ // ClusterExtensionRevision is the schema for the ClusterExtensionRevisions API.
279+ //
280+ // A ClusterExtensionRevision represents an immutable snapshot of Kubernetes objects
281+ // for a specific version of a ClusterExtension. Each revision contains objects
282+ // organized into phases that roll out sequentially.
283+ //
284+ // The ClusterExtension controller creates and manages ClusterExtensionRevisions automatically.
285+ // Do not create them directly. Each ClusterExtension can have multiple revisions as it
286+ // upgrades or reconfigures.
287+ //
288+ // The revision rollout uses a phased approach where objects apply in a defined order based
289+ // on type (for example: namespaces, then RBAC, then CRDs, then deployments). All objects
290+ // in a phase apply simultaneously and must pass readiness probes before rollout continues
291+ // to the next phase.
292+ //
293+ // Revisions have three lifecycle states:
294+ // - Active: The revision is actively managed and reconciled (default)
295+ // - Paused: Reconciliation is disabled but status updates continue
296+ // - Archived: The revision is torn down, objects are deleted, and the revision removes
297+ // itself from the owner list of managed objects
144298type ClusterExtensionRevision struct {
145299 metav1.TypeMeta `json:",inline"`
146300 metav1.ObjectMeta `json:"metadata,omitempty"`
147301
148- // spec is an optional field that defines the desired state of the ClusterExtension .
302+ // The spec field is optional and defines the desired state of the ClusterExtensionRevision .
149303 // +optional
150304 Spec ClusterExtensionRevisionSpec `json:"spec,omitempty"`
151305
152- // status is an optional field that defines the observed state of the ClusterExtension .
306+ // The status field is optional and defines the observed state of the ClusterExtensionRevision .
153307 // +optional
154308 Status ClusterExtensionRevisionStatus `json:"status,omitempty"`
155309}
0 commit comments