This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.8.4. Using a service account’s credentials externally
You can distribute a service account’s token to external applications that must authenticate to the API.
In order to pull an image, the authenticated user must have get
rights on the requested imagestreams/layers
. In order to push an image, the authenticated user must have update
rights on the requested imagestreams/layers
.
By default, all service accounts in a project have rights to pull any image in the same project, and the builder service account has rights to push any image in the same project.
Procedure
View the service account’s API token:
oc describe secret <secret_name>
$ oc describe secret <secret_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example:
oc describe secret robot-token-uzkbh -n top-secret
$ oc describe secret robot-token-uzkbh -n top-secret
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Log in using the token that you obtained:
oc login --token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
$ oc login --token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Logged into "https://server:8443" as "system:serviceaccount:top-secret:robot" using the token provided. You don't have any projects. You can try to create a new project, by running $ oc new-project <projectname>
Logged into "https://server:8443" as "system:serviceaccount:top-secret:robot" using the token provided. You don't have any projects. You can try to create a new project, by running $ oc new-project <projectname>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that you logged in as the service account:
oc whoami
$ oc whoami
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
system:serviceaccount:top-secret:robot
system:serviceaccount:top-secret:robot
Copy to Clipboard Copied! Toggle word wrap Toggle overflow