Table of Contents

Connecting to ScaleOut in Google Cloud

The GcpBootstrapGatewayProvider class allows the Scaleout.Client library to connect to a ScaleOut cluster running on Google Cloud Compute instances using only GCP credentials to discover ScaleOut hosts.

Background

When a GcpBootstrapGatewayProvider instance is supplied to a GridConnection Connect or ConnectAsync call, your connection string can omit the bootstrapGateway parameter.

The GcpBootstrapGatewayProvider uses tag metadata that is present on your GPC compute instances to find ScaleOut hosts. This metadata is present whenever ScaleOut hosts are launched using the standard ScaleOut configuration template or the ScaleOut Management Console.

Prerequisites

The GcpBootstrapGatewayProvider is available in the Scaleout.Client.GoogleCloud NuGet package.

Procedure

  1. Add a reference to the Scaleout.Client.GoogleCloud NuGet package.

  2. Supply an GcpBootstrapGatewayProvider instance to the GridConnection when connecting.

using System;
using Scaleout.Client;
using Scaleout.Client.GoogleCloud;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.Compute.V1;

class Program
{
    static void Main(string[] args)
    {
        // Build GCP InstancesClient:
        InstancesClientBuilder clientBuilder = new InstancesClientBuilder();
        clientBuilder.Credential = new ServiceAccountCredential(
            new ServiceAccountCredential.Initializer("[email protected]")
            {
                Scopes = InstancesClient.DefaultScopes
            }.FromPrivateKey("-----BEGIN PRIVATE KEY..."));

        InstancesClient instancesClient = clientBuilder.Build();

        // Set up the provider:
        var gcpProv = new GcpBootstrapGatewayProvider(
                            instancesClient,
                            zone: "us-central1-a",
                            projectId: "example-deployments-123654",
                            gatewayType: GatewayType.Public,
                            scaleoutStoreName: "MyProdClusterCentral");

        // Connect to the ScaleOut service and build a cache:
        string connectionString = "useSecure=false;maxPoolsize=16";

        var conn = GridConnection.Connect(connectionString, gcpProv);
        var cacheBuilder = new CacheBuilder<string, string>("My Cache", conn);
        var cache = cacheBuilder.Build();
        //...
    }
}
  • The GcpBootstrapGatewayProvider constructor requires a scaleoutStoreName argument. All ScaleOut clusters in GCP are assigned names upon deployment--use the name you gave your cluster for this parameter.
  • The gatewayType parameter indicates whether the Scaleout.Client library should connect using your compute instance's public or private IP address. Use GatewayType.Private whenever possible to avoid data egress charges.