Nodes discovery on Google Compute Engine is usually proven to be more challenging. Google Cloud, just like most of the other virtual environments, has the following limitations:
- Multicast is disabled.
- TCP addresses change every time a new image is started.
Although you can use TCP-based discovery in the absence of the Multicast, you still have to deal with constantly changing IP addresses and constantly updating the configuration. This creates a major inconvenience and makes configurations based on static IPs virtually unusable in such environments.
To mitigate constantly changing IP addresses problem, Ignite supports automatic node discovery by utilizing Google Cloud Storage store via TcpDiscoveryGoogleStorageIpFinder. On startup each node registers its IP address in the storage. This way other nodes can try to connect to any address stored in the storage and initiate automatic grid node discovery.
Such approach allows to create your configuration once and reuse it for all Google Compute Engine instances.
Here is an example of how to configure Google Cloud Storage based IP finder:
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
...
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder">
<property name="projectName" ref="YOUR_GOOGLE_PLATFORM_PROJECT_NAME"/>
<property name="bucketName" value="YOUR_BUCKET_NAME"/>
<property name="serviceAccountId" value="YOUR_SERVICE_ACCOUNT_ID"/>
<property name="serviceAccountP12FilePath" value="PATH_TO_YOUR_PKCS12_KEY"/>
</bean>
</property>
</bean>
</property>
</bean>
TcpDiscoverySpi spi = new TcpDiscoverySpi();
TcpDiscoveryGoogleStorageIpFinder ipFinder = new TcpDiscoveryGoogleStorageIpFinder();
ipFinder.setServiceAccountId(yourServiceAccountId);
ipFinder.setServiceAccountP12FilePath(pathToYourP12Key);
ipFinder.setProjectName(yourGoogleClourPlatformProjectName);
// Bucket name must be unique across the whole Google Cloud Platform.
ipFinder.setBucketName("your_bucket_name");
spi.setIpFinder(ipFinder);
IgniteConfiguration cfg = new IgniteConfiguration();
// Override default discovery SPI.
cfg.setDiscoverySpi(spi);
// Start Ignite node.
Ignition.start(cfg);
Refer to Cluster Configuration for more information on various cluster configuration properties.