<p>I have a kubernetes cluster version 1.26
Here i'm creating  a serviceaccount following the instructions in the yaml given below</p>
<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
   creationTimestamp: null
   name: devops-serviceaccount
   namespace: default


apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  creationTimestamp: null
  name: role-for-serviceaccount
  namespace: default
rules:
- apiGroups: [&quot;*&quot;,&quot;apps&quot;,&quot;extensions&quot;]
  resources: [&quot;*&quot;]
  verbs: [&quot;get&quot;, &quot;list&quot;, &quot;watch&quot;, &quot;create&quot;, &quot;update&quot;, &quot;patch&quot;, &quot;delete&quot;]




apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  creationTimestamp: null
  name: rolebinding-for-serviceaccount
  namespace: default
subjects:
- kind: ServiceAccount
  name: devops-serviceaccount
  namespace: default
roleRef:
  kind: Role
  name: role-for-serviceaccount
  apiGroup: rbac.authorization.k8s.io


apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
  name: devops-sa-secret
  annotations:
      kubernetes.io/service-account.name: &quot;devops-serviceaccount&quot;
</code></pre>
<p>after deploying the yaml i run the following command</p>
<blockquote>
<p>kubectl get serviceAccounts devops-serviceaccount</p>
</blockquote>
<p>I expect a Service Account with the secrets attached to it but the secret count is 0</p>
<p><a href="https://i.stack.imgur.com/pWfls.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pWfls.png" alt="enter image description here" /></a></p>

Arshad Badar Khan
<p>After version K8s <strong>1.24</strong> it does not default to create the secret with a <strong>Service account</strong>. If you are following any article make sure it's not for an older versions of <strong>k8s</strong>.</p>
<p>As you are on <strong>1.26</strong> which is the latest and it does not support <strong>secret</strong> creation by default with SA creation and it wont show.</p>
<p>You can read more about my article : <a href="https://medium.com/faun/k8s-v1-24-is-unable-to-create-a-serviceaccount-secret-798f8454e6e7" rel="nofollow noreferrer">https://medium.com/faun/k8s-v1-24-is-unable-to-create-a-serviceaccount-secret-798f8454e6e7</a></p>
<p><strong>Update</strong></p>
<pre><code>apiVersion: v1
kind: ServiceAccount
metadata:
  name: test-sa
secrets:
  - name: token-secret
---
apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
  name: token-secret
  annotations:
    kubernetes.io/service-account.name: &quot;test-sa&quot;
</code></pre>
<p>what i found, field counts the <strong>secrets</strong> mentioned in the field with a <strong>service account</strong>.</p>
<p>Code ref of <a href="https://github.com/kubernetes/kubernetes/blob/c09d01192aa51f9db0457ddb1ae1972326e37e8d/staging/src/k8s.io/api/core/v1/types.go#L4950" rel="nofollow noreferrer">SA struct</a></p>
