VK Cloud logo
Updated at April 23, 2024   12:00 PM

Creating an MLflow instance

This article provides examples of creating an MLflow instance using Terraform.

When creating the instance the following was used:

Before creating an instance

  1. Review the available resources and quotas for the region where you want to create the instance. Different regions may have different quotas configured.

    To increase your quotas, please contact technical support.

  2. Install Terraform and configure the provider if not already done.

  3. To go through this case, you need a provider version 0.6.0 or higher. Make sure that the provider version in the vkcs_provider.tf file is not lower. If the provider version is lower, update the provider.

1. Create an MLflow instance manifest file

In the example, the instance is created with the following configuration:

  • default region, availability zone — GZ1
  • disk type — SSD, size — 50 GB
  • data disk type — SSD, size — 60 GB

Create a Terraform configuration file named main.tf with the content:

resource "vkcs_mlplatform_mlflow" "mlflow" {  name              = "tf-example"  flavor_id         = data.vkcs_compute_flavor.basic.id  jh_instance_id    = vkcs_mlplatform_jupyterhub.jupyterhub.id  demo_mode         = true  availability_zone = "GZ1"  boot_volume = {    size        = 50    volume_type = "ceph-ssd"  }  data_volumes = [    {      size        = 60      volume_type = "ceph-ssd"    },  ]  networks = [    {      network_id = vkcs_networking_network.default.id    },  ]}

Here:

  • flavor_id — a VM type ID. You can specify the ID in the manifest or get it from the data source.

  • jh_instance_id — a JupyterHub instance ID for collaboration. You can use an existing instance or create a new one.

  • demo_mode — use true to store all data on the instance VM, use false to connect an S3 bucket with a Postgres database for storing data.

  • network_id — an ID of the network where the instance will be hosted. The instance can be hosted on an existing network or a new one. You can specify the ID in the manifest or get it from the data source or resource.

2. (Optional) Create a file describing the data source for the VM type

Create a Terraform configuration file named flavor.tf to describe the VM type:

data "vkcs_compute_flavor" "basic" {  name = "STD2-4-4"}

The specified VM type will be used to create an MLflow instance in your Terraform project.

3. (Optional) Create a file describing the synchronized JupyterHub instance

Create a Terraform configuration file named jh_instance.tf to describe the JupyterHub instance.

4. (Optional) Create a file describing the network infrastructure for the instance

Create a Terraform configuration file named network.tf with the network infrastructure description:

The data source example for a network existing in a project:

data "vkcs_networking_network" "default" {  name = "default"  sdn = "neutron"}

5. Create the necessary resources using Terraform

  1. Put the Terraform configuration files in one directory:

    • vkcs_provider.tf
    • main.tf
    • flavor.tf (if created)
    • jh_instance.tf(if created)
    • network.tf(if created)
  2. Open this directory.

  3. Make sure that the configuration files are correct and contain the required changes:

    terraform validate && terraform plan
  4. Apply the changes:

    terraform apply

    Enter yes to confirm.

  5. Wait for the operation to complete.

6. Check configuration application

Verify that the MLflow instance was successfully created:

  1. Go to your VK Cloud personal account.
  2. Go to ML PlatformInstances. Make sure your MLflow instance is created and active.

Delete unused resources

If you no longer need the Terraform resources, delete them:

  1. Open the directory that contains the Terraform configuration files.

  2. Run the command:

    terraform destroy

    Enter yes to confirm.

  3. Wait for the operation to complete.