Connecting to a Manta Cluster¶
The Cluster
object is used to control swarms, manage nodes, and access results and logs within the Manta platform. Below is an explanation of how to connect to a Manta cluster, both in unsecure and secure modes, using the connect
method.
Cluster Object API Documentation
For more information about the Cluster
object, refer to the Cluster
API Documentation.
Connecting to a Cluster
To connect to a Manta cluster, you use the Cluster.connect()
method, which creates a gRPC client for communication with the cluster manager.
Unsecured Connection¶
An unsecure connection can be established using the default host and ports without specifying a security token. This mode is suitable for development or testing in a controlled environment.
Example: Unsecured Connection
from manta import Cluster
# Connect to the cluster using default host and ports
cluster = Cluster.connect(host="localhost", port=50051)
# Check if the cluster is available
response = cluster.is_available()
print(response.message) # Output should indicate availability
Secured Connection¶
A secure connection requires a secured_token
, which is used for authentication when connecting to the cluster manager. This mode is recommended for production environments where security is a concern.
Example: Secured Connection
from manta import Cluster
# Connect securely using a secured token
secured_token = "YOUR_SECURED_TOKEN"
cluster = Cluster.connect(
host="localhost",
port=50051,
ca_port=50050,
secured_token=secured_token
)
# Check if the cluster is available
response = cluster.is_available()
print(response.message) # Output should indicate availability
Warning
Once you have been connected successfully to your cluster, the secured_token
should not be provided again. Instead, local certificate files will be used to securely access your cluster.