Installing License Service on the Kubernetes cluster

Learn how to install License Service on Kubernetes with kubectl.

Prerequisites

  • Administrator permissions for the cluster.
  • kubectl version 1.19 or higher.
  • Linux or iOS.

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

Verifying if License Service is already installed on the cluster

Check if License Service is already installed on the cluster to prevent the use of multiple License Service copies to report the license usage of multiple IBM Cloud Paks that are running on the same cluster.

Important: If you install multiple instances of License Service on one cluster, License Service generates an incorrect license usage report.

To check if License Service is already installed on the cluster, run the following command:

kubectl get deployment --all-namespaces | grep ibm-licensing-operator
  • If you get a deployment in response, License Service is already installed on the cluster. Upgrade to the latest version to benefit from all newest features and improvements. For more information, see Backing up and upgrading License Service.

  • If you get no deployments in response, proceed with the installation of License Service.

Installation

  1. Install 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, OLM is installed.

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

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

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

      olm_version=v0.33.0
      curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${olm_version}/install.sh -o install.sh
      chmod +x install.sh
      ./install.sh ${olm_version}
      

      Troubleshooting: If you get an error, upgrade your Kubernetes server version or use older version of 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
        grpcPodConfig:
          securityContextConfig: restricted
      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 recommended namespace for License Service installation is ibm-licensing. The commands in the installation instructions contain this default namespace. However, you can install License Service in any other custom namespace. If you install License Service in a custom namespace, replace ibm-licensing with the name of the 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: {{site.data.keyword.cs_channel_cert}}
        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 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. Update the License Service instance that was created during installation to accept the license.

    1. Create the accept-license.yaml file with the following content:

      spec:
        license:
          accept: true
      
    2. Run the following command:

      kubectl patch IBMLicensing instance --type merge --patch-file accept-license.yaml
      
  7. 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.