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

Creating a JupyterHub instance

This article provides examples of creating a JupyterHub 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 a JupyterHub instance manifest file

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

  • default region, availability zone — GZ1
  • boot disk type — SSD
  • username — admin, password — Password!
  • data disk type — SSD, sizes — 60 and 70 GB

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

resource "vkcs_mlplatform_jupyterhub" "jupyterhub" {  name              = "tf-example"  admin_name        = "admin"  admin_password    = "Password!"  flavor_id         = data.vkcs_compute_flavor.basic.id  availability_zone = "GZ1"  boot_volume = {    volume_type = "ceph-ssd"  }  data_volumes = [    {      size        = 60      volume_type = "ceph-ssd"    },    {      size        = 70      volume_type = "ceph-ssd"    }  ]  networks = [    {      network_id = data.vkcs_networking_network.default.id    },  ]}

Here:

  • admin_password — the JupyterHub instance administrator password.

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

  • 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 a JupyterHub instance in your Terraform project.

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

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

Example data source for a network existing in your project:

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

4. Create the necessary resources using Terraform

  1. Put the Terraform configuration files in one directory:

    • vkcs_provider.tf
    • main.tf
    • flavor.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.

5. Check configuration application

Verify that the JupyterHub instance was successfully created:

  1. Go to your VK Cloud personal account.
  2. Go to ML PlatformInstances. Make sure your JupyterHub 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.