Create a Tanzu GemFire Cluster

Once the Tanzu GemFire Operator is installed (see Install the Tanzu GemFire Operator), create a Tanzu GemFire cluster by using kubectl to apply the Custom Resource Definition (CRD) that describes the cluster. The Custom Resource Definition details the mappings and fields of a Tanzu GemFire cluster.

  1. Create a namespace to be used for the Tanzu GemFire cluster:

    $ kubectl create namespace NAMESPACE-NAME
    

    where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace.

    This namespace is distinct and separate from the namespace created for the Tanzu GemFire operator.

  2. Create an image pull secret for your Tanzu GemFire cluster's namespace. Set the user name (USERNAME) and password (PASSWD) credentials to values that have permission to access VMware Tanzu Network, as they will be used to acquire the locator and server images from the registry. Create the image pull secret:

    $ kubectl create secret docker-registry image-pull-secret --namespace=NAMESPACE-NAME --docker-server=registry.pivotal.io --docker-username='USERNAME' --docker-password='PASSWD'
    

    where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace.

    Surround both the USERNAME and the PASSWD by single quote marks to ensure that special characters within those values are handled correctly.

  3. Place the YAML that represents the Tanzu GemFire cluster's CRD into a file. For example, a definition that uses all possible defaults and names the cluster gemfire1:

    apiVersion: gemfire.tanzu.vmware.com/v1
    kind: GemFireCluster
    metadata:
      name: gemfire1
    spec:
      image: registry.pivotal.io/tanzu-gemfire-for-kubernetes/gemfire-k8s:1.0.1
    
  4. To create the Tanzu GemFire cluster, apply the CRD specified in the file with a command of the form:

    kubectl -n NAMESPACE-NAME apply -f CLUSTER-CRD-YAML
    

    where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace, and CLUSTER-CRD-YAML is the file name of the file containing the YAML that represents the Tanzu GemFire cluster's CRD.

  5. Check the creation status of the Tanzu GemFire cluster:

    kubectl -n NAMESPACE-NAME get GemFireClusters
    

    where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace.

    For example, if the NAMESPACE-NAME is gemfire-cluster:

    $ kubectl -n gemfire-cluster get GemFireClusters
    NAME       LOCATORS   SERVERS
    gemfire1   1/1        1/2
    

    The first number identifies how many of the replicas are running. The second number identifies how many replicas are specified. When the quantity running reaches the number of replicas specified for both locators and servers, the Tanzu GemFire cluster creation is complete.

Delete a Tanzu GemFire Cluster

To delete a Tanzu GemFire cluster, first remove the cluster:

$ kubectl -n NAMESPACE-NAME delete GemFireCluster NAME

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace, and NAME is the metadata: name field from the deployment YAML.

Once the Tanzu GemFire cluster is gone, remove the persistent volume claims of the Kubernetes cluster. These are disk claims that Kubernetes makes on the underlying system. Obtain a list of the persistent volume claims:

$ kubectl -n NAMESPACE-NAME get persistentvolumeclaims

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace.

For each persistent volume claim listed, delete it:

$ kubectl -n NAMESPACE-NAME delete persistentvolumeclaim PVC_NAME

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace.

Create a LoadBalancer Service

The optional creation of a Kubernetes LoadBalancer service permits Tanzu GemFire cluster access. Each of these two types of cluster access would have its own LoadBalancer service.

Some cloud providers assign a public IP address to a LoadBalancer service, which will expose the Tanzu GemFire cluster to the internet. Understand the security risks before creating a LoadBalancer service.

Create a LoadBalancer Service for the Management API

Once the Tanzu GemFire cluster has been created, a LoadBalancer service for the Tanzu GemFire Management API may be created.

Create a YAML configuration file for the LoadBalancer service with one of these two specifications:

  • If the underlying IaaS supports session affinity:

    apiVersion: v1
    kind: Service
    metadata:
      name: LB-SVC-MGMT-API
    spec:
      selector:
        app: NAME-locator
      ports:
        - name: management
          port: 7070
          targetPort: 7070
      sessionAffinity: ClientIP
      sessionAffinityConfig:
          clientIP:
            timeoutSeconds: 10800
      type: LoadBalancer
    

    where LB-SVC-MGMT-API is your chosen name for the LoadBalancer service. The chosen name must follow the syntax rules for a DNS name. NAME is the metadata: name field from the Tanzu GemFire cluster's deployment YAML.

  • If the underlying IaaS does not support session affinity:

    apiVersion: v1
    kind: Service
    metadata:
      name: LB-SVC-MGMT-API
    spec:
      selector:
        app: NAME-locator-0
      ports:
        - name: management
          port: 7070
          targetPort: 7070
      type: LoadBalancer
    

    where LB-SVC-MGMT-API is your chosen name for the LoadBalancer service. The chosen name must follow the syntax rules for a DNS name. NAME is the metadata: name field from the Tanzu GemFire cluster's deployment YAML.

    This specification directs all management REST API requests to a single locator within the Tanzu GemFire cluster. If the pod hosting that locator becomes unavailable, the management REST API will also be unavailable until the pod and locator restarts.

Create the LoadBalancer service by applying the YAML configuration to the Kubernetes cluster with a command of the form:

kubectl -n NAMESPACE-NAME apply -f YAML-FILE-NAME

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace, and YAML-FILE-NAME is your YAML configuration's file name.

Create a LoadBalancer Service for the Developer REST API

Create a Tanzu GemFire cluster that has the Developer REST API enabled. The Developer REST API is enabled by including a Tanzu GemFire property for servers in the CRD YAML:

overrides:
    gemfireProperties:
      start-dev-rest-api: "true"

Once the Tanzu GemFire cluster has been created, a LoadBalancer service for the Tanzu GemFire Developer API may be created.

Place the following YAML configuration in a file:

apiVersion: v1
kind: Service
metadata:
  name: LB-SVC-DEV-API
spec:
  selector:
    app: NAME-server
  ports:
    - name: rest-api
      port: 7070
      targetPort: 7070
  type: LoadBalancer

where LB-SVC-DEV-API is your chosen name for the LoadBalancer service. The chosen name must follow the syntax rules for a DNS name. NAME is the metadata: name field from the Tanzu GemFire cluster's deployment YAML.

Create the LoadBalancer service by applying this configuration to the Kubernetes cluster with a command of the form:

kubectl -n NAMESPACE-NAME apply -f YAML-FILE-NAME

where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace, and YAML-FILE-NAME is your YAML configuration's file name.

Delete a LoadBalancer Service

To delete LoadBalancer services:

  1. Identify the services with a command of the form:

    kubectl -n NAMESPACE-NAME get services
    

    where NAMESPACE-NAME is your chosen name for the Tanzu GemFire cluster namespace.

  2. For each listed LoadBalancer service, delete it with a command of the form:

    kubectl -n NAMESPACE-NAME delete service LB-SVC-NAME
    

    where LB-SVC-NAME is the name field from the service's configuration YAML.

check-circle-line exclamation-circle-line close-line
Scroll to top icon