This module creates the following resources required to provision Hazelcast
- Deployment resource
- Service resource
- Install Terraform from here
- Allow terraform to access the kubernetes master using by following https://www.terraform.io/docs/providers/kubernetes/index.html
Note: Change the inputs to match your requirement.
module "hazelcast" {
source = "<module_path>"
name = "customer-orders"
hazelcast_version = "3.12.7"
cluster_members = 3
cpu = "500m"
memory = "200Mi"
labels = {
created-by = "terraform"
purpose = "example"
}
}
Try out the module functionality with the example defined https://github.com/everest-engineering/terraform-kubernetes-hazelcast/blob/master/examples/main.tf
- Switch to examples directory
cd examples
- Initialize Terraform to download required plugins
terraform init
- Run
plan
to find out all resources that are going to be createdterraform plan
- Run
apply
to create those resourcesterraform apply
- Deploy a hazelcast client pod and verify the connection. More details about this are here
- Make sure to destroy them once you are done exploring using
terraform destroy
Hazelcast supports two strategies to simplify the deployment in a Kubernetes cluster. Official documentation is at https://github.com/hazelcast/hazelcast-kubernetes#understanding-discovery-modes
This module uses the DNS Lookup
strategy to form a cluster. So, the client should also use this strategy to connect to the cluster.
Here is a sample test client written in java https://github.com/everest-engineering/terraform-kubernetes-hazelcast/blob/master/tests/hazelcast-java-client
As of now (on 23rd June 2020) only the java Hazelcast client implementation supports kubernetes discovery using the plugin https://github.com/hazelcast/hazelcast-kubernetes
You can verify the feature completeness for your favourite langauge at https://hazelcast.org/imdg/clients-languages/
Name | Description | Type | Default | Required |
---|---|---|---|---|
cluster_members | number of members in the cluster | number |
1 |
no |
cpu | cpu units to request | string |
n/a | yes |
hazelcast_version | hazelcast version to deploy | string |
n/a | yes |
labels | labels to apply to all resources | map(string) |
n/a | yes |
memory | amount of memory to request | string |
n/a | yes |
name | name of the cluster | string |
"hazelcast" |
no |
namespace | kubernetes namespace to deploy to | string |
"default" |
no |
Name | Description |
---|---|
service_dns | fully qualified dns name of the hazelcast service |
Install minikube from here and start a kubernetes cluster in local.
- Test setup is automated in setup.sh. The shell script does the following tasks.
- deploys the example hazelcast cluster
- verifies that the cluster has formed successfully
- builds the client project jar
- builds a docker image using the above jar in Minikube
- deploys a kubernetes job to run the client in the cluster
- verifies that client has connected to the cluster successfully
- Use the script teardown.sh to remove all test resources
We appreciate your help!
Open an issue or submit a pull request for an enhancement. Browse through the current open issues.