Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

535
Views
jobs.batch is forbidden: User ' '"system:serviceaccount:default:default" cannot list resource "jobs" in API group "batch" in the namespace "default"

I am using Kubernetes javascript client with, in-cluster configurations to interact with the cluster.

I am trying to get the list of jobs

app.js(Node)

app.get("/", (req, res) => {
  k8sApi2
    .listNamespacedJob("default")
    .then((res) => {
      console.log(res.body);
      res.send(res.body);
    })
    .catch((err) => console.log(err));
});

But this is the log of the pod I am getting.

Log

Here are my deployment

Deployment

Service

Service

Also, I created a role and a role binding but still, I have no idea what makes this issue.

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: node-apis
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: node-apis
rules:
  - apiGroups:
      - ""
      - "apps"
      - "batch"
    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

I am new to Kubernetes, any help?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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 default service account which does not have Role and RoleBinding permitting the operation, leading to forbidden error.

spec:
  serviceAccountName: node-apis
  containers:
  ...

Alternatively you can give permission to the default service account in the RoleBinding

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 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!