A newer version of Platform Operator is available.

View latest

User Code Namespaces

User Code Namespaces provide a container for Java classpath resources, such as user code and accompanying artifacts like property files. This provides namespace isolation to ensure that access to resources in different namespaces can be managed through configuration. From Hazelcast Platform Operator, you can deploy your application code from external buckets using UserCodeNamespace CRs.

See User Code Namespaces for more detailed information about the configuration and behavior of User Code Namespaces in Hazelcast, including how updates to deployed resources affect running members.

Enabling User Code Namespaces

To enable User Code Namespaces you must configure the userCodeNamespaces section in the Hazelcast custom resource.

Example of Hazelcast with User Code Namespaces enabled
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
  name: hazelcast
spec:
  clusterSize: 3
  repository: 'docker.io/hazelcast/hazelcast-enterprise'
  licenseKeySecretName: hazelcast-license-key
  userCodeNamespaces: {}

Creating a User Code Namespace

To create a User Code Namespace, you must create a new UserCodeNamespace CR. The name of the CR is used as the name of the created User Code Namespace. The JAR files stored in the configured bucket are uploaded to the Hazelcast cluster under the newly created namespace.

  • AWS

  • GCP

  • Azure

User Code Namespaces in AWS S3:

apiVersion: hazelcast.com/v1alpha1
kind: UserCodeNamespace
metadata:
  name: ucn-sample
spec:
  hazelcastResourceName: hazelcast
  bucketConfig:
    secretName: s3-bucket-secret (1)
    bucketURI: s3://map-store-bucket/path/to/jars (2)
For further information about accessing resources on different cloud providers, see Authorization Methods to Access Cloud Provider Resources.

User Code Namespaces in GCP:

apiVersion: hazelcast.com/v1alpha1
kind: UserCodeNamespace
metadata:
  name: ucn-sample
spec:
  hazelcastResourceName: hazelcast
  bucketConfig:
    secretName: cloud-storage-bucket-secret (1)
    bucketURI: gs://map-store-bucket/path/to/jars (2)
For further information about accessing resources on different cloud providers, see Authorization Methods to Access Cloud Provider Resources.

User Code Namespaces in Azure Blob:

apiVersion: hazelcast.com/v1alpha1
kind: UserCodeNamespace
metadata:
  name: ucn-sample
spec:
  hazelcastResourceName: hazelcast
  bucketConfig:
    secretName: azure-blob-bucket-secret (1)
    bucketURI: azblob://map-store-bucket/path/to/jars (2)
For further information about accessing resources on different cloud providers, see Authorization Methods to Access Cloud Provider Resources.
1 Name of the secret with credentials for accessing the bucket URI.
2 The bucket URI from which user code JAR files are loaded.

To allow your data structures to resolve your user code, set spec.userCodeNamespace on the data structure CR to the name of the UserCodeNamespace CR. You can use the same namespace name on multiple data structures.

Example of Map with User Code Namespace
apiVersion: hazelcast.com/v1alpha1
kind: Map
metadata:
  name: my-map
spec:
  hazelcastResourceName: hazelcast
  userCodeNamespace: ucn-sample

Delete a User Code Namespace

Deleting a UserCodeNamespace CR removes only that resource from Kubernetes. It does not delete Map, Cache, or other CRs that set spec.userCodeNamespace to the same name.

To remove a User Code Namespace:

  1. Delete any Map, Cache, Queue, Topic, MultiMap, or ReplicatedMap CR that sets spec.userCodeNamespace to that namespace, and any executor services on the Hazelcast CR that use the same name.

  2. Delete the UserCodeNamespace CR.

  3. Restart Hazelcast members.

Restart Hazelcast members after deleting the UserCodeNamespace CR. Deleting the CR does not unload the namespace from members that are already running.

  • Kubernetes

  • Openshift

kubectl delete usercodenamespace <namespace-cr-name>
oc delete usercodenamespace <namespace-cr-name>