Lab: Automating the AI Data Foundation

Stop clicking. Start engineering.

In a mature AI Factory, you do not manually type AWS keys into a web form for every new project. You build automation that governs how data is accessed and stored.

In OpenShift AI 3.3, storage configuration dictates pipeline performance and model startup velocity. In this lab, you will act as the Lead Platform Engineer. You will replace manual configuration with a set of standardized deployment scripts that instantly provision the three pillars of RHOAI storage: Persistence (Pipeline Workspaces), Acceleration (OCI Modelcars), and Connectivity (S3/URI).

Prerequisites

  • Access to an OpenShift cluster with OpenShift AI 3.3 and OpenShift Data Foundation (ODF) installed.

  • cluster-admin privileges (required to patch Persistent Volumes).

  • The oc CLI tool installed.

1. Set Up Your Workspace

We have packaged the automation scripts into a Git repository.

# Clone the automation repo
git clone https://github.com/RedHatQuickCourses/rhoai3-storage.git
cd rhoai3-storage/deploy
chmod +x *.sh

# Create the project for our factory
oc new-project ai-supply-chain

Part 1: Adjust the Deployment for your Storage

Action: Discover Your Storage Capabilities

Not every cluster uses the same underlying storage. Cloud block storage (like AWS EBS) behaves very differently than network file storage (like CephFS). You must identify what is available on your cluster.

# List available storage classes
oc get sc
  • If your default is Block Storage (e.g., gp2-csi, gp3-csi): It strictly requires ReadWriteOnce access and uses WaitForFirstConsumer (meaning the physical disk isn’t created until a pod requests it).

  • If your default is File Storage (e.g., ocs-external-storagecluster-cephfs): It supports ReadWriteMany access and binds instantly.

Action: Update the Deployment Script

Now, you must adapt the baseline deployment script to match your cluster’s physics.

  1. Open cluster-storage.sh in your text editor.

  2. Update the STORAGE_CLASS variable to match the exact name from your oc get sc output (e.g., gp3-csi).

  3. Under the spec.accessModes section of the YAML, ensure it matches your storage type:

    • Change it to - ReadWriteOnce if using block storage (like AWS gp3-csi).

    • Leave it as - ReadWriteMany if using file storage (like CephFS).

  4. Save the file.

Action: Provision & Force Binding

Because cloud block storage often waits for a consumer, we will provision the claim and immediately spin up a "Binder Pod" to force the cloud provider to create the physical hard drive.

# 1. Provision the Storage Claim (10GB)
./cluster-storage.sh ai-supply-chain golden-dataset 10

# 2. Spin up a dummy pod to force the cloud to create the disk
cat <<EOF | oc apply -n ai-supply-chain -f -
apiVersion: v1
kind: Pod
metadata:
  name: storage-binder
spec:
  containers:
    - name: binder
      image: registry.access.redhat.com/ubi9/ubi-minimal
      command: ["tail", "-f", "/dev/null"]
      resources:
        requests:
          cpu: "10m"
          memory: "50Mi"
      volumeMounts:
        - mountPath: "/data"
          name: my-vol
  volumes:
    - name: my-vol
      persistentVolumeClaim:
        claimName: golden-dataset
EOF

# 3. Wait for the disk to be created and attached
echo "⏳ Waiting for cloud storage to provision..."
oc wait --for=condition=Ready pod/storage-binder -n ai-supply-chain --timeout=120s

Action: Protect the Dataset

Now that the physical disk (PV) exists, we must apply a safety protocol. By default, if a project is deleted, the disk is destroyed. We will patch the Persistent Volume to ensure the data survives.

# 1. Ask Kubernetes for the name of the newly created physical hard drive
PV_NAME=$(oc get pvc golden-dataset -n ai-supply-chain -o jsonpath='{.spec.volumeName}')

# 2. Patch that hard drive's policy to 'Retain'
oc patch pv $PV_NAME -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'

# 3. Clean up the Binder Pod (The data remains safe on the retained disk!)
oc delete pod storage-binder -n ai-supply-chain

# Verify the policy was applied successfully
oc get pv $PV_NAME

Result: You should see RECLAIM POLICY: Retain. Your pipeline workspace is physically bound and protected from accidental deletion.

