Install DG 8 Operator via template/ocp cli command

Solution Verified - Updated

Environment

  • Red hat OpenShift Container Platform (OCP)
    • 4.x
  • Red Hat Data Grid (RHDG)
    • 8.x
    • DG Operator

Issue

Install DG 8 Operator via template?
How to install the DG 8 Operator via cp cli command?

Resolution

Cli command

  1. Download the cli plugin.
  2. unzip redhat-datagrid-8.3.1-cli.zip
  3. cd redhat-datagrid-8.3.1-cli/
    4.cd redhat-datagrid-8.3.1-cli/
  4. kubectl-infinispan install <--- to install the latest operator with default channel

Via template

  1. oc login on the OCP cluster

  2. create a template file with subscription, the specific namespace and the group: operator-template.yaml

  3. Run oc process -f rhdg-operator/operator-template.yaml | oc apply -f -

  4. Confirming the installation:

$ oc get subscription  --all-namespaces
NAMESPACE        NAME                PACKAGE    SOURCE             CHANNEL
rhdg8-operator   datagrid-operator   datagrid   redhat-operators   8.3.x

Root Cause

In attach there is a template (yaml, saved as txt) where it creates two projects rhdg-8 (cluster_namespace) and rhdg8-operator (operator_namespace), which is the CRD (where the operator will listen to) and the operator itself.

For cache creation see Creating cache in DG 8 in OCP 4 and for DG 8 Operator upgrade, see How to migrate from DG 8.1 to DG 8.3 in DG 8 Operator.

Namespace installation

For setting the installation of the Operator's namespace use OperatorGroup, given the below:

  • cluster-wide operators must be installed in openshift-operators
  • while namespaced-operators should be in their own namespace

OperatorGroup is useful for setting the Operator installation for one namespace and the cluster target for another. Example:

- apiVersion: operators.coreos.com/v1alpha1
  kind: Subscription
  metadata:
    name: datagrid-operator
    namespace: ${OPERATOR_NAMESPACE}
  spec:
    channel: 8.3.x
    installPlanApproval: Manual 
    name: datagrid
    source: redhat-operators
    sourceNamespace: openshift-marketplace
    startingCSV: datagrid-operator.v8.3.7
- apiVersion: operators.coreos.com/v1
  kind: OperatorGroup
  metadata:
    name: infinispan
    namespace: ${OPERATOR_NAMESPACE}
  spec:
    targetNamespaces:
      - ${CLUSTER_NAMESPACE}

Diagnostic Steps

  1. To check the possible parameters to use on the template, use oc explain infinispan or oc explain infinispan.spec:
### Explain infinispan
$ oc explain infinispan
KIND:     Infinispan
VERSION:  infinispan.org/v1
DESCRIPTION:
     Infinispan is the Schema for the infinispans API
FIELDS:
   apiVersion	<string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
   kind	<string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
   metadata	<Object>
     Standard object's metadata. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   spec	<Object>
     InfinispanSpec defines the desired state of Infinispan
   status	<Object>
     InfinispanStatus defines the observed state of Infinispan
### Explain the spec:
$ oc explain infinispan.spec
KIND:     Infinispan
VERSION:  infinispan.org/v1
RESOURCE: spec <Object>
DESCRIPTION:
     InfinispanSpec defines the desired state of Infinispan
FIELDS:
   affinity	<Object>
     Affinity is a group of affinity scheduling rules.
   autoscale	<Object>
     Autoscale describe autoscaling configuration for the cluster
   cloudEvents	<Object>
     InfinispanCloudEvents describes how Infinispan is connected with Cloud
### Explain the infinispan.spec --recursive
 oc explain infinispan.spec --recursive
KIND:     Infinispan
VERSION:  infinispan.org/v1
RESOURCE: spec <Object>
DESCRIPTION:
     InfinispanSpec defines the desired state of Infinispan
FIELDS:
   affinity	<Object>
      nodeAffinity	<Object>
         preferredDuringSchedulingIgnoredDuringExecution	<[]Object>
            preference	<Object>
               matchExpressions	<[]Object>
                  key	<string>
                  operator	<string>
                  values	<[]string>
               matchFields	<[]Object>
                  key	<string>
                  operator	<string>
                  values	<[]string>
            weight	<integer>
         requiredDuringSchedulingIgnoredDuringExecution	<Object> 
Product(s)
Components
Category
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.