Connecting to a YTsaurus cluster
You can connect to a YTsaurus cluster:
- From Yandex Cloud VMs.
- Via the internet over HTTPS.
Examples of connection strings
The examples for Linux were tested in the following environment:
- Yandex Cloud VM running Ubuntu 20.04 LTS.
- Bash:
5.0.16. - Python:
3.8.2; pip3:20.0.2.
Bash
Before connecting:
-
If you do not have the Yandex Cloud CLI yet, install and initialize it.
-
Install the YTsaurus CLI according to the instructions
. -
Install the dependencies:
sudo apt update && sudo apt install -y python3 python3-pip && \ pip3 install ytsaurus-client-yc-auth
-
Get the access configuration file using the following YC CLI command:
yc managed-ytsaurus cluster get-configuration <cluster_name_or_ID> --privateConfiguration file example
{ auth_class = { module_name = "yc_managed_ytsaurus_auth"; class_name = "IamTokenAuth"; }; proxy = { url = "http://hp.<YTsaurus_cluster_ID>.ytsaurus.mdb.yandexcloud.net:32100"; network_name = "external"; http_proxy_role = "default"; } }The configuration file will be saved to
~/.yt/config.You can get the cluster ID with the list of clusters in the folder.
-
Run a request for the root directory contents list:
yt list /
-
Get the access configuration file using the following YC CLI command:
yc managed-ytsaurus cluster get-configuration <cluster_name_or_ID>Configuration file example
{ auth_class = { module_name = "yc_managed_ytsaurus_auth"; class_name = "IamTokenAuth"; }; proxy = { url = "https://proxy.<YTsaurus_cluster_ID>.ytsaurus.yandexcloud.net"; enable_proxy_discovery = %false; } }The configuration file will be saved to
~/.yt/config.You can get the cluster ID with the list of clusters in the folder.
-
Run a request for the root directory contents list:
yt list /
Python
Before connecting:
-
If you do not have the Yandex Cloud CLI yet, install and initialize it.
-
Install the YTsaurus CLI according to the instructions
. -
Install the dependencies:
sudo apt update && sudo apt install -y python3 python3-pip && \ pip3 install ytsaurus-client-yc-auth
-
Code example:
connect.pyimport yt.wrapper as yt from yc_managed_ytsaurus_auth import with_iam_token_auth client = yt.YtClient( proxy="http://hp.<YTsaurus_cluster_ID>.ytsaurus.mdb.yandexcloud.net:32100", config=with_iam_token_auth( config={"proxy": {"network_name": "external", "http_proxy_role": "default"}} ), ) client.list("/") -
Connecting:
python3 connect.py
-
Code example:
connect.pyimport yt.wrapper as yt from yc_managed_ytsaurus_auth import with_iam_token_auth client = yt.YtClient( proxy="https://proxy.<YTsaurus_cluster_ID>.ytsaurus.yandexcloud.net", config=with_iam_token_auth(config={"proxy": {"enable_proxy_discovery": False}}), ) client.list("/") -
Connecting:
python3 connect.py