kuberneteskubectlgoogle-anthos

kubectl - Error from server (Forbidden): users "xxx@xxx.it" is forbidden: User "system:serviceaccount:gke-connect:connect-agent-sa"


I have this strange situation, how I can solve this problem ?

ubuntu@anth-mgt-wksadmin:~$ kubectl get nodes
error: the server doesn't have a resource type "nodes"

ubuntu@anth-mgt-wksadmin:~$ kubectl cluster-info
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
error: the server doesn't have a resource type "services"

ubuntu@anth-mgt-wksadmin:~$ kubectl cluster-info dump
Error from server (Forbidden): users "xxx@xxx.it" is forbidden: User system:serviceaccount:gke-connect:connect-agent-sa" cannot impersonate resource "users" in API group "" at the cluster scope

I think that the problem has been generated by this following apply searching a way to connect the admin cluster to Cloud Console but how to rollback ?

USER_ACCOUNT=foo@example.com
cat <<EOF > /tmp/impersonate.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: gateway-impersonate
rules:
- apiGroups:
  - ""
  resourceNames:
  - ${USER_ACCOUNT}
  resources:
  - users
  verbs:
 - impersonate
 - --
 - apiVersion: rbac.authorization.k8s.io/v1
 - kind: ClusterRoleBinding
metadata:
  name: gateway-impersonate
roleRef:
  kind: ClusterRole
  name: gateway-impersonate
  apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
  name: connect-agent-sa
  namespace: gke-connect
EOF
# Apply impersonation policy to the cluster.
kubectl apply -f /tmp/impersonate.yaml

Solution

  • I have copied the admin.conf file from one admin cluster node to the admin workstation and renamed to kubeconfig

    root@anth-admin-host1:~# cat /etc/kubernetes/admin.conf apiVersion: v1 clusters: