kubectl debug with --as and --as-group overwrites service account #1715
Labels
kind/bug
Categorizes issue or PR as related to a bug.
needs-triage
Indicates an issue or PR lacks a `triage/foo` label and requires one.
What happened:
I am running
kubectl debug
in an AWS environment and want to use the AWS IAM privileges of the kube-system/ebs-csi-controller-sa (using AWS IAM roles for service accounts). But this service account does not have K8s privileges for node objects, so I have to run with--as-group system:masters
in addition. So finally I haveWhen running:
$ kubectl debug node/ip-<redacted>.compute.internal -it --profile=sysadmin --image=<redacted>.dkr.ecr.<redacted>.amazonaws.com/node-debug-container:1.4 --as kube-system/ebs-csi-controller-sa --as-group system:masters
which gives me a Bash prompt. But looking at the pod spec I see that it runs with
serviceAccount: default
and so the pod does not have the IAM privileges ofkube-system/ebs-csi-controller-sa
What you expected to happen:
kubectl debug
should merge--as ... --as-group ..
and run debug pod with respective service accountHow to reproduce it (as minimally and precisely as possible):
Run a command similar to the above in an EKS cluster with EBS CSI driver installed and using IRSA and specify for example a publicly available image like:
kubectl debug node/<redacted> -it --profile=sysadmin --image=public.ecr.aws/amazonlinux/amazonlinux:2023 --as kube-system/ebs-csi-controller-sa --as-group system:masters
Anything else we need to know?:
Environment:
kubectl version
): v1.32.1cat /etc/os-release
):The text was updated successfully, but these errors were encountered: