Skip to content

Commit cd8667e

Browse files
committed
Deprecate spec.ServiceAccount and remove synthetic permissions feature
Make spec.ServiceAccount an optional field and note that it's now deprecated and does not perform any function. Make OLM use cluster-admin by default for managing ClusterExtensions. Remove the synthetic permissions experimental feature flag.
1 parent dcf2963 commit cd8667e

File tree

22 files changed

+112
-1766
lines changed

22 files changed

+112
-1766
lines changed

api/v1/clusterextension_types.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ const (
4949
// ClusterExtensionSpec defines the desired state of ClusterExtension
5050
type ClusterExtensionSpec struct {
5151
// namespace is a reference to a Kubernetes namespace.
52-
// This is the namespace in which the provided ServiceAccount must exist.
53-
// It also designates the default namespace where namespace-scoped resources
52+
// It designates the default namespace where namespace-scoped resources
5453
// 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.
@@ -67,14 +66,13 @@ type ClusterExtensionSpec struct {
6766
// +kubebuilder:validation:Required
6867
Namespace string `json:"namespace"`
6968

70-
// serviceAccount is a reference to a ServiceAccount used to perform all interactions
69+
// serviceAccount is deprecated and ignored by OLM.
70+
// serviceAccount was a reference to the ServiceAccount used to perform all interactions
7171
// with the cluster 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-
// serviceAccount is required.
72+
// serviceAccount is optional.
7573
//
76-
// +kubebuilder:validation:Required
77-
ServiceAccount ServiceAccountReference `json:"serviceAccount"`
74+
// +kubebuilder:validation:Optional
75+
ServiceAccount *ServiceAccountReference `json:"serviceAccount,omitempty"`
7876

7977
// source is a required field which selects the installation source of content
8078
// for this ClusterExtension. Selection is performed by setting the sourceType.
@@ -369,7 +367,8 @@ type CatalogFilter struct {
369367
UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"`
370368
}
371369

372-
// ServiceAccountReference identifies the serviceAccount used fo install a ClusterExtension.
370+
// ServiceAccountReference identifies the serviceAccount used to install a ClusterExtension.
371+
// Note: The serviceAccount field is deprecated and ignored by OLM.
373372
type ServiceAccountReference struct {
374373
// name is a required, immutable reference to the name of the ServiceAccount
375374
// to be used for installation and management of the content for the package

cmd/operator-controller/main.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ import (
6262
ocv1 "github.com/operator-framework/operator-controller/api/v1"
6363
"github.com/operator-framework/operator-controller/internal/operator-controller/action"
6464
"github.com/operator-framework/operator-controller/internal/operator-controller/applier"
65-
"github.com/operator-framework/operator-controller/internal/operator-controller/authentication"
66-
"github.com/operator-framework/operator-controller/internal/operator-controller/authorization"
6765
"github.com/operator-framework/operator-controller/internal/operator-controller/catalogmetadata/cache"
6866
catalogclient "github.com/operator-framework/operator-controller/internal/operator-controller/catalogmetadata/client"
6967
"github.com/operator-framework/operator-controller/internal/operator-controller/contentmanager"
@@ -606,11 +604,9 @@ func setupHelm(
606604
if err != nil {
607605
return fmt.Errorf("unable to create core client: %w", err)
608606
}
609-
tokenGetter := authentication.NewTokenGetter(coreClient, authentication.WithExpirationDuration(1*time.Hour))
610-
clientRestConfigMapper := action.ServiceAccountRestConfigMapper(tokenGetter)
611-
if features.OperatorControllerFeatureGate.Enabled(features.SyntheticPermissions) {
612-
clientRestConfigMapper = action.SyntheticUserRestConfigMapper(clientRestConfigMapper)
613-
}
607+
// tokenGetter := authentication.NewTokenGetter(coreClient, authentication.WithExpirationDuration(1*time.Hour))
608+
// clientRestConfigMapper := action.ServiceAccountRestConfigMapper(tokenGetter)
609+
clientRestConfigMapper := action.ClusterAdminRestConfigMapper(mgr.GetConfig())
614610

615611
cfgGetter, err := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(),
616612
helmclient.StorageDriverMapper(action.ChunkedStorageDriverMapper(coreClient, mgr.GetAPIReader(), cfg.systemNamespace)),
@@ -631,12 +627,6 @@ func setupHelm(
631627
return fmt.Errorf("unable to create helm action client getter: %w", err)
632628
}
633629

634-
// determine if PreAuthorizer should be enabled based on feature gate
635-
var preAuth authorization.PreAuthorizer
636-
if features.OperatorControllerFeatureGate.Enabled(features.PreflightPermissions) {
637-
preAuth = authorization.NewRBACPreAuthorizer(mgr.GetClient())
638-
}
639-
640630
cm := contentmanager.NewManager(clientRestConfigMapper, mgr.GetConfig(), mgr.GetRESTMapper())
641631
err = clusterExtensionFinalizers.Register(controllers.ClusterExtensionCleanupContentManagerCacheFinalizer, finalizers.FinalizerFunc(func(ctx context.Context, obj client.Object) (crfinalizer.Result, error) {
642632
ext := obj.(*ocv1.ClusterExtension)
@@ -660,7 +650,6 @@ func setupHelm(
660650
IsWebhookSupportEnabled: certProvider != nil,
661651
},
662652
HelmReleaseToObjectsConverter: &applier.HelmReleaseToObjectsConverter{},
663-
PreAuthorizer: preAuth,
664653
Watcher: ceController,
665654
Manager: cm,
666655
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: manager-rolebinding
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: cluster-admin
9+
subjects:
10+
- kind: ServiceAccount
11+
name: controller-manager
12+
namespace: olmv1-system
13+
---
14+
apiVersion: rbac.authorization.k8s.io/v1
15+
kind: RoleBinding
16+
metadata:
17+
name: manager-rolebinding
18+
namespace: olmv1-system
19+
roleRef:
20+
apiGroup: rbac.authorization.k8s.io
21+
kind: Role
22+
name: manager-role
23+
subjects:
24+
- kind: ServiceAccount
25+
name: controller-manager
26+
namespace: olmv1-system
27+
---
28+
apiVersion: rbac.authorization.k8s.io/v1
29+
kind: ClusterRoleBinding
30+
metadata:
31+
name: manager-rolebinding
32+
roleRef:
33+
apiGroup: rbac.authorization.k8s.io
34+
kind: ClusterRole
35+
name: manager-role
36+
subjects:
37+
- kind: ServiceAccount
38+
name: controller-manager
39+
namespace: olmv1-system

hack/demo/resources/synthetic-user-perms/argocd-clusterextension.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

hack/demo/resources/synthetic-user-perms/cegroup-admin-binding.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

hack/demo/synthetic-user-cluster-admin-demo-script.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

hack/tools/crd-generator/testdata/api/v1/clusterextension_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ type ClusterExtensionSpec struct {
6363
// +kubebuilder:validation:Required
6464
Namespace string `json:"namespace"`
6565

66-
// serviceAccount is a reference to a ServiceAccount used to perform all interactions
66+
// serviceAccount is deprecated and ignored by OLM.
6767
// with the cluster that are required to manage the extension.
6868
// The ServiceAccount must be configured with the necessary permissions to perform these interactions.
6969
// The ServiceAccount must exist in the namespace referenced in the spec.
70-
// serviceAccount is required.
70+
// serviceAccount is deprecated and optional.
7171
//
72-
// +kubebuilder:validation:Required
72+
// +kubebuilder:validation:Optional
7373
ServiceAccount ServiceAccountReference `json:"serviceAccount"`
7474

7575
// source is a required field which selects the installation source of content

helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ spec:
146146
namespace:
147147
description: |-
148148
namespace is a reference to a Kubernetes namespace.
149-
This is the namespace in which the provided ServiceAccount must exist.
150-
It also designates the default namespace where namespace-scoped resources
149+
It designates the default namespace where namespace-scoped resources
151150
for the extension are applied to the cluster.
152151
Some extensions may contain namespace-scoped resources to be applied in other namespaces.
153152
This namespace must exist.
@@ -166,11 +165,10 @@ spec:
166165
rule: self.matches("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
167166
serviceAccount:
168167
description: |-
169-
serviceAccount is a reference to a ServiceAccount used to perform all interactions
168+
serviceAccount is deprecated and ignored by OLM.
169+
serviceAccount was a reference to the ServiceAccount used to perform all interactions
170170
with the cluster that are required to manage the extension.
171-
The ServiceAccount must be configured with the necessary permissions to perform these interactions.
172-
The ServiceAccount must exist in the namespace referenced in the spec.
173-
serviceAccount is required.
171+
serviceAccount is optional.
174172
properties:
175173
name:
176174
description: |-
@@ -493,7 +491,6 @@ spec:
493491
has(self.catalog) : !has(self.catalog)'
494492
required:
495493
- namespace
496-
- serviceAccount
497494
- source
498495
type: object
499496
status:

helm/olmv1/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ spec:
112112
namespace:
113113
description: |-
114114
namespace is a reference to a Kubernetes namespace.
115-
This is the namespace in which the provided ServiceAccount must exist.
116-
It also designates the default namespace where namespace-scoped resources
115+
It designates the default namespace where namespace-scoped resources
117116
for the extension are applied to the cluster.
118117
Some extensions may contain namespace-scoped resources to be applied in other namespaces.
119118
This namespace must exist.
@@ -132,11 +131,10 @@ spec:
132131
rule: self.matches("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$")
133132
serviceAccount:
134133
description: |-
135-
serviceAccount is a reference to a ServiceAccount used to perform all interactions
134+
serviceAccount is deprecated and ignored by OLM.
135+
serviceAccount was a reference to the ServiceAccount used to perform all interactions
136136
with the cluster that are required to manage the extension.
137-
The ServiceAccount must be configured with the necessary permissions to perform these interactions.
138-
The ServiceAccount must exist in the namespace referenced in the spec.
139-
serviceAccount is required.
137+
serviceAccount is optional.
140138
properties:
141139
name:
142140
description: |-
@@ -459,7 +457,6 @@ spec:
459457
has(self.catalog) : !has(self.catalog)'
460458
required:
461459
- namespace
462-
- serviceAccount
463460
- source
464461
type: object
465462
status:

helm/olmv1/templates/rbac/clusterrolebinding-operator-controller-manager-rolebinding.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ metadata:
1616
roleRef:
1717
apiGroup: rbac.authorization.k8s.io
1818
kind: ClusterRole
19-
{{- if has "BoxcutterRuntime" .Values.operatorControllerFeatures }}
2019
name: cluster-admin
21-
{{- else }}
22-
name: operator-controller-manager-role
23-
{{- end }}
2420
subjects:
2521
- kind: ServiceAccount
2622
name: operator-controller-controller-manager

0 commit comments

Comments
 (0)