Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
fix pod kube-api-access service-account not found
Browse files Browse the repository at this point in the history
  • Loading branch information
雄奇 committed Sep 12, 2023
1 parent 1e31f2d commit a92297e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (pl *PodKubeAPIAccessMutatorPlugin) Mutator() conversion.PodMutator {
p.PPod.Spec.ServiceAccountName = DefaultServiceAccountName
}

targetNamespace := conversion.ToSuperClusterNamespace(p.ClusterName, p.PPod.Namespace)
targetNamespace := conversion.ToSuperClusterNamespace(p.ClusterName, p.VPod.Namespace)
serviceAccount, err := pl.client.CoreV1().ServiceAccounts(targetNamespace).Get(context.TODO(), p.PPod.Spec.ServiceAccountName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("error looking up serviceAccount %s/%s: %v", targetNamespace, p.PPod.Spec.ServiceAccountName, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ func TestPodKubeAPIAccessMutatorPlugin_Mutator(t *testing.T) {
tests := []struct {
name string
pPod *corev1.Pod
vPod *corev1.Pod
existingObjectInSuper []runtime.Object
}{
{
"Test RootCACert Mutator",
tenantKubeAPIAccessPod("test", "default", "123-456-789"),
tenantKubeAPIAccessPod("test", "cluster1-default", "123-456-789"),
tenantKubeAPIAccessPod("test", "default", "000-456-789"),
[]runtime.Object{
&corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -161,7 +163,7 @@ func TestPodKubeAPIAccessMutatorPlugin_Mutator(t *testing.T) {
}
mutator := pl.Mutator()

if err := mutator(&conversion.PodMutateCtx{ClusterName: "cluster1", PPod: tt.pPod}); err != nil {
if err := mutator(&conversion.PodMutateCtx{ClusterName: "cluster1", PPod: tt.pPod, VPod: tt.vPod}); err != nil {
t.Errorf("mutator failed processing the pod, %v", err)
}

Expand Down

0 comments on commit a92297e

Please sign in to comment.