<p>I have a daemon running on my kubernetes cluster whose purpose is to accept gRPC requests and turn those into commands for creating, deleting, and viewing pods in the k8s cluster. It runs as a service in the cluster and is deployed through helm.</p>
<p>The helm chart creates a service account for the daemon, &quot;tass-daemon&quot;, and gives it a cluster role that is supposed to allow it to manipulate pods in a specific namespace, &quot;tass-arrays&quot;.</p>
<p>However, I'm finding that the service account does not appear to be working, with my daemon reporting a permissions error when it tries to contact the K8S API server:</p>
<pre><code>2021/03/04 21:17:48 pods is forbidden: User &quot;system:serviceaccount:default:tass-daemon&quot; cannot list resource &quot;pods&quot; in API group &quot;&quot; in the namespace &quot;tass-arrays&quot;
</code></pre>
<p>I confirmed that the code works if I use the default service account with a manually added clusterrole, but attempting to do the setup through the helm chart appears to not work.</p>
<p>However, if I compare the tass-daemon clusterrole to that of admin (which clearly has the permissions to manipulate pods in all namespaces), they appear to be identical:</p>
<pre><code>[maintainer@headnode helm]$ kubectl describe clusterrole admin  | grep -i pods
  pods                                            []                 []              [create delete deletecollection patch update get list watch]
  pods/attach                                     []                 []              [get list watch create delete deletecollection patch update]
  pods/exec                                       []                 []              [get list watch create delete deletecollection patch update]
  pods/portforward                                []                 []              [get list watch create delete deletecollection patch update]
  pods/proxy                                      []                 []              [get list watch create delete deletecollection patch update]
  pods/log                                        []                 []              [get list watch]
  pods/status                                     []                 []              [get list watch]

[maintainer@headnode helm]$ kubectl describe clusterrole tass-daemon  | grep -i pods
  pods/attach  []                 []              [create delete deletecollection patch update get list watch]
  pods         []                 []              [create delete deletecollection patch update get list watch]
  pods.apps    []                 []              [create delete deletecollection patch update get list watch]
  pods/status  []                 []              [get list watch]
</code></pre>
<p>Based on this setup, I would expect the tass-daemon service account to have the appropriate permissions for pod management.</p>
<p>The following is my clusterrole.yaml from my helm chart:</p>
<pre><code>{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  labels:
    app: {{ template &quot;tass-daemon.name&quot; . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template &quot;tass-daemon.fullname&quot; . }}
  namespace: &quot;tass-arrays&quot;
rules:
- apiGroups:
  - &quot;&quot;
  resources:
  - pods
  verbs:
  - create delete deletecollection patch update get list watch
- apiGroups:
  - &quot;&quot;
  resources:
  - pods/attach
  verbs:
  - create delete deletecollection patch update get list watch
- apiGroups:
  - &quot;&quot;
  resources:
  - pods/status
  verbs:
  - get list watch
- apiGroups:
  - apps
</code></pre>
<p>And my clusterrolebinding.yaml:</p>
<pre><code>{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  labels:
    app: {{ template &quot;tass-daemon.name&quot; .}}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template &quot;tass-daemon.fullname&quot; . }}
  namespace: &quot;tass-arrays&quot;
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: {{ template &quot;tass-daemon.fullname&quot; . }}
subjects:
- kind: ServiceAccount
  name: {{ template &quot;tass-daemon.fullname&quot; . }}
  namespace: {{ .Release.Namespace }}
{{- end -}}
</code></pre>
<p>If I change the roleRef name to &quot;admin&quot;, it works, but admin is more permissive than we'd prefer.</p>
<p>And finally here's my serviceaccount.yaml:</p>
<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app: {{ template &quot;tass-daemon.name&quot; . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template &quot;tass-daemon.fullname&quot; . }}
</code></pre>
<p>Clearly I'm doing something wrong, so what is the proper way to configure the clusterrole so that my daemon can manipulate pods in the &quot;tass-arrays&quot; namespace?</p>

stix
<p>As I have mentioned in comment section there is a deprecation on <code>apiVersion</code> <code>rbac.authorization.k8s.io/v1beta1</code>, instead use <code>rbac.authorization.k8s.io/v1</code> instead .
The API <code>v1</code> is stable. You should use stable version if it possible.</p>
<p>Read more: <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">rbac-kubernetes</a>.</p>
<p>About problem with <code>RBAC</code>, part of your <code>ClusterRole</code> below rules section should looks like:</p>
<pre><code>rules:
- apiGroups: [&quot;&quot;]
  resources: [&quot;pods&quot;]
  verbs: [&quot;get&quot;, &quot;watch&quot;, &quot;list&quot;]
</code></pre>
<p>See: <a href="https://stackoverflow.com/questions/52951777/listing-pods-from-inside-a-pod-forbidden">pod-rbac-forbidden</a>.</p>
