<p>I have a few kubernetes service accounts.</p>
<p>I want to login kubernetes dashboard.</p>
<pre><code>$kubectl get sa -n kubernetes-dashboard
NAME                   SECRETS   AGE
whitebear              0         9m37s
default                0         15m
kubernetes-dashboard   0         15m
</code></pre>
<p>However service account does'nt have token.</p>
<pre><code>$kubectl describe sa whitebear -n kubernetes-dashboard
Name:                whitebear
Namespace:           kubernetes-dashboard
Labels:              &lt;none&gt;
Annotations:         &lt;none&gt;
Image pull secrets:  &lt;none&gt;
Mountable secrets:   &lt;none&gt;
Tokens:              &lt;none&gt;
Events:              &lt;none&gt;
</code></pre>
<p>How can I create the token for account?</p>
<p>I am using docker for mac, local environement.</p>
<p>Thank you  very much.</p>
<p><strong>Solution</strong></p>
<p>thanks to @Sai Chandini Routhu!!</p>
<p>I made token and login successfuly</p>
<pre><code>kubectl create token default
</code></pre>
<p>However it was not enough to use dashboard</p>
<p>I make cluster role</p>
<pre><code>kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  namespace: default
  name: service-reader
rules:
- apiGroups: [&quot;&quot;] # &quot;&quot; indicates the core API group
  resources: [&quot;*&quot;]
  verbs: [&quot;*&quot;]
</code></pre>
<p>then bind this to my account.</p>
<pre><code>kubectl create clusterrolebinding service-reader-pod \
  --clusterrole=service-reader  \
  --serviceaccount=default:whitebear
</code></pre>
<p>Now I can login and operate dashboard!</p>

whitebear
<p>Tokens are not generated by default for ServiceAccounts since Kubernetes version 1.22. To create a long-lived ServiceAccount token in a Secret, see <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#manually-create-an-api-token-for-a-serviceaccount" rel="nofollow noreferrer">this documentation</a>, which says:</p>
<blockquote>
<p>If you want to obtain an API token for a ServiceAccount, you create a new Secret with a special annotation, <code>kubernetes.io/service-account.name</code>.</p>
<pre><code>kubectl apply -f - &lt;&lt;EOF
apiVersion: v1
kind: Secret
metadata:
  name: build-robot-secret
    annotations:
        kubernetes.io/service-account.name: build-robot
        type: kubernetes.io/service-account-token
EOF
</code></pre>
<p>If you view the Secret using:</p>
<pre><code>kubectl get secret/build-robot-secret -o yaml
</code></pre>
<p>you can see that the Secret now contains an API token for the &quot;build-robot&quot; ServiceAccount.</p>
</blockquote>