Part 2: The Velocity Tier (OCI Modelcars)

Next, we enable "Instant Scaling" by creating a connection to the Red Hat Modelcar registry. This tells OpenShift AI 3.3 to use the underlying CRI-O container cache rather than downloading massive files.

Action: Connect the Accelerator

# Usage: ./modelcar.sh <project>
./modelcar.sh ai-supply-chain

Result: A Secret granite-3-8b-modelcar is created. Note that the script utilizes the required 3.3 backend routing annotation (opendatahub.io/connection-type-protocol: oci) AND the UI visibility label (opendatahub.io/managed: "true").

Part 3: The Air-Gap Simulation (The Helper Pod)

In a highly secure enterprise, your cluster might not have internet access to download models. You need a way to "Side-Load" data directly into your PVC so you can use the OpenShift AI 3.3 pvc:// deployment routing.

We will spin up a temporary "Helper Pod" to stage data onto our golden-dataset volume.

Action: Side-Load the Model (Admin Override)

In OpenShift, strict Security Context Constraints (SCCs) force pods to run as randomized, non-root users. However, newly provisioned cloud volumes are often owned by root. To write to the root of this volume, we must deploy our Helper Pod with elevated privileges.

# 1. Create a dedicated Admin Service Account
oc create sa side-loader-sa -n ai-supply-chain

# 2. Grant it the 'anyuid' SCC to allow root-level disk writes
oc adm policy add-scc-to-user anyuid -z side-loader-sa -n ai-supply-chain

# 3. Spin up the Data Loader Pod using our new Service Account
cat <<EOF | oc apply -n ai-supply-chain -f -
apiVersion: v1
kind: Pod
metadata:
  name: data-loader
spec:
  serviceAccountName: side-loader-sa
  containers:
    - name: loader
      image: registry.access.redhat.com/ubi9/ubi
      command: ["tail", "-f", "/dev/null"]
      # Force the container to run as root to write to the newly formatted PV
      securityContext:
        runAsUser: 0
      volumeMounts:
        - mountPath: "/data"
          name: my-vol
  volumes:
    - name: my-vol
      persistentVolumeClaim:
        claimName: golden-dataset
EOF

# 4. Wait for it to be Ready
oc wait --for=condition=Ready pod/data-loader -n ai-supply-chain --timeout=60s

# 5. Simulate "Side-Loading" the Model
echo "Simulated Model Weights v1.0" > model.safetensors
cat model.safetensors | oc exec -i data-loader -n ai-supply-chain -- sh -c 'cat > /data/model.safetensors'

# 6. Verify the file was written successfully!
oc exec data-loader -n ai-supply-chain -- cat /data/model.safetensors

# 7. Clean up the Helper Pod and Service Account
oc delete pod data-loader -n ai-supply-chain
oc delete sa side-loader-sa -n ai-supply-chain

Result: You have successfully bypassed the internet and staged data directly onto a disconnected volume. Because of our Retain policy, deleting the pod keeps the data safe on the disk.

Part 4: The Ingestion Layer (S3 & URI)

Finally, we provide the standard connections for raw data ingestion and precise external links.

Action: Connect Data Lakes and URIs

# Connect the simulated corporate data lake
./dataconnect.sh ai-supply-chain corporate-data-lake

# Connect a precise URI to a specific external model file
./uri.sh ai-supply-chain

Part 5: The 3.3 Payoff (Deployment Routing)

You have just architected a complete storage solution via the CLI. Now, let’s see how OpenShift AI 3.3 consumes this architecture using Direct URIs.

  1. Open the OpenShift AI Dashboard.

  2. Navigate to Data Science Projects → ai-supply-chain.

  3. Under the Data connections tab, verify your connections are present and labeled correctly (S3, OCI, URI).

  4. Click the Deployments tab, and click Deploy model.

Notice how the UI expects you to route the deployment based on the architecture you just built. You can now define your deployment locations using the exact 3.3 syntax:

  • To use the S3 Connection: s3://private-models/my-model

  • To use the OCI Accelerator: oci://quay.io/redhat-ai-services/modelcar-catalog:granite-3.2-8b-instruct

  • To use the Air-Gapped PVC: pvc://golden-dataset/model.safetensors