Lab: Automated Deployment (GitOps)
Click-Ops does not scale. GitOps does.
In the previous modules, we selected the Granite-8B (FP16) model and calculated the tuning parameters (max-model-len=8000) required to make it run safely on our hardware.
Now, we’re using the granite-3.3-2b-instruct, it’s .75% smaller and faster experience. So let’s increase the max-model-len=16000, providing more KV cache to support larger prompts.
You could open the OpenShift AI Dashboard, click "Add Model Server," copy-paste arguments, and hope you didn’t make a typo.
But what happens when you need to deploy 50 models? Or when you need to update the configuration across three clusters?
In this lab, We will deploy our tuned inference stack using a parameterized Infrastructure-as-Code scripts.
Fast Track to Model Deployment Setup
To begin, we need to acquire the automation scripts. We have packaged the entire "inference deployment" into a Git repository.
-
Open your OpenShift Terminal.
-
Clone the repository:
git clone https://github.com/RedHatQuickCourses/rhoai3-deploy.gitSwitch to the lab directory:
cd rhoai3-deploy
|
This utility automates the "grunt work" of the AI Engineer:
This script only works with Public/Ungated models (like IBM Granite 4.0 or Qwen 2.5). It does not support gated models (like Llama 3) that require a Hugging Face Token. |
Model Inference
Step 1: Prerequisites
Before proceeding, verify that your "Fast Track" script successfully populated the vault.
Step 2: The Runtime (The Engine)
RHOAI includes a certified vLLM runtime template. Instead of writing one from scratch, we will extract the official template from the cluster and install it in our namespace.
Extract and Apply the Runtime:
oc process vllm-cuda-runtime-template -n redhat-ods-applications | \
oc apply -f - -n model-deploy-lab
|
To view the runtime config, leave off the: | \ oc apply -f - -n model-deploy-lab, from the previous command. |
Verify the Runtime:
oc get servingruntime vllm-cuda-runtime -n model-deploy-lab
Create a Secret to Access the Models Files
In order to read the model files from the "vault" storage, we need a storage-config, which is stored as a kubernets secret. There is supplied file in the deploy folder called dataconn.yaml. Apply this file to create the secret.
apiVersion: v1
kind: Secret
metadata:
name: models-connection # Renaming for clarity (was 'models' or 'storage-config')
namespace: model-deploy-lab
labels:
# 1. VISIBILITY: Tells the Dashboard "I belong to RHOAI"
opendatahub.io/dashboard: "true"
# 2. MANAGEMENT: Tells RHOAI "I am a managed Data Connection"
opendatahub.io/managed: "true"
annotations:
# 3. TYPE: Tells the Injector "I am an S3 credential"
opendatahub.io/connection-type: s3
openshift.io/display-name: Models Bucket
type: Opaque
stringData:
# The keys MUST match standard AWS SDK expectations
AWS_ACCESS_KEY_ID: minio
AWS_SECRET_ACCESS_KEY: minio123
AWS_DEFAULT_REGION: us-east-1
AWS_S3_ENDPOINT: http://minio-service.model-deploy-lab:9000
AWS_S3_BUCKET: models
oc apply -f ./deploy/dataconn.yaml
oc secret link fast-track-sa models-connection
Step 3: The Deployment (The Workload)
We will now create the InferenceService. This Custom Resource binds our Runtime (the engine) to our Storage (the fuel).
Create the Manifest:
There is supplied file in the deploy folder called deploy.yaml.
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: granite3
namespace: model-deploy-lab
annotations:
# "RawDeployment" mode bypasses Serverless to prevent cold starts
serving.kserve.io/deploymentMode: RawDeployment
spec:
predictor:
serviceAccountName: fast-track-sa
model:
# The Format must match what the Runtime supports (vLLM)
modelFormat:
name: vLLM
# This name must match the runtime extracted in Step 2
runtime: vllm-cuda-runtime
# The path to your model in MinIO (s3://bucket/folder)
storageUri: s3://models/granite3
args:
- "--max-model-len=16000" # Limits context to 16k to save VRAM
- "--gpu-memory-utilization=0.95" # Uses 95% of GPU (leaves 5% for overhead)
# - "--distributed-executor-backend=mp" # Required for some multi-GPU setups
resources:
requests:
nvidia.com/gpu: "1"
memory: "8Gi"
limits:
nvidia.com/gpu: "1"
memory: "10Gi"
Step 4: Validate the API
Once the model is ready, we can test it using the OpenAI-compatible API provided by vLLM.
Retrieve the Inference URL:
export MODEL_URL=$(oc get inferenceservice granite3 -n model-deploy-lab -o jsonpath='{.status.url}')
echo "Targeting: $MODEL_URL"
curl -k -X POST "${MODEL_URL}/v1/chat/completions" \
-H "Content-Type: application/json" \
-d '{
"model": "granite3",
"messages": [{"role": "user", "content": "Write a Poem about AI"}]
}'
Expected Output:
{
"id": "cmpl-...",
"object": "chat.completion",
"created": 1700000000,
"model": "granite3",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Pods rise in the cloud,\nGPUs hum with quiet power,\nCode serves thought to all."
},
"finish_reason": "stop"
}
]
}
That’s a Wrap
This is one example of model inference using the built-in runtime from the command line.
Based on your feedback, we’ll update this course accordingly:
-
What type of model inference examples should be add to this course?
-
What additional features need to be supported such as tool calling templates?
Let us know by creating an issue in the course repository