<p>I am using <a href="https://github.com/kubernetes-client/javascript" rel="noreferrer">Kubernetes javascript client</a> with, <strong>in-cluster configurations</strong> to interact with the cluster.</p>
<p>I am trying to get the list of jobs</p>
<p>app.js(Node)</p>
<pre><code>app.get(&quot;/&quot;, (req, res) =&gt; {
  k8sApi2
    .listNamespacedJob(&quot;default&quot;)
    .then((res) =&gt; {
      console.log(res.body);
      res.send(res.body);
    })
    .catch((err) =&gt; console.log(err));
});
</code></pre>
<p>But this is the log of the pod I am getting.</p>
<p><a href="https://i.stack.imgur.com/zwJQf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zwJQf.png" alt="Log" /></a></p>
<p>Here are my deployment</p>
<p><a href="https://i.stack.imgur.com/9B1E0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9B1E0.png" alt="Deployment" /></a></p>
<p>Service</p>
<p><a href="https://i.stack.imgur.com/vfIQc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vfIQc.png" alt="Service" /></a></p>
<p>Also, I created a role and a role binding but still, I have no idea what makes this issue.</p>
<pre><code>---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: node-apis
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: node-apis
rules:
  - apiGroups:
      - &quot;&quot;
      - &quot;apps&quot;
      - &quot;batch&quot;
    resources:
      - endpoints
      - deployments
      - pods
      - jobs
    verbs:
      - get
      - list
      - watch
      - create
      - delete
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: node-apis
  namespace: default
subjects:
  - kind: ServiceAccount
    name: node-apis
    namespace: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: node-apis

</code></pre>
<p>I am new to Kubernetes, any help?</p>

<p>You need to use the service account by specifying it in the spec section of the pod.Since you are not doing that it's using the <code>default</code> service account which does not have Role and RoleBinding permitting the operation, leading to <code>forbidden</code> error.</p>
<pre><code>spec:
  serviceAccountName: node-apis
  containers:
  ...
</code></pre>
<p>Alternatively you can give permission to the <code>default</code> service account in the RoleBinding</p>
<pre><code>kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: node-apis
  namespace: default
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: node-apis 
</code></pre>
