Bug: `runtime/client.(*Impersonator).CanImpersonate` does not take kubeconfig into account

Open
#959 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@yuminn-k is already working on this.

Since Oct 31, 2026.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
49/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
go
Domain
backend

Research direction

Start with runtime/client.(*Impersonator).CanImpersonate and trace how it checks for the ServiceAccount during Kustomization finalization. Compare the current-cluster lookup with the kubeconfig case, using the linked helm-controller issue for context. Done means the method recognizes a ServiceAccount in the remote cluster when spec.kubeConfig is configured, so finalization can collect remote garbage.

Written by the indexing model from the issue text.

Description

xref: https://github.com/fluxcd/helm-controller/issues/1250

This method is used by kustomize-controller during the finalization of a Kustomization to know if it can impersonate the configured spec.serviceAccountName for the operation. The method simply takes the existence of the ServiceAccount in the current cluster as the answer to this question. When spec.kubeConfig is configured, spec.serviceAccountName is supposed to exist in the remote cluster, and not in the current cluster. This means that if anybody is using both fields and the ServiceAccount does not exist in the current cluster (but correctly exists in the remote cluster), kustomize-controller does not collect the garbage in the remote cluster when the Kustomization is deleted.

Dominant language
Go
Stars
63
Forks
162
Avg merge
9h 54m
Merged PRs (30d)
29

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fluxcd/pkg

All issues in fluxcd/pkg

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.