Preparing the operator and log file storage

All instances of an operator need a place to store its log files. If you plan to run the scripts to generate a custom resource (CR), the cluster setup script creates a persistent volume claim (PVC) for you by default.

About this task

You can customize the storage of the operator before you create an instance of the operator. The cluster setup script creates the operator instance, if you plan to use the Operator Hub then you must create the necessary storage for the operator.

Tip:

The cluster setup script identifies the available storage classes on your cluster, but you can create a new PV for the operator. The name of the PV must be set in the PVC, so make sure that the storageClassName has the correct value.

If you use static storage, make sure that you grant group write permission to the nfs.path on the host or your shared volume on your NFS server.

Important:

If you plan to run the installation scripts and want to use the default storage, decide whether to create a new namespace before you run the scripts. You can create a namespace beforehand or when you run the cluster setup script. If you do not want to use the IBM Entitled Registry to pull the container images, then you need a namespace to load the images to a target registry.

Procedure

  1. Login to your cluster.
    Use the oc command line interface for OpenShift container platforms.
    oc login https://<cluster-ip>:<port> -u <cluster-admin> -p <password>

    Where the <cluster-ip>:<port> is the IP address and port number of the cluster, and the <password> is your password for your <cluster-admin> user.

    The following command shows an example cluster URL and port.

    oc login https://api.ocp4616-cp4ba.cp.example.com:6443 -u admin -p admin_pwd
    
  2. Create a namespace for the operator and CP4BA deployment.

    You can use an existing project in the cluster or create a new namespace. If you are planning an all namespaces installation, the openshift-operators project is used for the operator, but you must have a different project for your CP4BA deployment. You can create a project in the OpenShift console or on the OCP CLI by running the following command.

    oc new-project <project_name> --description="<description>" --display-name="<display_name>"

    Change the scope in the OpenShift cluster to the new project (cp4ba-project) or openshift-operators for an all namespaces installation.

    oc project <project_name>
  3. Create the YAML resources for the operator and component logs. Dynamic storage (Choice 1) is recommended.
    • Choice 1:
      1. Edit cert-kubernetes/descriptors/operator-shared-pvc.yaml and replace the <StorageClassName> and <Fast_StorageClassName> placeholders by storage classes of your choice.

        For more information about downloading cert-kubernetes, see Preparing a client to connect to the cluster.

      2. Deploy the PVCs. If you edited descriptors/operator-shared-pvc.yaml run the command with the file from the descriptors folder.
        oc create -f descriptors/operator-shared-pvc.yaml
        Note: If you are using an Oracle database with an "ibm-spectrum-scale" storage class, and the default data replication of 2, then increase the spec.resources.requests.storage to 3Gi.
    • Choice 2:

      If you prefer to use static storage, do the following steps.

      1. Create a PV YAML file, for example operator-shared-pv.yaml. The following example YAML defines two PVs, one for the operator and one shared volume for the Ansible logs for the deployment. PVs depend on your cluster configuration, so adapt the YAML to your configuration.
        apiVersion: v1
        kind: PersistentVolume
        metadata:
          name: operator-shared-pv
        spec:
          accessModes:
          - ReadWriteMany
          capacity:
            storage: 1Gi
          nfs:
            path: /root/operator
            server: <NFS Server>
          persistentVolumeReclaimPolicy: Retain
        ---
        apiVersion: v1
        kind: PersistentVolume
        metadata:
          labels:
            type: local
          name: cp4a-shared-log-pv
        spec:
          capacity:
            storage: 100Gi
          accessModes:
            - ReadWriteMany
          nfs:
            path: /root/logs
            server: <NFS Server>
          persistentVolumeReclaimPolicy: Delete

        Replace <NFS Server> with the actual server name.

      2. Deploy the PVs.
        oc create -f operator-shared-pv.yaml
      3. Provide group write permission to the persistent volumes. According to the PV nfs.path definitions, run the following commands:
        chown -R :65534 <path> 
        chmod -R g+rw <path>
        

        Where <path> is the value in your PVs (/root/operator and /root/logs). Group ownership must be set to the anongid option given in the NFS export definition of the NFS server associated with the PV. The default anongid value is 65534.

        Remove the .OPERATOR_TYPE file if it exists from a previous deployment.

        rm -f <path>.OPERATOR_TYPE

        Where <path> is the value in your operator PV (/root/operator).

      4. Create a claim for the static PVs.

        To create a claim bound to the previously created PVs, create a file <path>/operator-shared-pvc.yaml anywhere on your disk, with the following content.

        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: operator-shared-pvc
          namespace: <project_name>
        spec:
          accessModes:
            - ReadWriteMany
          resources:
            requests:
              storage: 1Gi
          volumeName: operator-shared-pv
        ---
        apiVersion: v1
        kind: PersistentVolumeClaim
        metadata:
          name: cp4a-shared-log-pvc
          namespace: <project_name>
        spec:
          accessModes:
            - ReadWriteMany
          resources:
            requests:
              storage: 100Gi
          volumeName: cp4a-shared-log-pv

        Replace the <project_name> placeholders with the name of your project to use for the operator in your OpenShift cluster. If you are planning an all namespaces installation then the operator project is openshift-operators.

        Note: If you are using an Oracle database with an "ibm-spectrum-scale" storage class, and the default data replication of 2, then increase the spec.resources.requests.storage to 3Gi.
      5. Deploy the PVCs. If you created your own operator-shared-pvc.yaml file, run the following command with your own path.
        oc create -f <path>/operator-shared-pvc.yaml

What to do next

Confirm that the STATUS of the PVCs (cp4a-shared-log-pvc and operator-shared-pvc) are bound correctly before you move to the next step by running the following command in the <project_name>.

oc get pvc

NAME                STATUS VOLUME                                   CAPACITY ACCESS MODES STORAGECLASS        AGE
cp4a-shared-log-pvc Bound  pvc-db2068e1-83d1-45e4-a4db-a33b93387561 100Gi    RWX          managed-nfs-storage 102m
operator-shared-pvc Bound  pvc-74f0a26c-3632-4c93-a78c-6502cee5ab48 1Gi      RWX          managed-nfs-storage 102m

You can now check that you have access to the container images. For more information, see Getting access to images from the public IBM Entitled Registry.