<p>I'm trying to deploy my application into EKS cluster. When I am running jenkins job I could able to get <code>kubectl get pod</code> details with running state at the same time when I'm trying to deploy yaml file via jenkins I'm getting below error:</p>
<pre><code>+ kubectl create -f deployment.yaml
Error from server (Forbidden): error when creating &quot;deployment.yaml&quot;: deployments.apps is forbidden: User &quot;system:node:ip-10-2-3-4.eu-central-1.compute.internal&quot; cannot create resource &quot;deployments&quot; in API group &quot;apps&quot; in the namespace &quot;default&quot;
</code></pre>
<p>create pod</p>
<pre><code>+ kubectl '--kubeconfig=****' '--context=arn:aws:eks:eu-central-1:123456789101:cluster/my-cluster' sh &quot;kubectl auth can-i list pods&quot;
yes
</code></pre>
<p>Create deployment</p>
<pre><code>+ kubectl '--kubeconfig=****' '--context=arn:aws:eks:eu-central-1:123456789101:cluster/my-cluster' sh &quot;kubectl auth can-i create deployment&quot;
no
</code></pre>

Gowmi
<p>So that means you have permissions to read/list pods data but dont have an access for creating <code>deployment</code> object.</p>
<p>Below is 2 examples, check and compare them.</p>
<ul>
<li>1st is just reading rules(what you currently have)</li>
</ul>
<pre><code>rules:
- apiGroups: [&quot;&quot;]
  #
  # at the HTTP level, the name of the resource for accessing Pod
  # objects is &quot;pods&quot;
  resources: [&quot;pods&quot;]
  verbs: [&quot;get&quot;, &quot;list&quot;, &quot;watch&quot;]
</code></pre>
<ul>
<li>2nd is permissions for deployment creation (<code>verbs: [&quot;**create**&quot;]</code>). Most probably you miss this part</li>
</ul>
<pre><code>rules:
- apiGroups: [&quot;extensions&quot;, &quot;apps&quot;]
  #
  # at the HTTP level, the name of the resource for accessing Deployment
  # objects is &quot;deployments&quot;
  resources: [&quot;deployments&quot;]
  verbs: [&quot;get&quot;, &quot;list&quot;, &quot;watch&quot;, &quot;create&quot;, &quot;update&quot;, &quot;patch&quot;, &quot;delete&quot;]
</code></pre>
<p>For more options, examples and explanations please check <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">Using RBAC Authorization</a></p>
