Step 2: Generate multitenant tokens in airgapped EKS
Now that the system is up and running, you can create tokens.
If you want to create your own application to generate tokens, you can base it on our open source golang example application openstorage-sdk-auth
SSH to one of your nodes and follow the steps below to use pxctl to generate tokens:
Fetching the shared secret
Fetch the shared secret, which is stored in a
Kubernetes secret. Below, the secret is saved in the
environment variable $PORTWORX_AUTH_SHARED_SECRET.
Get the shared secret:
PORTWORX_AUTH_SHARED_SECRET=$(kubectl -n kube-system get \
secret px-shared-secret -o json \
| jq -r '.data."shared-secret"' \
| base64 -d)
Generate a storage admin token
pxctl uses YAML configuration files to create tokens.
You must create a token for the storage admin used for pxctl to manage Portworx
(like root in Linux)
-
Create a file called
admin.yamlwith the the following:name: Storage Administrator
email: the email of the storage admin
sub: ${uuid} or email of the storage admin
roles: ["system.admin"]
groups: ["*"] -
Create a token for the storage administrator using
admin.yaml. In the example below:-
The issuer matches the setting in the Portworx manifest of
portworx.comas the set value for-jwt-issuer. -
The example sets the duration of the token to one year -- You may want to adjust it to a much shorter duration if you plan on refreshing the token often.
ADMIN_TOKEN=$(/opt/pwx/bin/pxctl auth token generate \
--auth-config=admin.yaml \
--issuer=portworx.com \
--shared-secret=$PORTWORX_AUTH_SHARED_SECRET \
--token-duration=1y)
-
-
Save the storage admin token in the
pxctlcontext:/opt/pwx/bin/pxctl context create admin --token=$ADMIN_TOKEN