Skip to content

Commit 1e74ae0

Browse files
committed
helm: use chunking release driver in systemNamespace
Signed-off-by: Joe Lanford <[email protected]>
1 parent 957fc1b commit 1e74ae0

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

cmd/manager/main.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,31 @@ func main() {
172172
}
173173
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(catalogsCachePath, httpClient))
174174

175+
// We use the systemNamespaceMapper to globally use the system namespace for storing release secrets.
176+
// This ensures that we do not leak implementation details into user namespaces.
177+
//
178+
// NOTE: When we add support for use of service accounts, we will use this controller's service account
179+
// to manage the release secrets. That way, we won't leak our implementation's RBAC requirements
180+
// to users either.
181+
systemNamespaceMapper := helmclient.ObjectToStringMapper(func(obj client.Object) (string, error) {
182+
return systemNamespace, nil
183+
})
175184
installNamespaceMapper := helmclient.ObjectToStringMapper(func(obj client.Object) (string, error) {
176185
ext := obj.(*ocv1alpha1.ClusterExtension)
177186
return ext.Spec.InstallNamespace, nil
178187
})
179188
cfgGetter, err := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(),
180-
helmclient.StorageNamespaceMapper(installNamespaceMapper),
189+
// We use a custom storage driver for two reasons:
190+
// 1. We need to chunk secrets to avoid hitting etcd limits on the size of a single object.
191+
// 2. We need to avoid using the same storage driver as the Helm CLI to avoid conflicts and
192+
// accidental inheritance of behavior (e.g. adoption of a Helm CLI-created release by
193+
// operator-controller)
194+
helmclient.StorageDriverMapper(helmclient.ChunkedSecretsStorageDriver(
195+
"operator-controller",
196+
1048576, // Use 1MB chunks
197+
helmclient.SecretsStorageDriverOpts{
198+
StorageNamespaceMapper: systemNamespaceMapper,
199+
})),
181200
helmclient.ClientNamespaceMapper(installNamespaceMapper),
182201
)
183202
if err != nil {

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ require (
3737
sigs.k8s.io/yaml v1.4.0
3838
)
3939

40+
replace github.com/operator-framework/helm-operator-plugins => github.com/joelanford/helm-operator v0.0.8-0.20240716193650-3fdf9f962b60
41+
4042
require (
4143
cloud.google.com/go/compute/metadata v0.3.0 // indirect
4244
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw
441441
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
442442
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
443443
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
444+
github.com/joelanford/helm-operator v0.0.8-0.20240716193650-3fdf9f962b60 h1:NLMNoYzWGg/w/8kS7/U38D6h4iz2X0EusHJk/pkouO4=
445+
github.com/joelanford/helm-operator v0.0.8-0.20240716193650-3fdf9f962b60/go.mod h1:ly6Bd9rSzmt37Wy6WtZHmA+IY9zG958MryJFLcVpCXw=
444446
github.com/joelanford/ignore v0.1.0 h1:VawbTDeg5EL+PN7W8gxVzGerfGpVo3gFdR5ZAqnkYRk=
445447
github.com/joelanford/ignore v0.1.0/go.mod h1:Vb0PQMAQXK29fmiPjDukpO8I2NTcp1y8LbhFijD1/0o=
446448
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
@@ -588,8 +590,6 @@ github.com/operator-framework/api v0.26.0 h1:YVntU2NkVl5zSLLwK5kFcH6P3oSvN9QDgTs
588590
github.com/operator-framework/api v0.26.0/go.mod h1:3IxOwzVUeGxYlzfwKCcfCyS+q3EEhWA/4kv7UehbeyM=
589591
github.com/operator-framework/catalogd v0.18.0 h1:3eFoURYkn+vspoqYL5ijzUjAyVMSSR60BMOiKFvdVmM=
590592
github.com/operator-framework/catalogd v0.18.0/go.mod h1:3i2dDt0yg6L/xHbNt93/Teao6xBC8rhL6UgewjQpvI8=
591-
github.com/operator-framework/helm-operator-plugins v0.3.0 h1:LNhcb5nPT/TAxZSsKH2LTYh79RgiN2twGFptQR96sRM=
592-
github.com/operator-framework/helm-operator-plugins v0.3.0/go.mod h1:ly6Bd9rSzmt37Wy6WtZHmA+IY9zG958MryJFLcVpCXw=
593593
github.com/operator-framework/operator-lib v0.14.0 h1:er+BgZymZD1im2wytLJiPLZpGALAX6N0gXaHx3PKbO4=
594594
github.com/operator-framework/operator-lib v0.14.0/go.mod h1:wUu4Xb9xzXnIpglvaZ3yucTMSlqGXHIoUEH9+5gWiu0=
595595
github.com/operator-framework/operator-registry v1.44.0 h1:NW5/xHYR77J2EUYm+6iBER1WNGLNS8gM+G5GBQWqTTs=

0 commit comments

Comments
 (0)