Skip to main content

Set Up Elastigroup Commitments

Cloud service provider relevance: Azure Kubernetes.

Before you can enable commitments for your group, you need to:

Once you have your Azure credentials, you can enable commitments using either the Spot console or the Spot API.

Get the Azure Credentials Required to Connect Commitments to Spot Products

Follow the instructions below while referring to the Azure documentation:

App Registration

  1. Log in to your Azure account.

  2. Go to App registrations.

  3. Register a new application.

  4. Set the Redirect URI to https://spot.io

    note

    Spot requires this URI for authentication purposes.

  5. Copy the following IDs (you will need them later to connect to Spot):

    • Application (client) ID.
    • Directory (tenant) ID.

Certificates & Secrets

  1. In Azure, under the newly created application, click Certificates & secrets.
  2. Create a new client secret and set its expiration to 24 months.
  3. Copy the following details (you will need them later to connect to Spot):
    • Application secret expiration date.
    • Client secret value.

Connect Commitments to Spot Products

  1. Obtain the credentials from your Azure app. See Get your Azure credentials
note

If you have already configured commitments for either Ocean or Stateful Node, you already have your credentials for Elastigroup. Continue with Step 5 of this procedure.

  1. Set these credentials for the Azure tenant in Spot API-Accounts:

    • Application (client) ID - clientId
    • Client secret - clientSecret
    • Directory (tenant) ID - tenantId
    • Application secret expiration date - expirationDate
  2. Use the following Azure PowerShell script to assign the Reservation Reader / Savings Plan Reader roles at the tenant level:

    Import-Module Az.Accounts
    Import-Module Az.Resources

    Connect-AzAccount -Tenant {TENANT_ID}

    ## Assign Reservation Reader role
    New-AzRoleAssignment -Scope "/providers/Microsoft.Capacity" -ApplicationId {CLIENT_ID} -RoleDefinitionName "Reservations Reader"

    ## Assign Savings Plan Reader role (optional)
    New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -ApplicationId {CLIENT_ID} -RoleDefinitionName "Savings plan Reader"
  3. Use the following Azure PowerShell script to assign the Custom Reader role:

    # Replace with your principal's object ID (user, group, or service principal)
    $principalId = "<YOUR-PRINCIPAL-ID>"

    # Replace with your custom role name (from your JSON)
    $roleName = "Custom Reader Role"

    # Path to your custom role definition JSON file
    $roleFile = "custom-role.json"

    # Create the custom role
    az role definition create --role-definition $roleFile

    # Assign the custom role to all subscriptions
    $subscriptions = az account list --query "[].id" -o tsv
    foreach ($sub in $subscriptions) {
    Write-Host "Assigning role to subscription: $sub"
    az role assignment create `
    --assignee $principalId `
    --role $roleName `
    --scope "/subscriptions/$sub"
    }

    # For management groups, use the following:
    $managementGroups = az account management-group list --query "[].name" -o tsv
    foreach ($mg in $managementGroups) {
    Write-Host "Assigning '$roleName' to principal at MG: $mg"
    az role assignment create `
    --assignee $principalId `
    --role $roleName `
    --scope "/providers/Microsoft.Management/managementGroups/$mg"
    }
  4. In the Spot API, the shouldUtilizeCommitments attribute controls utilization commitments.

    When set to True (false is default), and there are free reserved instances / savings plans within the Azure account, Elastigroup will utilize them before launching spot instances.

    To enable the commitments feature:

    In the Spot API - Create Elastigroup or Update Elastigroup (under strategy), set the shouldUtilizeCommitments attribute to True.