Skip to content

Commit 08b446a

Browse files
pedjakclaude
andcommitted
feat(api): deprecate spec.serviceAccount and adopt cluster-admin scope
Mark spec.serviceAccount as deprecated in the ClusterExtension API. Remove PreAuthorizer integration, SA-scoped RBAC templates, and restconfig action. Simplify the controller to use cluster-admin scope directly. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e4879a3 commit 08b446a

23 files changed

Lines changed: 380 additions & 1407 deletions

api/v1/clusterextension_types.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ const (
5050
// ClusterExtensionSpec defines the desired state of ClusterExtension
5151
type ClusterExtensionSpec struct {
5252
// namespace specifies a Kubernetes namespace.
53-
// This is the namespace where the provided ServiceAccount must exist.
54-
// It also designates the default namespace where namespace-scoped resources for the extension are applied to the cluster.
53+
// It designates the default namespace where namespace-scoped resources for the extension are applied to the cluster.
5554
// Some extensions may contain namespace-scoped resources to be applied in other namespaces.
5655
// This namespace must exist.
5756
//
@@ -67,14 +66,15 @@ type ClusterExtensionSpec struct {
6766
// +required
6867
Namespace string `json:"namespace"`
6968

70-
// serviceAccount specifies a ServiceAccount used to perform all interactions with the cluster
71-
// that are required to manage the extension.
72-
// The ServiceAccount must be configured with the necessary permissions to perform these interactions.
73-
// The ServiceAccount must exist in the namespace referenced in the spec.
74-
// The serviceAccount field is required.
69+
// serviceAccount is a deprecated field and is completely ignored.
70+
// OLMv1 is a single-tenant system where users with ClusterExtension write access are
71+
// effectively delegated cluster-admin trust. The operator-controller runs with
72+
// cluster-admin privileges and uses its own service account for all cluster interactions.
7573
//
76-
// +required
77-
ServiceAccount ServiceAccountReference `json:"serviceAccount"`
74+
// Deprecated: serviceAccount is no longer used and will be removed in a future release.
75+
//
76+
// +optional
77+
ServiceAccount ServiceAccountReference `json:"serviceAccount,omitzero"` //nolint:kubeapilinter // deprecated field uses omitzero per OpenShift convention; pointer would be a breaking API change
7878

7979
// source is required and selects the installation source of content for this ClusterExtension.
8080
// Set the sourceType field to perform the selection.
@@ -150,7 +150,7 @@ type SourceConfig struct {
150150
}
151151

152152
// ClusterExtensionInstallConfig is a union which selects the clusterExtension installation config.
153-
// ClusterExtensionInstallConfig requires the namespace and serviceAccount which should be used for the installation of packages.
153+
// ClusterExtensionInstallConfig requires the namespace which should be used for the installation of packages.
154154
//
155155
// +kubebuilder:validation:XValidation:rule="has(self.preflight)",message="at least one of [preflight] are required when install is specified"
156156
// +union
@@ -378,12 +378,13 @@ type CatalogFilter struct {
378378
UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"`
379379
}
380380

381-
// ServiceAccountReference identifies the serviceAccount used fo install a ClusterExtension.
381+
// ServiceAccountReference is a deprecated type and is completely ignored.
382+
//
383+
// Deprecated: ServiceAccountReference is no longer used and will be removed in a future release.
382384
type ServiceAccountReference struct {
383-
// name is a required, immutable reference to the name of the ServiceAccount used for installation
384-
// and management of the content for the package specified in the packageName field.
385+
// name is a deprecated field and is completely ignored.
385386
//
386-
// This ServiceAccount must exist in the installNamespace.
387+
// Deprecated: name is no longer used and will be removed in a future release.
387388
//
388389
// The name field follows the DNS subdomain standard as defined in [RFC 1123].
389390
// It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.),
@@ -403,10 +404,10 @@ type ServiceAccountReference struct {
403404
// [RFC 1123]: https://tools.ietf.org/html/rfc1123
404405
//
405406
// +kubebuilder:validation:MaxLength:=253
406-
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
407-
// +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="name must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters"
408-
// +required
409-
Name string `json:"name"`
407+
// +kubebuilder:validation:XValidation:rule="self == oldSelf || size(self) == 0",message="name is immutable once set, but may be cleared"
408+
// +kubebuilder:validation:XValidation:rule="size(self) == 0 || self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="name must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters"
409+
// +optional
410+
Name string `json:"name"` //nolint:kubeapilinter // deprecated field; empty string means unset, pointer would be a breaking API change
410411
}
411412

412413
// PreflightConfig holds the configuration for the preflight checks. If used, at least one preflight check must be non-nil.

api/v1/validation_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ func TestValidate(t *testing.T) {
2323
}
2424
defaultExtensionSpec := func(s *ClusterExtensionSpec) *ClusterExtensionSpec {
2525
s.Namespace = "ns"
26-
s.ServiceAccount = ServiceAccountReference{
27-
Name: "sa",
28-
}
2926
s.Source = SourceConfig{
3027
SourceType: SourceTypeCatalog,
3128
Catalog: &CatalogFilter{

applyconfigurations/api/v1/clusterextensioninstallconfig.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/clusterextensionspec.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/serviceaccountreference.go

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)