Configuring a local StorageClass and PersistentVolume for analytics-api in Kubernetes

You can configure a local StorageClass and PersistentVolume for analytics-api in a Kubernetes cluster.

Before you begin

The following procedure for configuring a StorageClass and PersistentVolume is only acceptable for Proof of concepts (POCs) and not recommended for production or other systems with numerous running loads.
Note: The instructions are predicated upon your volumes placement in /mnt/local-persistent-volumes and that analytics-api is called the data-analytics-api-0 name.

Procedure

  1. Set up the local storage directory if it does not exist.
    For example: mkdir -p /mnt/local-persistent-volumes/data-analytics-api-0
  2. Ensure the directory is owned by a user with uid:1000 and assigned a group with gid:1000.
    The analytics-api service runs as the user elasticsearch (uid:1000,gid:1000) in the container, and the user and group ids must match.
  3. Write the following example to a file.
    Kubernetes StorageClass information can be found here.
    File: local-storageclass.yaml

    Example:

    
         apiVersion: storage.k8s.io/v1
         kind: StorageClass
         metadata:
           name: local-storage
         provisioner: kubernetes.io/no-provisioner
         volumeBindingMode: WaitForFirstConsumer
             
  4. Create the StorageClass by applying the yaml file.
    For example: kubectl apply -f local-storageclass.yaml
  5. Write the following example to a file.
    Kubernetes PersistentVolume information can be found here.
    File: analytics-api-persistentvolume.yaml

    Example:

    
         apiVersion: v1
         kind: PersistentVolume
         metadata:
           name: data-analytics-api-0
         spec:
           capacity:
             storage: 8Gi
           volumeMode: Filesystem
           accessModes:
           - ReadWriteOnce
           claimRef:
             namespace: {{whatever your installation namespace is e.g. 'default'}}
             name: data-analytics-api-0
           persistentVolumeReclaimPolicy: Delete
           storageClassName: local-storage
           local:
             path: /mnt/local-persistent-volumes/data-analytics-api-0
           nodeAffinity:
             required:
               nodeSelectorTerms:
               - matchExpressions:
                 - key: kubernetes.io/hostname
                   operator: In
                   values:
                   - {{the kubernetes.io/hostname value on the node on which you want to create local volumes}}
  6. Create the PersistentVolume by applying the yaml file.
    For example: kubectl apply -f analytics-api-persistentvolume.yaml
  7. Install HCL Accelerate with the analytics beta feature.
    Note: Refer to the analytics beta feature installation instructions for Kubernetes for details.
  8. Verify that the analytics-api-0 pod advances to status Running 1/1.

Results

You should have a new StorageClass and new PersistentVolume created as shown in the example below.

# kubectl get sc,pv

NAME                                        PROVISIONER                    RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
storageclass.storage.k8s.io/local-storage   kubernetes.io/no-provisioner   Delete          WaitForFirstConsumer   false                  16h

NAME                                    CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                          STORAGECLASS    REASON   AGE
persistentvolume/data-analytics-api-0   8Gi        RWO            Delete           Bound    default/data-analytics-api-0   local-storage            16h