<p>I want to have a service account that can create a deployment. So I am creating a service account, then a role and then a rolebinding. The yaml files are below: </p>

<p>ServiceAccount:</p>

<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
  name: testsa
  namespace: default
</code></pre>

<p>Role:</p>

<pre><code>kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: testrole
  namespace: default
rules:
  - apiGroups:
      - ""
      - batch
      - apps
    resources:
      - jobs
      - pods
      - deployments
      - deployments/scale   
      - replicasets
    verbs:
      - create
      - delete
      - get
      - list
      - patch
      - update
      - watch
      - scale 
</code></pre>

<p>RoleBinding:</p>

<pre><code>kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: testrolebinding
  namespace: default
subjects:
  - kind: ServiceAccount
    name: testsa
    namespace: default
roleRef:
  kind: Role
  name: testrole
  apiGroup: rbac.authorization.k8s.io
</code></pre>

<p>But after applying these files, when I do the following command to check if the service account can create a deployment, it answers no.</p>

<p><code>kubectl auth can-i --as=system:serviceaccount:default:testsa create deployment</code></p>

<p>The exact answer is: 
<code>no - no RBAC policy matched</code></p>

<p>It works fine when I do checks for Pods.</p>

<p>What am I doing wrong?</p>

<p>My kubernetes versions are as follows:</p>

<pre><code>kubectl version --short

Client Version: v1.16.1
Server Version: v1.12.10-gke.17
</code></pre>

Satyajit Das
<p>Since you're using a 1.12 cluster, you should include the <code>extensions</code> API group in the <code>Role</code> for the <code>deployments</code> resource.</p>

<p>This was deprecated in Kubernetes 1.16 in favor of the <code>apps</code> group: <a href="https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/" rel="nofollow noreferrer">https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/</a></p>
