Installing License Service on the Kubernetes cluster

Learn how to install License Service on Kubernetes with kubectl.

Prerequisites

Before installation, see Supported platforms and hardware requirements to check the installation requirements.

Installation

Note: For the OpenShift cluster, check whether the License Service is installed in cs-control or ibm-common-services namespace of the cluster to prevent the use of the multiple License Service copies to report the license usage of multiple IBM Cloud Paks that are running on the same cluster.

If you install the License Service in cs-control or ibm-common-services namespace and multiple IBM Cloud Paks run on the same cluster, upgrade the License Service to the latest version.

If a single instance of IBM Cloud Pak runs on the cluster, you can install the License Service in the ibm-licensing namespace.

  1. Install the Operator Lifecycle Manager (OLM).

    1. Make sure that you are connected to your cluster and run the following command:

      kubectl get node
      

      The response should contain a list of your nodes.

    2. Verify the installation of OLM with the following command:

      kubectl get crd clusterserviceversions.operators.coreos.com
      
      • If you get the following response, the OLM is installed.

         NAME                                          CREATED AT
         clusterserviceversions.operators.coreos.com   2020-06-04T14:42:13Z
        
      • If you get the following response, the OLM CRD is not installed.

         Error from server (NotFound): customresourcedefinitions.apiextensions.k8s.io "clusterserviceversions.operators.coreos.com" not found
        
    3. If the OLM is not installed, download it from the OLM GitHub repository. Use the following script to download and install OLM v0.19.1

      Note: : This procedure is applicable for OLM version v0.19.1. For newer versions, check OLM documentation.

      olm_version=v0.19.1
      curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${olm_version}/install.sh | bash -s ${olm_version}
      

      Troubleshooting: If you get an error, upgrade your Kubernetes server version or use older version of the OLM.

  2. Create the CatalogSource.

    1. To get GLOBAL_CATALOG_NAMESPACE, check global catalog namespace in a yaml in a packageserver OLM pod that is somewhere on your cluster. You can, for example, use the following command:

      olm_namespace=$(kubectl get csv --all-namespaces -l olm.version -o jsonpath="{.items[?(@.metadata.name=='packageserver')].metadata.namespace}")
      GLOBAL_CATALOG_NAMESPACE=$(kubectl get deployment --namespace="${olm_namespace}" packageserver -o yaml | grep -A 1 -i global-namespace | tail -1 | cut -d "-" -f 2- | sed -e 's/^[ \t]*//')
      # check if the namespace is found
      echo ${GLOBAL_CATALOG_NAMESPACE}
      

      If you get an empty response to the echo command, you can get global catalog namespace using the following command.

      Note: The following method should only be used for getting global catalog namespace if the previous method failed.

      GLOBAL_CATALOG_NAMESPACE=$(kubectl get pod --all-namespaces -l app=olm-operator -o jsonpath="{.items[0].metadata.namespace}")
      echo ${GLOBAL_CATALOG_NAMESPACE}
      
    2. Create the CatalogSource by using the following command:

      cat <<EOF | kubectl apply -f -
      apiVersion: operators.coreos.com/v1alpha1
      kind: CatalogSource
      metadata:
        name: ibm-licensing-catalog
        namespace: $GLOBAL_CATALOG_NAMESPACE
      spec:
        displayName: IBM License Service Catalog
        publisher: IBM
        sourceType: grpc
        image: icr.io/cpopen/ibm-licensing-catalog
        updateStrategy:
          registryPoll:
            interval: 45m
      EOF
      
    3. Check the results.

      • Run the following command to check if the CatalogSource is created in the $GLOBAL_CATALOG_NAMESPACE namespace:

         kubectl get catalogsource -n $GLOBAL_CATALOG_NAMESPACE
        

        The following is the sample output:

         NAME                           DISPLAY                        TYPE   PUBLISHER   AGE
         ibm-licensing-catalog          IBM License Service Catalog    grpc   IBM         16m
         [...]
        
      • If everything goes well, you should see similar pod running. Run the following command to check if the pod is running:

         kubectl get pod -n $GLOBAL_CATALOG_NAMESPACE
        

        The following is the sample output:

         NAME                                   READY   STATUS    RESTARTS   AGE
         ibm-licensing-catalog-1v1g2            1/1     Running   0          18m
         [...]
        
  3. Create an OperatorGroup.

    An OperatorGroup is used to denote which namespaces your Operator should watch. It must exist in the namespace where your operator is deployed, for example, <foundational-services>.

    1. Create a namespace for IBM Licensing with the following command.

      Note: The ibm-licensing namespace is the default namespace of the License Service. If you need to install the License Service in a custom namespace for your cluster, replace ibm-licensing with your custom namespace.

      kubectl create namespace ibm-licensing
      
    2. Check if the operator group exists in that namespace by running the following command:

      kubectl get OperatorGroup -n ibm-licensing
      
      • If you get the following response, the operator group was found, and you can go to step 4 and create a Subscription.

         NAME            AGE
         operatorgroup   39d
        
      • If you get the following response, the operator group was not found, and you need to create it.

         No resources found.
        
    3. Create the operator group.

      Use the following command to deploy the OperatorGroup resource.

      cat <<EOF | kubectl apply -f -
      apiVersion: operators.coreos.com/v1
      kind: OperatorGroup
      metadata:
        name: operatorgroup
        namespace: ibm-licensing
      spec:
        targetNamespaces:
        - ibm-licensing
      EOF
      
  4. Create a Subscription.

    A subscription is created for the operator and is responsible for upgrades of IBM Licensing when needed.

    1. Make sure that the GLOBAL_CATALOG_NAMESPACE variable has the global catalog namespace value. The global catalog namespace was retrieved in step 2.

    2. Create the Subscription using the following command:

      cat <<EOF | kubectl apply -f -
      apiVersion: operators.coreos.com/v1alpha1
      kind: Subscription
      metadata:
        name: ibm-licensing-operator-app
        namespace: ibm-licensing
      spec:
        channel: v4.1
        name: ibm-licensing-operator-app
        source: ibm-licensing-catalog
        sourceNamespace: $GLOBAL_CATALOG_NAMESPACE
      EOF
      
  5. Verify operator health.

    1. To check whether IBM Licensing is deployed by OLM from the CatalogSource, run the following command.

      kubectl get clusterserviceversion -n ibm-licensing -o jsonpath="v{.items[*].spec.version}"
      

      The Output should be the latest IBM Licensing release version. To check the latest IBM Licensing release version, see ibm-licensing-operator.

      The example output:

      //
      // Copyright 2022 IBM Corporation
      //
      // Licensed under the Apache License, Version 2.0 (the "License");
      // you may not use this file except in compliance with the License.
      // You may obtain a copy of the License at
      //
      // http://www.apache.org/licenses/LICENSE-2.0
      //
      // Unless required by applicable law or agreed to in writing, software
      // distributed under the License is distributed on an "AS IS" BASIS,
      // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      // See the License for the specific language governing permissions and
      // limitations under the License.
      //
      package version
      
      var (
               Version = "1.16.6"
      )
      

      Note: The above command assumes that you have created the Subscription in the ibm-licensing namespace. If your Operator deployment (CSV) shows Succeeded in the InstallPhase status, the operator is deployed successfully. Otherwise, check the ClusterServiceVersion objects status for details.

    2. Optional: Check if the operator is deployed. Run the following command:

      kubectl get deployment -n ibm-licensing | grep ibm-licensing-operator
      
  6. Configure the Kubernetes ingress. For more information, see Configuring ingress.

The Operator for IBM Licensing Service is created and only responsible for watching over the configuration and managing resources of IBM Licensing Service.

Verification

To check whether License Service components are properly installed and running, see Checking License Service components.