[Solved] Error creating: pods “my-service-a-xxx” is forbidden: error looking up service account my-apps/my-service-a: serviceaccount “my-service-a” not found

0 min read 132 words

So you’ve run a deployment and tried to check the pods and there’s nothing there!

kubectl get pods

Next step is to see what’s happening with the replicaset

kubectl get rs

Then take the replicaset name and do a describe on it:

kubectl describe rs my-service-a-5549cbc6c8

The error

Events:
  Type     Reason            Age           From         Message
  ----     ------            ----          ----         -------
  Warning  FailedCreate      2m10s..  replicaset-controller  Error creating: pods "my-service-a-5549cbc6c8-" is forbidden: error looking up service account my-apps/my-service-a: serviceaccount "my-service-a" not found

It’s down to a missing Service Account!

The fix

You need to create a service account:

kubectl create serviceaccount my-service-a

Remember to create it in the same namespace as the deployment.

So if you have a deployment going to my-apps namespace, then you should do the following:

kubectl create serviceaccount my-service-a -n my-apps
Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags