Skip to content

Unable to delete namespace for HelmReleases impersonating ServiceAccount #270

@darryl-sw

Description

@darryl-sw

When:

  1. A HelmRelease sets .spec.serviceAccountName to "default"
  2. A Namespace is set for termination
  3. The ServiceAccount is terminated before the HelmRelease automatically
  4. The HelmController attempts to delete the HelmRelease
  5. The Namespace never terminates
{"level":"error","ts":"2021-06-01T01:30:41.625Z","logger":"controller.helmrelease","msg":"Reconciler error","reconciler group":"helm.toolkit.fluxcd.io","reconciler kind":"HelmRelease","name":"nginx-hello","namespace":"gatekeeper-test-296eaaf2","error":"could not impersonate ServiceAccount 'default': ServiceAccount \"default\" not found"}
{"level":"error","ts":"2021-06-01T01:31:22.901Z","logger":"controller.helmrelease","msg":"Reconciler error","reconciler group":"helm.toolkit.fluxcd.io","reconciler kind":"HelmRelease","name":"nginx-hello","namespace":"gatekeeper-test-a2852804","error":"could not impersonate ServiceAccount 'default': ServiceAccount \"default\" not found"}
{"level":"error","ts":"2021-06-01T01:32:59.594Z","logger":"controller.helmrelease","msg":"Reconciler error","reconciler group":"helm.toolkit.fluxcd.io","reconciler kind":"HelmRelease","name":"nginx-hello","namespace":"gatekeeper-test-d4cc7ecb","error":"could not impersonate ServiceAccount 'default': ServiceAccount \"default\" not found"}
{"level":"error","ts":"2021-06-01T01:36:09.305Z","logger":"controller.helmrelease","msg":"Reconciler error","reconciler group":"helm.toolkit.fluxcd.io","reconciler kind":"HelmRelease","name":"nginx-hello","namespace":"gatekeeper-test-296eaaf2","error":"could not impersonate ServiceAccount 'default': ServiceAccount \"default\" not found"}

Hypothesis:
The Helm Controller is behaving as expected by attempting to impersonate the SA, and failing the operation because the SA does not exist. This behaviour is unexpected as a a termination of a namespace should result in the deletion of helm resources as well.

Alternatives:

  1. Impersonate only for creation of resources, and not for deletion of resources
  2. If a SA cannot be found, detect if a namespace is marked for deletion, and delete the helm resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions