This is a cache of https://developer.ibm.com/tutorials/serve-custom-models-on-kubernetes-or-openshift/. It is a snapshot of the page as it appeared on 2025-11-15T03:32:53.648+0000.
Serve a custom model on a Kubernetes or Red Hat OpenShift cluster - IBM Developer
This content is no longer being updated or maintained. The content is provided “as is.” Given the rapid evolution of technology, some content, steps, or illustrations may have changed.
With IBM Watson NLP, IBM introduced a common library for natural language processing, document understanding, translation, and trust. IBM Watson NLP brings everything under one umbrella for consistency and ease of development and deployment. In this tutorial, learn how to take a Watson NLP model that you trained in IBM Watson Studio and serve it on a Kubernetes or Red Hat OpenShift cluster. The model is packaged as a container image using the model builder. The container images can be used in the same way as the pretrained Watson NLP models, that is, specified as init containers of Watson NLP Runtime Pods.
Reference Architecture
Prerequisites
To complete this tutorial, you first must complete the Consumer Complaint Classification notebook, which includes steps on training a custom ensemble model and saving it to the IBM Cloud Object Storage bucket associated with the project.
You have a Kubernetes or Red Hat OpenShift cluster on which you can deploy an application.
You have either the Kubernetes (kubectl) or Red Hat OpenShift (oc) CLI installed and logged into your cluster. The current namespace should be set to the namespace in which you will deploy the model service.
You have completed the Consumer Complaint Classification notebook, and saved the custom trained model named ensemble_model to the Cloud Object Storage bucket associated with the project.
Steps
Step 1. Save your model
Export your Watson NLP model from Watson Studio on IBM Cloud.
In the IBM Cloud Pak for Data GUI, navigate to the page for your Consumer Complaints Classification project. Click the Assets tab. There, you should find a model named ensemble_model stored as a ZIP file.
If the model is not there, go back to the notebook and ensure that you have followed the steps in the notebook.
Download the model into the models directory on your local machine. Use the vertical ellipsis to the right of the model name to open a menu with the download option.
Create a directory to unzip the file into.
mkdir models
Copy codeCopied!
mkdir models/ensemble_model
Copy codeCopied!
Unzip the file into the newly created directory. You might need to specify the path to the ZIP file if it is not in the current directory.
Ensure that you replace /path/to/models in the previous command with the path to your models directory. This command generates the file model-manifest.csv that is used during the build.
Create a secret in the namespace to give credentials to the registry used, and add this secret to the imagePullSecrets section so that your Pod can pull the image from the registry.
Deploy the model service.
If using Kubernetes:
kubectl apply -f deployment/deployment.yaml
Copy codeCopied!
If using Red Hat OpenShift:
oc apply -f deployment/deployment.yaml
Copy codeCopied!
The model service is now deployed.
Step 5. Test the service
Run a simple Python client program to test that the model is being served. Note that the client code is specific to the model. If you serve a different model you must update the client program.
Install the Python client library on your machine.
Go to the directory with the client program and run it.
cd Client
Copy codeCopied!
Run the program with a single string argument.
python client.py"Watson NLP is awesome"
Copy codeCopied!
The program returns output similar to the following code.
###### Calling GRPC endpoint = localhost:8085###### Calling remote GRPC model = ensemble_modelclasses{ class_name:"Credit reporting, credit repair services, or other personal consumer reports" confidence:0.328219473}classes{ class_name:"Debt collection" confidence:0.262635}classes{ class_name:"Credit card or prepaid card" confidence:0.16425848}classes{ class_name:"Checking or savings account" confidence:0.102090739}classes{ class_name:"Mortgage" confidence:0.0733666793}producer_id{ name:"Voting based Ensemble" version:"0.0.1"}
Copy codeCopied!
Conclusion
In this tutorial, you learned how to take a Watson NLP model that you trained in IBM Watson Studio and serve it on a Kubernetes or Red Hat OpenShift cluster.
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.