Step 2: Generate multitenant tokens in OCP on bare metal
Summary and Key concepts
Summary
This article outlines the steps to generate and manage authentication tokens for Portworx using the pxctl
command-line tool. It explains how to retrieve the shared secret stored in a Kubernetes secret, create tokens for storage administrators and tenants, and store those tokens securely in Kubernetes. These tokens are crucial for securing communication between Kubernetes and Portworx, ensuring that only authorized users can access storage resources. The article also covers how to manage tenant accounts by namespaces and how to prevent specific Kubernetes resources, like secrets, from being backed up by tools like Stork and PX-Backup.
Kubernetes Concepts
- Secret: Used to store sensitive data, such as authentication tokens, securely.
- Namespace: Used to isolate tenant resources and store tenant-specific tokens.
- kubectl: Command-line tool used to interact with Kubernetes clusters, including managing secrets and tokens.
- Annotation: Used to store metadata on Kubernetes objects, such as preventing certain resources from being backed up.
Portworx Concepts
- pxctl: The Portworx command-line tool used for managing clusters and generating authentication tokens.
- PX-Security: The security framework that secures communication between Kubernetes and Portworx.
- Administrator Role: A role that provides full access to manage Portworx resources, similar to the root user in Linux.
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=$(oc -n kube-system get \
secret px-shared-secret -o json \
| jq -r '.data."shared-secret"' \
| base64 -d)