@@ -61,12 +61,53 @@ type ClusterExtensionSpec struct {
6161 //
6262 Source SourceConfig `json:"source"`
6363
64- // installNamespace is a reference to the Namespace in which the bundle of
64+ // install is a required field used to configure the installation options
65+ // for the ClusterExtension such as the installation namespace,
66+ // the service account and the pre-flight check configuration.
67+ //
68+ // Below is a minimal example of an installation definition (in yaml):
69+ // install:
70+ // namespace: example-namespace
71+ // serviceAccount:
72+ // name: example-sa
73+ Install ClusterExtensionInstallConfig `json:"install"`
74+ }
75+
76+ const SourceTypeCatalog = "Catalog"
77+
78+ // SourceConfig is a discriminated union which selects the installation source.
79+ // +union
80+ // +kubebuilder:validation:XValidation:rule="self.sourceType == 'Catalog' && has(self.catalog)",message="sourceType Catalog requires catalog field"
81+ type SourceConfig struct {
82+ // sourceType is a required reference to the type of install source.
83+ //
84+ // Allowed values are ["Catalog"]
85+ //
86+ // When this field is set to "Catalog", information for determining the appropriate
87+ // bundle of content to install will be fetched from ClusterCatalog resources existing
88+ // on the cluster. When using the Catalog sourceType, the catalog field must also be set.
89+ //
90+ // +unionDiscriminator
91+ // +kubebuilder:validation:Enum:="Catalog"
92+ SourceType string `json:"sourceType"`
93+
94+ // catalog is used to configure how information is sourced from a catalog. This field must be defined when sourceType is set to "Catalog",
95+ // and must be the only field defined for this sourceType.
96+ //
97+ // +optional.
98+ Catalog * CatalogSource `json:"catalog,omitempty"`
99+ }
100+
101+ // ClusterExtensionInstallConfig is a union which selects the clusterExtension installation config.
102+ // ClusterExtensionInstallConfig requires the namespace and serviceAccount which should be used for the installation of packages.
103+ // +union
104+ type ClusterExtensionInstallConfig struct {
105+ // namespace is a reference to the Namespace in which the bundle of
65106 // content for the package referenced in the packageName field will be applied.
66107 // The bundle may contain cluster-scoped resources or resources that are
67108 // applied to other Namespaces. This Namespace is expected to exist.
68109 //
69- // installNamespace is required, immutable, and follows the DNS label standard
110+ // namespace is required, immutable, and follows the DNS label standard
70111 // as defined in [RFC 1123]. This means that valid values:
71112 // - Contain no more than 63 characters
72113 // - Contain only lowercase alphanumeric characters or '-'
@@ -89,17 +130,8 @@ type ClusterExtensionSpec struct {
89130 //
90131 //+kubebuilder:validation:Pattern:=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
91132 //+kubebuilder:validation:MaxLength:=63
92- //+kubebuilder:validation:XValidation:rule="self == oldSelf",message="installNamespace is immutable"
93- InstallNamespace string `json:"installNamespace"`
94-
95- // preflight is an optional field that can be used to configure the preflight checks run before installation or upgrade of the content for the package specified in the packageName field.
96- //
97- // When specified, it overrides the default configuration of the preflight checks that are required to execute successfully during an install/upgrade operation.
98- //
99- // When not specified, the default configuration for each preflight check will be used.
100- //
101- //+optional
102- Preflight * PreflightConfig `json:"preflight,omitempty"`
133+ //+kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable"
134+ Namespace string `json:"namespace"`
103135
104136 // serviceAccount is a required reference to a ServiceAccount that exists
105137 // in the installNamespace. The provided ServiceAccount is used to install and
@@ -110,31 +142,15 @@ type ClusterExtensionSpec struct {
110142 // appropriate permissions to perform the necessary operations on all the
111143 // resources that are included in the bundle of content being applied.
112144 ServiceAccount ServiceAccountReference `json:"serviceAccount"`
113- }
114-
115- const SourceTypeCatalog = "Catalog"
116145
117- // SourceConfig is a discriminated union which selects the installation source.
118- // +union
119- // +kubebuilder:validation:XValidation:rule="self.sourceType == 'Catalog' && has(self.catalog)",message="sourceType Catalog requires catalog field"
120- type SourceConfig struct {
121- // sourceType is a required reference to the type of install source.
122- //
123- // Allowed values are ["Catalog"]
146+ // preflight is an optional field that can be used to configure the preflight checks run before installation or upgrade of the content for the package specified in the packageName field.
124147 //
125- // When this field is set to "Catalog", information for determining the appropriate
126- // bundle of content to install will be fetched from ClusterCatalog resources existing
127- // on the cluster. When using the Catalog sourceType, the catalog field must also be set.
148+ // When specified, it overrides the default configuration of the preflight checks that are required to execute successfully during an install/upgrade operation.
128149 //
129- // +unionDiscriminator
130- // +kubebuilder:validation:Enum:="Catalog"
131- SourceType string `json:"sourceType"`
132-
133- // catalog is used to configure how information is sourced from a catalog. This field must be defined when sourceType is set to "Catalog",
134- // and must be the only field defined for this sourceType.
150+ // When not specified, the default configuration for each preflight check will be used.
135151 //
136- // +optional.
137- Catalog * CatalogSource `json:"catalog ,omitempty"`
152+ //+optional
153+ Preflight * PreflightConfig `json:"preflight ,omitempty"`
138154}
139155
140156// CatalogSource defines the required fields for catalog source.
@@ -463,24 +479,9 @@ type BundleMetadata struct {
463479
464480// ClusterExtensionStatus defines the observed state of ClusterExtension.
465481type ClusterExtensionStatus struct {
466- // installedBundle is a representation of the currently installed bundle.
467- //
468- // A "bundle" is a versioned set of content that represents the resources that
469- // need to be applied to a cluster to install a package.
470- //
471- // This field is only updated once a bundle has been successfully installed and
472- // once set will only be updated when a new version of the bundle has
473- // successfully replaced the currently installed version.
474- //
475- //+optional
476- InstalledBundle * BundleMetadata `json:"installedBundle,omitempty"`
482+ Install * ClusterExtensionInstallStatus `json:"install,omitempty"`
477483
478- // resolvedBundle is a representation of the bundle that was identified during
479- // resolution to meet all installation/upgrade constraints and is slated to be
480- // installed or upgraded to.
481- //
482- //+optional
483- ResolvedBundle * BundleMetadata `json:"resolvedBundle,omitempty"`
484+ Resolution * ClusterExtensionResolutionStatus `json:"resolution,omitempty"`
484485
485486 // conditions is a representation of the current state for this ClusterExtension.
486487 // The status is represented by a set of "conditions".
@@ -514,6 +515,29 @@ type ClusterExtensionStatus struct {
514515 Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
515516}
516517
518+ type ClusterExtensionInstallStatus struct {
519+ // bundle is a representation of the currently installed bundle.
520+ //
521+ // A "bundle" is a versioned set of content that represents the resources that
522+ // need to be applied to a cluster to install a package.
523+ //
524+ // This field is only updated once a bundle has been successfully installed and
525+ // once set will only be updated when a new version of the bundle has
526+ // successfully replaced the currently installed version.
527+ //
528+ //+optional
529+ Bundle * BundleMetadata `json:"bundle,omitempty"`
530+ }
531+
532+ type ClusterExtensionResolutionStatus struct {
533+ // bundle is a representation of the bundle that was identified during
534+ // resolution to meet all installation/upgrade constraints and is slated to be
535+ // installed or upgraded to.
536+ //
537+ //+optional
538+ Bundle * BundleMetadata `json:"bundle,omitempty"`
539+ }
540+
517541//+kubebuilder:object:root=true
518542//+kubebuilder:resource:scope=Cluster
519543//+kubebuilder:subresource:status
0 commit comments