Skip to content

Conversation

agrare
Copy link
Member

@agrare agrare commented Sep 9, 2025

Service Account Tokens are no longer automatically generated when the service account gets created, oc sa new-token is deprecated, and oc create token has a limited duration (even if it can be years) and has not well documented default.

https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#manually-create-a-long-lived-api-token-for-a-serviceaccount describes how to create a long-lived service account token which matches what oc sa new-token would generate.

type: kubernetes.io/service-account-token
EOF
# oc describe sa -n $project_name $service_account_name
Copy link
Member Author

@agrare agrare Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE I dropped the leading # from here because the examples that this is included into do not have that (e.g. oc policy add-role-to-user -n $project_name admin -z $service_account_name) and it also made bash markdown think this was a comment

...
Tokens: management-admin-token-0f3fh
management-admin-token-q7a87
oc describe secret -n $project_name $service_account_name-secret
Copy link
Member

@Fryguy Fryguy Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, does it make sense to do something like the following to get directly at the token?

oc describe secret -n $project_name -o json $service_account_name-secret | jq -r .data.token

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-o json isn't valid for oc describe but we could use oc get

This would require people have jq installed which I don't think we require anywhere else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yes oc get

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ibm cloud docs have jq even so it feels so ubiquitous to me now, but yeah, maybe we err on the side of not having jq.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we go, oc get secret -o template $service_account_name-secret -n $project_name --template={{.data.token}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah I forgot you can do that - that's fantastic

@agrare agrare force-pushed the update_openshift_token_instructions branch 3 times, most recently from 1524f42 to 4c2d8a5 Compare September 9, 2025 17:33
====
token: eyJhbGciOiJSUzI1NiI...
```bash
oc get secret -o template $service_account_name-secret -n $project_name --template={{.data.token}
Copy link
Member

@Fryguy Fryguy Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think there's a typo in the template. Also, I think it's clearer if the template lives next to the -o template. Also typically you put the namespace first, then other options, then the object last.

So something like:

Suggested change
oc get secret -o template $service_account_name-secret -n $project_name --template={{.data.token}
oc get secret -n $project_name -o template --template={{.data.token}} $service_account_name-secret

Copy link
Member Author

@agrare agrare Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah missed last character while copy&pasting, fixed
NOTE I kept the namespace+name together instead of splitting them up with the -o template --template in the middle but I did keep the -o template --template together

@agrare agrare force-pushed the update_openshift_token_instructions branch from 4c2d8a5 to dc7504c Compare September 9, 2025 18:39
@Fryguy Fryguy merged commit e763a02 into ManageIQ:master Sep 9, 2025
2 checks passed
@Fryguy
Copy link
Member

Fryguy commented Sep 9, 2025

Backported to spassky in commit a2d1ec3.

commit a2d1ec361e96128c8c2782b55afbe376d01ffedf
Author: Jason Frey <[email protected]>
Date:   Tue Sep 9 16:11:06 2025 -0400

    Merge pull request #1864 from agrare/update_openshift_token_instructions
    
    Update openshift management token instructions
    
    (cherry picked from commit e763a02a990437eaf163b131332be46f6e2aaec9)

Fryguy added a commit that referenced this pull request Sep 9, 2025
Update openshift management token instructions

(cherry picked from commit e763a02)
@agrare agrare deleted the update_openshift_token_instructions branch September 9, 2025 20:18
github-actions bot pushed a commit to ManageIQ/manageiq.github.io that referenced this pull request Sep 9, 2025
github-actions bot pushed a commit to ManageIQ/manageiq.github.io that referenced this pull request Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants