Skip to main content
Version: 5.18

Install Operator and deploy a Hazelcast cluster

This topic explains how to deploy a Hazelcast cluster using Operator for Kubernetes.

note

If you want to migrate from the Hazelcast Helm Chart, see Migrate from Helm to Operator.

note

Unless the deployment is pinned to a specific Java version, the Operator defaults to the latest supported Java version.

Overview​

As part of the deployment process, you will install the custom resource definitions (CRDs) that describe the Hazelcast resource types.

A CRD is a Kubernetes feature that allows you to create custom resources that extend the Kubernetes API. CRDs allow new types of resources tailored to specific use cases to be created, without adding another API server. They also provide detailed reports on the configuration content of a CRD to any authorized Kubernetes API consumer. Using CRDs, you can:

  • Introduce unique objects or types into the Kubernetes cluster.
  • Create platform resources on top of Kubernetes.
  • Build and use platforms through self-service activity.

For example, the clusterName field in the Hazelcast CRD can be used to rename a cluster.

CRDs are expressed in YAML format, just like standard Kubernetes entities. The Kubernetes API server processes and manages CRDs the same way it does with built-in resources.

For more information about the Operator CRD, see Hazelcast Platform Operator API Docs.

Prerequisites​

  • A Kubernetes or OpenShift cluster.
  • The kubectl or oc command line tools, configured to communicate with your cluster.
  • Helm.
  • A Hazelcast Enterprise license key. If you don't have a license key, you can request one from the Hazelcast website.
note

Because CRDs are global resources, they may need to be installed by an administrator.

Install and run Operator​

Operator is installed using a Helm chart.

note

Hazelcast images are hosted at docker.io/hazelcast and registry.connect.redhat.com/hazelcast. The Docker images are used by default. If you need to fetch images from Red Hat or a private mirror, you can change the default image registry.

  1. Add the Hazelcast Helm Charts repository to your Helm repository list:

    shell
    helm repo add hazelcast https://hazelcast-charts.s3.amazonaws.com/
    helm repo update
  2. You can either deploy Operator at the same time as the CRDs or separately.

    Run the following command to deploy Operator and the CRDs together. By default, Operator watches all namespaces. Use the watchedNamespaces variable to change this configuration if needed.

    shell
    helm install operator hazelcast/hazelcast-platform-operator --version=5.18.0 \
    --set=installCRDs=true
    tip

    You can view all configuration options by running the following command: helm show values hazelcast/hazelcast-platform-operator

  3. Monitor the Operator logs. At this point, Operator should be up and running. To check:

    shell
    kubectl logs deployment.apps/operator-hazelcast-platform-operator -n hz-system

Start the Hazelcast cluster​

After installing and running Operator, you can create a Hazelcast cluster.

  1. Create a Kubernetes secret to hold your license key.

    For Kubernetes
    shell
    kubectl create secret generic hazelcast-license-key --from-literal=license-key=<YOUR LICENSE KEY>
    For Openshift
    shell
    oc create secret generic hazelcast-license-key --from-literal=license-key=<YOUR LICENSE KEY>
  2. Create the Hazelcast custom resource file and name it hazelcast-enterprise.yaml.

    yaml
    apiVersion: hazelcast.com/v1alpha1
    kind: Hazelcast
    metadata:
    name: hazelcast-sample
    spec:
    clusterSize: 3
    clusterName: mycluster
    repository: 'docker.io/hazelcast/hazelcast-enterprise'
    version: '5.7.0-slim'
    licenseKeySecretName: hazelcast-license-key
  3. Apply the custom resource to start the Hazelcast cluster.

    For Kubernetes
    shell
    kubectl apply -f hazelcast-enterprise.yaml
    For Openshift
    shell
    oc apply -f hazelcast-enterprise.yaml
  4. Verify that Hazelcast cluster is up and running by checking the Hazelcast member logs.

    For Kubernetes
    shell
    kubectl logs pod/hazelcast-sample-0
    For Openshift
    shell
    oc logs pod/hazelcast-sample-0

You should see the following:

Members {size:3, ver:3} [
Member [10.36.8.3]:5701 - ccf31703-de3b-4094-9faf-7b5d0dc145b2 this
Member [10.36.7.2]:5701 - e75bd6e2-de4b-4360-8113-040773d858b7
Member [10.36.6.2]:5701 - c3d105d2-0bca-4a66-8519-1cacffc05c98
]

Check that the Hazelcast cluster is running​

To check if a cluster is running, see the status field of the Hazelcast resource. You can check the status using get hazelcast:

shell
kubectl get hazelcast
NAME STATUS MEMBERS
hazelcast-sample Running 3/3

You can also view a more detailed status report in YAML format:

shell
kubectl get hazelcast hazelcast-sample -o=yaml
yaml
status:
hazelcastClusterStatus:
readyMembers: 3/3
phase: Running

The phase field represents the current status of the cluster, and can contain any of the following values:

  • Running: The cluster is up and running.
  • Pending: The cluster is in the process of starting.
  • Failed: An error occurred while starting the cluster.

Any additional information, such as validation errors, will be provided in the message field.

The readyMembers field represents the number of Hazelcast members that are connected to the cluster.

For more information, see the API reference.

Next steps​

Expose Hazelcast clusters outside Kubernetes so you can connect external clients to them.