Score:0

ClusterRoleBinding does not apply

cn flag

rbac.yaml:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: my-account
  namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  namespace: default
  name: my-role
rules:
- apiGroups: [""]
  resources: ["*"]
  verbs: ["create", "delete", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: my-cluster-role-binding
  namespace: default
subjects:
- kind: ServiceAccount
  name: my-account
  namespace: default
roleRef:
  kind: ClusterRole
  name: my-role
  apiGroup: rbac.authorization.k8s.io

After kubectl apply -f rbac.yaml I try:

user@host> kubectl auth can-i create pods --as=my-account
no

What's wrong with my yaml?

Environment: new minikube.

Score:1
cn flag

I found the error. The --as=.. part was wrong:

This works:

kubectl auth can-i create pod --as=system:serviceaccount:default:my-account
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.