6 Deploying and Configuring the Prediction Service

Learn how to deploy and configure the prediction service for Oracle Monetization Suite in both Oracle Cloud Infrastructure (OCI) and non-OCI environments.

Topics in this document:

Deploying the Prediction Service in OCI and Non-OCI Environments

You can connect to a model on Oracle Cloud Infrastructure or on a non-OCI environment and deploy the prediction service independently, depending on your requirements. For this, you need to perform the installation steps described in "Overview of Installation Tasks", and then install the prediction service Helm charts by following the instructions below.

To install and deploy the prediction service using Helm charts:

  1. Download the recommendation service Helm charts from the deployment package.

    For more information, see "Downloading Packages for the Cloud Native Helm Charts and Docker Files" and "Setting Up Prerequisite Software and Tools".

  2. Generate the SSL certificate and private key:

    openssl req -newkey rsa:2048 -nodes -keyout privateKeyName.key -x509 -days 365 -out certificateName.crt
  3. Create a Kubernetes TLS Secret using your certificate and private key:

    kubectl create secret tls secretName --cert=certificateName.crt --key=privateKeyName.key
  4. Install the Ingress NGINX controller:

    • Add the ingress-nginx Helm repository:

      helm repo add ingress-nginx
    • Update the Helm repository:

      helm repo update
    • Install the Ingress Controller:

      helm install ingress-nginx ingress-nginx/ingress-nginx --namespace nginxNamespace --create-namespace
  5. Attach the service to the NGINX Controller:

    helm install ingress-nginx ingress-nginx/ingress-nginx --namespace nginxNamespace \ 
      --set controller.service.enableHttp=false \
      --set controller.service.enableHttps=true \ 
      --set controller.service.ports.https=443 \ 
      --set controller.service.nodePorts.https=31231 nodePort \ 
      --set controller.config.ssl-redirect=true \ 
      --set controller.config.force-ssl-redirect=true \ 
      --set controller.ingressClassResource.name=ingressClassName \ 
      --set controller.ingressClass=ingressClassName \ 
      --create-namespace
  6. Update the values.yaml file for your deployment:

    1. Set the following mount paths:

      • modelFilesPath: Mount path for model files. This is required for both OCI and non-OCI deployments.

      • logFilesPath: Mount path for log files. If not set, it defaults to modelFilesPath.

      • artifactsPath: Mount path for Python scripts and configuration files (use a separate mount path if using PVC). Leave blank if not required.

      • Create distinct PV and PVC for artifacts (predict-artifacts-pvc, if artifactsPath is set) and logs (predict-logs-pvc).

        Note:

        These paths are container directories and need not match host system paths.
      • Set folder permissions:

        groupadd -g 10001 oracle
        useradd -mr -u 10001 -g oracle oracle
        chown 10001:10001 -R mountPath
    2. Set the following configuration parameters:

      • imageRepository

      • IMAGE_TAG for both recommendationOrchestrator.image and recommendationPredictor.image

    3. Specify file paths in recommendationPredictor.configurableFiles:

      • modelPath: Path for the base folder where models are stored. Supported: PVC, OCI bucket (must include oci://), or Data Science URI (must include https://).

      • modelNames: File path for the list of models to be loaded at startup. Update and restart the service if new models are added.

        • For the PVC path, follow the {Stage}@{Model_Name} format. The files with '@' are stored in MLFlow. The remaining files are required supporting files.

        • For Data Flow, follow the {Name}@{OCI_Path} format.

        • For Data Science, follow the {name}@{Predict_URI} format.

        Note:

        You must include necessary mapper file paths in modelNames for k-Nearest Neighbors (KNN) or Cosine algorithms when using OCI Object Storage. Follow the {Name}@{OCI_Path} format.

      • ociConfigFile: Path to configuration file with OCI connection details.

      • preprocessScript: Path to data preprocessing script for prediction.

      • logConfigFile: Path to logging configuration file.

      • datascienceConfig: Path to configuration for data science job integration.

      Note:

      A sample is available for these files in the artifacts provided with the package: oci_config (for ociConfigFile), sample_predict_preprocess.py (for preprocessScript), and logging_config.py (for logConfigFile). You can configure these files as per your requirements.

    4. Set additional deployment parameters:
      • Hostname (ingress.host)
      • TLS secret (ingress.tlsSecretName)
      • Ingress class (ingress.ingressClassName)
      • IDCS configuration: Set identityURI, clientID, clientSecret as required. To disable IDCS, set recommendationOrchestrator.idcs.enabled to false.
      • Monitoring namespace (serviceMonitor.serviceNamespace)
  7. Create the StorageClass, PersistentVolume, and PersistentVolumeClaim resources. Update the host system path in pv-template.yaml as needed:

    kubectl apply -f helm/sc.yaml
    kubectl apply -f helm/pv-template.yaml
    kubectl apply -f helm/pvcTemplate.yaml
  8. Update the deployment template as required. Edit helm/cgiurecommendation/templates/deployment.yaml, especially the spec.template.spec.volumes section.

  9. Install the Helm charts:

    helm upgrade --install recommend-services helm/cgiurecommendation/ --namespace=recommend-service

Configuring and Using the Prediction Service

You can use and configure the prediction service using its REST API. The prediction service accepts API calls from other systems for inference and recommendation.

For the prediction service, you use the following REST service:

  • Prediction API (/recommend/predict)

    Use this API to generate predictions or recommendations for specific input data after models are trained and deployed.

Note:

Interactive REST API documentation is available through the Swagger UI at the /openapi/ui endpoint.