Access Rok from External Client¶
This guide contains instructions to access Rok in your Arrikto EKF deployment from an external client.
Overview
What You’ll Need¶
Choose one of the following options, depending on your desired environment.
- An Arrikto EKF deployment.
- An Arrikto EKF or MiniKF deployment with a working TokenRequest API for external clients.
- A token for external clients.
- An environment with access to Python3 and the Rok client.
Contact Arrikto
If you are using a custom image or environment, make sure it supports Python3 and contact the Arrikto Tech Team to provide you with the wheels to install the Rok client and CLI.
- An Arrikto EKF or MiniKF deployment with a working TokenRequest API for external clients.
- A token for external clients.
- An environment with access to Python3 and the Rok client.
Contact Arrikto
If you are using a custom image or environment, make sure it supports Python3 and contact the Arrikto Tech Team to provide you with the wheels to install the Rok client and CLI.
Procedure¶
Choose one of the following options, depending on your desired environment.
Select Snapshots from the left-side menu.
Select the namespace you wish to view using the Kubeflow Dashboard namespace selector.
Specify the namespace you wish to access:
jovyan@mynotebook-0:~$ export ROK_ACCOUNT="<ACCOUNT>"Replace
<ACCOUNT>
with the namespace, for example:jovyan@mynotebook-0:~$ export ROK_ACCOUNT="kubeflow-user"Note
Instead of specifying the namespace via an environment variable, you can alternatively include the
--account
command line argument during the invocation of the CLI.Specify the endpoint of your Kubernetes cluster:
jovyan@mynotebook-0:~$ export CLUSTER_ENDPOINT="<CLUSTER_ENDPOINT>"Replace
<CLUSTER_ENDPOINT>
with the endpoint of your Kubernetes cluster:jovyan@mynotebook-0:~$ export CLUSTER_ENDPOINT="https://arrikto-cluster.apps.example.com"Specify the endpoint of your cluster’s Rok API:
jovyan@mynotebook-0:~$ export ROK_URL="${CLUSTER_ENDPOINT?}/rok"Note
Instead of specifying the Rok API endpoint via an environment variable, you can alternatively include the
--url
command line argument during the invocation of the CLI.Specify the endpoint of your cluster’s Kubernetes API:
jovyan@mynotebook-0:~$ export KUBERNETES_SERVICE_HOST="${CLUSTER_ENDPOINT?}/kubernetes"Note
Instead of specifying the Kubernetes API endpoint via an environment variable, you can alternatively include the
--kubernetes-host
command line argument during the invocation of the CLI.Specify the location of the file holding your service account token in your file system:
jovyan@mynotebook-0:~$ export ROK_SA_TOKEN="file:<PATH_TO_TOKEN>"Replace
<PATH_TO_TOKEN>
with the file system path of the file containing your token, for example:jovyan@mynotebook-0:~$ export ROK_SA_TOKEN="file:/home/jovyan/kubeflow-user-rok-external.token"Note
Instead of specifying the location of the token in the file system via an environment variable, you can alternatively include the
--sa-token
command line argument during the invocation of the CLI.Use the
rok
CLI to interact with the Rok API server:jovyan@mynotebook-0:~$ rok account-show Account Information Account Name kubeflow-user Account UUID 1790af25-41c2-4e37-92cb-a2a3ee11fb9a Bucket Count 5 Version Bytes Used 482GiB Version Count 190 Bytes Used 100GiB Object Count 16 Created At 2021-10-05T16:11:56.764930+00:00jovyan@mynotebook-0:~$ rok bucket-list Name Objects Object Bytes Versions Version Bytes Type Paused auto-backup 2 20GiB 12 40GiB local False
Specify the location of the file holding your service account token in your file system:
jovyan@mynotebook-0:~$ export ROK_SA_TOKEN="file:<PATH_TO_TOKEN>"Replace
<PATH_TO_TOKEN>
with the file system path of the file containing your token, for example:jovyan@mynotebook-0:~$ export ROK_SA_TOKEN="file:/home/jovyan/kubeflow-user-rok-external.token"Create a new Python file and name it
access-rok.py
:jovyan@mynotebook-0:~$ touch access-rok.pyCopy and paste the following code inside
access-rok.py
:access-rok-external.py1 # Copyright © 2022 Arrikto Inc. All Rights Reserved. 2 3 """Access the Rok API.""" 4-17 4 5 from rok_gw_client import RokClient 6 7 NAMESPACE = "mynamespace" 8 CLUSTER_ENDPOINT = "https://myendpoint.com" 9 10 # Initialize the Rok client 11 URL = "%s/rok" % CLUSTER_ENDPOINT 12 KUBERNETES_HOST = "%s/kubernetes" % CLUSTER_ENDPOINT 13 client = RokClient(account=NAMESPACE, url=URL, 14 kubernetes_host=KUBERNETES_HOST) 15 16 17 # Access the Rok API 18 account_info, buckets = client.bucket_list() 19 print("Successfully retrieved %d Rok bucket(s) in namespace '%s'" 20 % (len(buckets), NAMESPACE)) Alternatively, download the Python file above in your execution environment.
Update the following fields in the file:
Set NAMESPACE to the Kubernetes namespace you wish to access.
Set CLUSTER_ENDPOINT to the endpoint of your Kubernetes cluster.
access-rok-external-updated.py1 # Copyright © 2022 Arrikto Inc. All Rights Reserved. 2 3 """Access the Rok API.""" 4 5 from rok_gw_client import RokClient 6 7 - NAMESPACE = "mynamespace" 8 - CLUSTER_ENDPOINT = "https://myendpoint.com" 9 + NAMESPACE = "kubeflow-user" 10 + CLUSTER_ENDPOINT = "https://arrikto-cluster.apps.example.com" 11 12 # Initialize the Rok client 13 URL = "%s/rok" % CLUSTER_ENDPOINT 14-19 14 KUBERNETES_HOST = "%s/kubernetes" % CLUSTER_ENDPOINT 15 client = RokClient(account=NAMESPACE, url=URL, 16 kubernetes_host=KUBERNETES_HOST) 17 18 19 # Access the Rok API 20 account_info, buckets = client.bucket_list() 21 print("Successfully retrieved %d Rok bucket(s) in namespace '%s'" 22 % (len(buckets), NAMESPACE))
Run the script using Python 3:
jovyan@mynotebook-0:~$ python3 access-rok.py Successfully retrieved 3 Rok bucket(s) in namespace 'kubeflow-user'