Reputation: 475
I am trying to use ECS to run a server cluster and it uses hazelcast. I have searched online and also asked Amazon, but I cannot find the instructions on how to set up hazelcast in that case. Can someone please share it? Thank you.
Upvotes: 0
Views: 1269
Reputation: 31
This is DEFINITELY possible as I do it in test and production systems currently. There are a couple of tricks to get it to work. First, your networking has to be correct. Port forward any port of your choice to port 5701 in the container. Next, get the instance IP located at http://169.254.169.254/latest/meta-data/local-ipv4
and set this on the property "hazelcast.local.localAddress
". Next, set the property "hazelcast.local.publicAddress
" to this IP and the port you forwarded to 5701 in step 1. For example if to instance IP is 172.1.2.3
and you forwarded port 5702->5701 in step 1 then set the property to "172.1.2.3:5702
". For good measure also set this ip/port pair on the HazelcastConfig.getNetworkConfig().setPublicAddress(ipAndPort);
The final strp is to ensure EC2 auto discovery works by setting the appropriate AWS values in the network config. I should note these settings are currently running with Hazelcast 3.10.5 with 3.12.3 in testing.
Upvotes: -1
Reputation: 36095
I'm just evaluating this situation as I'm considering Hazelcast for our ECS deployment, so I haven't tried this but here's what I found:
It seems to be possible if you are using a fixed hostPort
only, thus obviously only one container per host is possible. This way it everyting should work as with regular EC2 deployments.
For ECS it should be possible to write a custom discovery strategy that uses the network bindings from DescribeTasks API method to discover the dynamic port.
Upvotes: 0
Reputation: 31
This solution works well if there is a single container; however, running multiple containers is problematic as ECS docker containers all have the same IP address so the member is not unique when you try to launch a second container. Someone posted here stating docker needed to be run with the --net=host option
; however, I don't think you can explicitly do that using ECS task definitions.
Upvotes: 1
Reputation: 493
You can use below samples.
Sample project: https://github.com/hazelcast/hazelcast-code-samples/tree/master/hazelcast-integration/amazon-ec2-vagrant-chef
Network config: https://github.com/hazelcast/hazelcast-code-samples/tree/master/network-configuration/aws
Upvotes: 1