A newer version of Hazelcast Operator is available.

View latest

Configuring Maps

Hazelcast maps are used to distribute data across a cluster and make it easy to scale your applications while protecting data against member failures. You can create and configure maps using the Map resource.

Configuring the Map Resource

Below are the configuration options for the Map resource. You can find more detailed information in API Reference page.

Field Description

name

Name of the map config to be created. If empty, the CR name will be used. It cannot be updated after the map config is created successfully.

hazelcastResourceName

HazelcastResourceName defines the name of the Hazelcast resource.

backupCount

Count of synchronous backups.

timeToLiveSeconds

Maximum time in seconds for each entry to stay in the map.

maxIdleSeconds

Maximum time in seconds for each entry to stay idle in the map.

eviction

Configuration for removing data from the map when it reaches its max size.

  • evictionPolicy: Eviction policy to be applied when map reaches its max size according to the max size policy.

  • maxSize: Max size of the map.

  • maxSizePolicy: Policy for deciding if the maxSize is reached.

indexes

Indexes to be created for the map data.

persistenceEnabled

When enabled, map data will be persisted.

Persistence should be enabled for Hazelcast before enabling it for the map. You can learn about enabling persistence for Hazelcast in Persistence, Backup and Restore.

mapStore

Configuration options when you want to load/store the map entries from/to a persistent data store such as a relational database. You can learn more at Working With External Data.

  • className: Name of your class implementing MapLoader and/or MapStore interface.

  • initialMode: Sets the initial entry loading mode.

  • writeDelaySeconds: Policy for deciding if the maxSize is reached.

  • writeBatchSize: Used to create batches when writing to map store.

  • writeCoealescing: It is meaningful if you are using write behind in MapStore. When it is set to true, only the latest store operation on a key during the write-delay-seconds will be reflected to MapStore.

  • propertiesSecretName: Name of the secret holding the properties for the MapStore classes implementing the MapLoaderLifecycleSupport interface.

Example Configuration

The following Map resource creates a map configuration for the Hazelcast custom resource that is defined in the hazelcastResourceName field.

Example configuration
apiVersion: hazelcast.com/v1alpha1
kind: Map
metadata:
  name: map-sample
spec:
  hazelcastResourceName: hazelcast-sample
  backupCount: 1
  timeToLiveSeconds: 0
  maxIdleSeconds: 0
  eviction:
    evictionPolicy: NONE
    maxSize: 0
    maxSizePolicy: PER_NODE
  indexes:
    - type: HASH
      name: index1
      attributes:
        - "name"
        - "age"
    - type: BITMAP
      attributes:
        - "name"
      bitMapIndexOptions:
        uniqueKey: id
        uniqueKeyTransition: RAW
  persistenceEnabled: true

After creating the Map resource, you can learn about its status with the following command

kubectl get map map-sample -o wide
NAME   STATUS    MESSAGE
map    Success