Update ClusterClientDiscovery Akka.Hosting documentation #7310
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Contact Auto-Discovery Using Akka.Discovery
Note
This feature can only be used with:
This feature is added in Akka.NET 1.5.27. Instead of watching for actor termination manually, you can leverage Akka.Discovery to discover cluster client contact points inside a dynamic environment such as Kubernetes, AWS, or anywhere else with Azure Table
Contact Auto-Discovery Setup Using Akka.Hosting
Cluster client discovery API has been added in
Akka.Cluster.Hosting
v1.5.27. You can use the.WithClusterClientDiscovery()
extension method to use the cluster client initial contact auto discovery feature.Example: Setting Up Contact Auto-Discovery With Akka.Discovery.KubernetesApi
On your cluster client node side, these are the code you'll need to implement:
On the YAML side, you will need to change the Receptionist YAML and add a new metadata label to tag the pods:
If you're not using ClusterBootstrap on the Receptionist side, you have to start Akka.Management. Skip this step if you're using ClusterBootstrap:
Example: Setting Up Contact Auto-Discovery With Akka.Discovery.Azure
On your cluster client node side, these are the code you'll need to implement:
On the cluster client receptionist side, you will need to implement these code:
Contact Auto-Discovery Setup Using Hocon Configuration
The HOCON configuration to set these are:
To enable contact auto-discovery, you will need to:
akka.cluster.client.use-initial-contacts-discovery
to true.akka.cluster.client.discovery.service-name
that matches the service name of the Akka.Discovery extension that you used:pod-label-selector
HOCON setting or theKubernetesDiscoveryOptions.PodLabelSelector
options property.akka.discovery.aws-api-ec2-tag-based.tag-key
HOCON setting or the Akka.HostingEc2ServiceDiscoveryOptions.TagKey
options property.akka.discovery.aws-api-ecs.tags
HOCON setting or the Akka.HostingEcsServiceDiscoveryOptions.Tags
options property.service-name
HOCON setting or theAkkaDiscoveryOptions.ServiceName
options property.akka.cluster.client.discovery.method
to a valid discovery method name listed underakka.discovery
.akka.cluster.client.discovery.actor-system-name
to the target cluster ActorSystem name.akka.cluster.client.discovery,port-name
if the discovery extension that you're using depends on port names.akka.cluster.client.discovery.receptionist-name
if you're using a non-default receptionist name.Using Akka.Discovery For Both Akka.Cluster.Tools.Client And Akka.Management.Cluster.Bootstrap
If you need to use Akka.Discovery with both ClusterClient AND ClusterBootstrap, you will have to make sure that you have TWO different Akka.Discovery settings living side-by-side under the
akka.discovery
HOCON setting section.Akka.Discovery.KubernetesApi Example
In your YAML file:
Make sure that you tag the instances that will run the cluster client receptionists with an extra tag. If your ClusterBootstrap is tagged with the YAML value
metadata.labels.app: cluster
, then you will need to add another tag to the instances that runs the Receptionists, e.g.metadata.labels.contact: cluster-client
like so:Make sure you name the Akka.Management port
In your cluster client Akka.NET node HOCON settings:
akka.discovery.kubernetes-api
HOCON section and paste it above or under the original settings. You can also copy the value from hereakka.discovery.kubernetes-api-cluster-client
. The key name does not matter, what matters is that the name does not collide with any other setting section name underakka.discovery
.akka.discovery.kubernetes-api-cluster-client.pod-label-selector
to "contact={0}" to match what we have in the YAML file.akka.cluster.client.discovery.service-name
to "cluster-client" to match what we have in the YAML file.akka.cluster.client.discovery.port-name
value to "management" to match what we have in the YAML file.akka.discovery.method
HOCON value to "kubernetes-api", this is the discovery extension that will be used by ClusterBootstrap.akka.cluster.client.discovery.method
value from "<method>" to "kubernetes-api-cluster-client", this is the discovery extension that will be used by ClusterClient. If not set, this will default to the value set inakka.discovery.method
, which is NOT what we want.Akka.Discovery.Azure Example
In your cluster receptionist Akka.NET node HOCON settings:
Copy the
akka.discovery.azure
HOCON section and paste it above or under the original settings. You can also copy the value from hereRename the HOCON section to
akka.discovery.azure-cluster-client
. The key name does not matter, what matters is that the name does not collide with any other setting section name underakka.discovery
.Change
akka.discovery.azure-cluster-client.public-port
to the management port of the Akka.NET node.Change
akka.discovery.azure-cluster-client.service-name
to "cluster-client". The name does not matter, what matters is that this name HAS to match the service name we'll be using inakka.cluster.client.discovery.service-name
.[OPTIONAL] change
akka.discovery.azure-cluster-client.table-name
toakkaclusterreceptionists
to separate the discovery table from ClusterBootstrap entries.Make sure that you start the discovery extension in the receptionist side. This needs to be done because the extension is responsible for updating the Azure table.
In your cluster client Akka.NET node HOCON settings:
akka.cluster.client.discovery.service-name
to "cluster-client" to match what we have in the receptionist node HOCON file.akka.discovery.method
HOCON value to "azure", this is the discovery extension that will be used by ClusterBootstrap.akka.cluster.client.discovery.method
value from "<method>" to "azure-cluster-client", this is the discovery extension that will be used by ClusterClient. If not set, this will default to the value set inakka.discovery.method
, which is NOT what we want.akka.discovery.azure-cluster-client.table-name
to match the table name with the receptionist side, it wasakkaclusterreceptionists
in our example aboveakka.cluster.client.discovery.service-name
to "cluster-client" to match what we have in the receptionist node HOCON file.akka.discovery.method
HOCON value to "azure".akka.cluster.client.discovery.method
value from "<method>" to "azure", this is the discovery extension that will be used by ClusterClient. If not set, this will default to the value set inakka.discovery.method
, which will be the same.akka.discovery.azure-cluster-client.table-name
to match the table name with the receptionist side, it wasakkaclusterreceptionists
in our example above.