kubernetes pods is forbidden: User "user1" cannot list pods in the namespace "stage" kubernetes pods is forbidden: User "user1" cannot list pods in the namespace "stage" kubernetes kubernetes

kubernetes pods is forbidden: User "user1" cannot list pods in the namespace "stage"


The RoleBinding is for user user2, not for user1. That's why you are getting RBAC error.

Setting context for user user2 does not mean that kubernetes will identify this user as user2. It depends on the credential you use. If the used credential is of user user-x, then kubernetes will treat it as user-x. The context user is for kubectl to find user credential info. To understand kubernetes authentication see here.

The credential you used there resolved to user user1. So you should update your RoleBinding to user1.

After updated question

For certificate authetication, CN will be the username (ref: here).In your certificate "/CN=user1/O=8gwifi.org", so username will be user1 not user2.