<p>This question concerns kubernetes v1.24 and up</p>
<p>So I can create tokens for service accounts with</p>
<pre><code>kubectl create token myserviceaccount
</code></pre>
<p>The created token works and serves the purpose, but what I find confusing is that when I <code>kubectl get sa</code> SECRETS field of myserviceaccount is still 0. The token doesn't appear in <code>kubectl get secrets</code> either.</p>
<p>I've also seen that I can pass <code>--bound-object-kind</code> and <code>--bound-object-name</code> to <code>kubectl create token</code> but this doesn't seem to do anything (visible) either...</p>
<p>Is there a way to see created token? And what is the purpose of --bound.. flags?</p>

golder3
<p>Thanks to the <a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/#service-account-tokens" rel="nofollow noreferrer">docs link</a> I've stumbled upon today (I don't know how I've missed it when asking the question because I've spent quite some time browsing through the docs...) I found the information I was looking for. I feel like providing this answer because I find v1d3rm3's answer incomplete and not fully accurate.</p>
<p>The kubernetes docs confirm v1d3rm3's claim (which is btw the key to answering my question):</p>
<blockquote>
<p>The created token is a signed JSON Web Token (JWT).</p>
</blockquote>
<p>Since the token is JWT token the server can verify if it has signed it, hence no need to store it. JWTs expiry time is set not because the token is not associated with an object (it actually is, as we'll see below) but because the server has no way of invalidating a token (it would actually need to keep track of invalidated tokens because tokens aren't stored anywhere and any token with good signature is valid). To reduce the damage if a token gets stolen there is an expiry time.</p>
<p>Signed JWT token contains all the necessary information inside of it.</p>
<p>The decoded token (created with <code>kubectl create token test-sa</code> where test-sa is service account name) looks like this:</p>
<pre><code>{
  &quot;aud&quot;: [
    &quot;https://kubernetes.default.svc.cluster.local&quot;
  ],
  &quot;exp&quot;: 1666712616,
  &quot;iat&quot;: 1666709016,
  &quot;iss&quot;: &quot;https://kubernetes.default.svc.cluster.local&quot;,
  &quot;kubernetes.io&quot;: {
    &quot;namespace&quot;: &quot;default&quot;,
    &quot;serviceaccount&quot;: {
      &quot;name&quot;: &quot;test-sa&quot;,
      &quot;uid&quot;: &quot;dccf5808-b29b-49da-84bd-9b57f4efdc0b&quot;
    }
  },
  &quot;nbf&quot;: 1666709016,
  &quot;sub&quot;: &quot;system:serviceaccount:default:test-sa&quot;
}
</code></pre>
<p>Contrary to v1d3rm3 answer, <strong>This token IS associated with a service account automatically</strong>, as the kubernets docs link confirm and as we can also see from the token content above.</p>
<p>Suppose I have a secret I want to bind my token to (for example <code>kubectl create token test-sa --bound-kind Secret --bound-name my-secret</code> where test-sa is service account name and my-secret is the secret I'm binding token to), the decoded token will look like this:</p>
<pre><code>{
  &quot;aud&quot;: [
    &quot;https://kubernetes.default.svc.cluster.local&quot;
  ],
  &quot;exp&quot;: 1666712848,
  &quot;iat&quot;: 1666709248,
  &quot;iss&quot;: &quot;https://kubernetes.default.svc.cluster.local&quot;,
  &quot;kubernetes.io&quot;: {
    &quot;namespace&quot;: &quot;default&quot;,
    &quot;secret&quot;: {
      &quot;name&quot;: &quot;my-secret&quot;,
      &quot;uid&quot;: &quot;2a44872f-1c1c-4f18-8214-884db5f351f2&quot;
    },
    &quot;serviceaccount&quot;: {
      &quot;name&quot;: &quot;test-sa&quot;,
      &quot;uid&quot;: &quot;dccf5808-b29b-49da-84bd-9b57f4efdc0b&quot;
    }
  },
  &quot;nbf&quot;: 1666709248,
  &quot;sub&quot;: &quot;system:serviceaccount:default:test-sa&quot;
}
</code></pre>
<p>Notice that binding happens inside the token, under <strong>kubernetes.io</strong> key and if you describe my-secret you will still not see the token. So the --bound-... flags weren't visibly (from secret object) doing anything because binding happens inside the token itself...</p>
<p>Instead of decoding JWT tokens, we can also see details in TokenRequest object with</p>
<pre><code>kubectl create token test-sa -o yaml
</code></pre>
