Create a Batch login node

The batch-login-node module lets you create a virtual machine (VM) instance that acts as a login node. Use this login node to test and submit Google Cloud Batch jobs. We recommend that you use this module alongside the batch-job-template module.

To help ensure that your login node exactly matches the environment of your batch workload, the batch-login-node module requires a reference to a batch-job-template module in your blueprint by using the use keyword. By defining the job template first, the login node can automatically inherit the following settings:

  • Network and VPC: Connects to the exact same Virtual Private Cloud network and subnetwork as your job template.
  • Machine configuration: Replicates the same machine type, base image, and mounted file systems as your job template.
  • Initialization: Runs the identical startup script to help ensure that all required software is installed.

The module automatically names your login node VM instance by using the format <deployment_name>-<group_name>-login-001. Once the login node is running, you can connect to it to test your environment, modify your job template, and submit your jobs to the fully managed Batch service.

For the complete list of inputs and outputs for this module, see the batch-login-node module page in the Cluster Toolkit GitHub repository.

Before you begin

Before you begin, verify that you meet the following requirements:

  • You have installed and configured Cluster Toolkit. For installation instructions, see Set up Cluster Toolkit.
  • You have an existing cluster blueprint. You can use and modify an existing blueprint or create one from scratch. For a working example of a blueprint configured for Batch, see the examples/batch.yaml file. For more information about creating and customizing blueprints, see Cluster blueprint.
  • To view a complete list of blueprints that support Batch, go to the Cluster blueprint catalog page, click the Select scheduler menu and then select Batch.
  • The batch-login-node module does not create a full active cluster or execute the workload. It only provisions a virtual machine (VM) instance that acts as a login node for testing and submitting jobs.

Required roles

To get the permissions that you need to deploy the login node VM instance, ask your administrator to grant you the following IAM roles on your project:

For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

To ensure that the VM service account has the necessary permissions to submit Google Cloud Batch jobs from the login node, ask your administrator to grant the Batch Job Administrator (roles/batch.jobsAdmin) IAM role to the VM service account on your project.

For more information about granting roles, see Manage access to projects, folders, and organizations.

Your administrator might also be able to give the VM service account the required permissions through custom roles or other predefined roles.

Alternatively, you can grant this role to the service account by executing a command in the gcloud CLI. The following command grants the Batch Job Administrator role to the service account:

gcloud projects add-iam-policy-binding PROJECT_ID \
  --member=serviceAccount:SERVICE_ACCOUNT_EMAIL \
  --role=roles/batch.jobsAdmin

Create a Batch login node

The following example demonstrates how to configure the batch-login-node module. To view the location of the generated file and the instructions for accessing the login node and submitting jobs, refer to the instructions output.

- id: batch-job
  source: modules/scheduler/batch-job-template
  ...

- id: batch-login
  source: modules/scheduler/batch-login-node
  use: [batch-job]
  outputs: [instructions]

If the Google Cloud Batch CLI is not available, the gcloud components update command updates the gcloud CLI. Alternatively, you can use an image that contains a more recent version of the gcloud CLI.

What's next

  • For the complete list of inputs and outputs for this module, see the batch-login-node module page in the Cluster Toolkit GitHub repository.