Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a secret for service account using Kubernetes version 1.24

I am using Kubernetes version 1.24, I have created a secret for my service account manually, but when I run kubectl get serviceaccounts, it is showing that I do not have any secrets for that service account?

like image 391
Coder3000 Avatar asked Oct 28 '25 22:10

Coder3000


1 Answers

If you are on K8s version 1.24

The serviceaccount won't create the secret automatically.

You have to create it manually.

kubectl create sa <serviceaccount-name>

Example :

apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
  name: token-secret
  annotations:
    kubernetes.io/service-account.name: "<SA name>"

If you just want to create the token you can use the : kubectl create token <Name>

Read more about it : https://medium.com/@harsh.manvar111/k8s-v1-24-is-unable-to-create-a-serviceaccount-secret-798f8454e6e7

like image 101
Harsh Manvar Avatar answered Nov 01 '25 12:11

Harsh Manvar