public class TcpDiscoveryKubernetesIpFinder extends TcpDiscoveryIpFinderAdapter
The implementation is based on a distinct Kubernetes service that has to be created and should be deployed prior
Ignite nodes startup. The service will maintain a list of all endpoints (internal IP addresses) of all containerized
Ignite pods running so far. The name of the service must be equal to setServiceName(String)
which is
`ignite` by default.
As for Ignite pods, it's recommended to label them in such a way that the service will use the label in its selector configuration excluding endpoints of irrelevant Kubernetes pods running in parallel.
The IP finder, in its turn, will call this service to retrieve Ignite pods IP addresses. The port will be
either the one that is set with TcpDiscoverySpi.setLocalPort(int)
or TcpDiscoverySpi.DFLT_PORT
.
Make sure that all Ignite pods occupy a similar discovery port, otherwise they will not be able to discover each
other using this IP finder.
setServiceName(String)
)setNamespace(String)
setMasterUrl(String)
)setAccountToken(String)
Both registerAddresses(Collection)
and unregisterAddresses(Collection)
have no effect.
Note, this IP finder is only workable when it used in Kubernetes environment.
Choose another implementation of TcpDiscoveryIpFinder
for local
or home network tests.
ignite
Constructor and Description |
---|
TcpDiscoveryKubernetesIpFinder()
Creates an instance of Kubernetes IP finder.
|
Modifier and Type | Method and Description |
---|---|
Collection<InetSocketAddress> |
getRegisteredAddresses()
Gets all addresses registered in this finder.
|
void |
registerAddresses(Collection<InetSocketAddress> addrs)
Registers new addresses.
|
void |
setAccountToken(String accountToken)
Specifies the path to the service token file.
|
void |
setMasterUrl(String master)
Sets the host name of the Kubernetes API server.
|
void |
setNamespace(String namespace)
Sets the namespace the Kubernetes service belongs to.
|
void |
setServiceName(String service)
Sets the name of Kubernetes service for Ignite pods' IP addresses lookup.
|
void |
unregisterAddresses(Collection<InetSocketAddress> addrs)
Unregisters provided addresses.
|
close, discoveryClientMode, initializeLocalAddresses, isShared, onSpiContextDestroyed, onSpiContextInitialized, setShared, spiContext, toString
public TcpDiscoveryKubernetesIpFinder()
public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException
null
.IgniteSpiException
- In case of error.public void registerAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException
Implementation should accept duplicates quietly, but should not register address if it is already registered.
addrs
- Addresses to register. Not null
and not empty.IgniteSpiException
- In case of error.public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException
Implementation should accept addresses that are currently not registered quietly (just no-op).
addrs
- Addresses to unregister. Not null
and not empty.IgniteSpiException
- In case of error.public void setServiceName(String service)
service
- Kubernetes service name for IP addresses lookup. If it's not set then 'ignite' is used by default.public void setNamespace(String namespace)
namespace
- The Kubernetes service namespace for IP addresses lookup.public void setMasterUrl(String master)
master
- The host name of the Kubernetes API server.public void setAccountToken(String accountToken)
accountToken
- The path to the service token file.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.2 Release Date : February 6 2019