Scenarios for other frameworks

This article provides basic validation scenarios for running MLOps Studio Trainer workloads with frameworks other than PyTorch. It focuses on TFJob, JAXJob, and XGBoostJob, using the same general testing approach as in the main Trainer article: create a notebook, submit a job from the notebook, verify pod status and logs, and then clean up the resources.

Overview

MLOps Studio training workloads are not limited to PyTorch. The same notebook-based workflow can be adapted for other supported frameworks, including TensorFlow, JAX, and XGBoost.

The scenarios below are intended as functional checks. They help verify that:

  • the framework-specific job resource can be created from a notebook,

  • the training pod or pods start correctly in the user namespace,

  • logs confirm that the training workload is actually running,

  • the created resources can be removed cleanly after the test.

Prerequisites

Before starting any of the scenarios below, make sure that:

  1. You have a working MLOps Studio notebook.

  2. The notebook is running in your own namespace.

  3. The notebook image includes the tools needed to run Python and shell commands.

  4. The cluster allows creation of the framework-specific job type you want to test.

  5. Your namespace has enough CPU and memory quota for the selected workload.

In all scenarios below, the first notebook steps are the same:

  1. Create a notebook with the pytorch-full option.

  2. Connect to the notebook.

  3. Install the required Python dependencies.

  4. Load the in-cluster Kubernetes configuration and detect the current namespace.

Here will be a basic scenario for the correct operation of the Trainer for the following frameworks: TFJob, JAXJob, and XGBoostJob. This is a modification of the Trainer launch scenario from the page: ENG: Trainer scenarios

Trainer launch scenario for TFJob

Steps

  1. Create a Notebook with the pytorch-full option and connect to the notebook

  2. Add and run

    !pip install -q kubernetes pyyaml pandas
    
  3. Add and run

    from kubernetes import client, config
    from kubernetes.client.rest import ApiException
    import yaml, time, pandas as pd
    from IPython.display import clear_output
    import subprocess
    
    # Connect to the cluster
    config.load_incluster_config()
    custom_api = client.CustomObjectsApi(client.ApiClient())
    
    # Get namespace
    with open('/var/run/secrets/kubernetes.io/serviceaccount/namespace', 'r') as f:
        NAMESPACE = f.read().strip()
    
    print(f"Setup OK! Namespace: {NAMESPACE}")
    
  4. Add and run

    TFJOB_NAME = "mnist-tfjob-optimized"
    
    tf_job = {
        "apiVersion": "kubeflow.org/v1",
        "kind": "TFJob",
        "metadata": {
            "name": TFJOB_NAME,
            "namespace": NAMESPACE
        },
        "spec": {
            "tfReplicaSpecs": {
                "Worker": {
                    "replicas": 1,
                    "restartPolicy": "OnFailure",
                    "template": {
                        "metadata": {
                            "annotations": {
                                # TFJob in user-namespace often requires disabling the Istio sidecar
                                "sidecar.istio.io/inject": "false"
                            }
                        },
                        "spec": {
                            "containers": [{
                                "name": "tensorflow",
                                # image from the Katib/Training Operator example for MNIST with metrics
                                "image": "ghcr.io/kubeflow/katib/tf-mnist-with-summaries:latest",
                                "command": [
                                    "python",
                                    "/opt/tf-mnist-with-summaries/mnist.py",
                                    "--epochs=1",
                                    "--batch-size=16",
                                    "--learning-rate=0.01",
                                    "--log-path=/tmp/tf-logs"
                                ],
                                "resources": {
                                    "requests": {
                                        "cpu": "400m",
                                        "memory": "800Mi"
                                    },
                                    "limits": {
                                        "cpu": "500m",
                                        "memory": "1Gi"
                                    }
                                }
                            }]
                        }
                    }
                }
            }
        }
    }
    
    try:
        custom_api.create_namespaced_custom_object(
            group="kubeflow.org",
            version="v1",
            namespace=NAMESPACE,
            plural="tfjobs",
            body=tf_job
        )
        print("TFJob created!")
    except ApiException as e:
        if e.status == 409:
            print("Error 409 - AlreadyExists (TFJob already exists). Delete it or change TFJOB_NAME.")
        else:
            raise
    
  5. Add and run

    import subprocess
    
    # Selector by job-name
    selector = f"training.kubeflow.org/job-name={TFJOB_NAME}"
    
    result = subprocess.run(
        ["kubectl", "get", "pods", "-n", NAMESPACE, "-l", selector],
        capture_output=True,
        text=True
    )
    
    print("Pod status:\n")
    print(result.stdout)
    
    # If Running or Completed, show logs
    if "Running" in result.stdout or "Completed" in result.stdout:
        print("\nLogs (last 30 lines):\n")
        logs = subprocess.run(
            ["kubectl", "logs", "-n", NAMESPACE, "-l", selector, "--tail=30", "--all-containers=true"],
            capture_output=True,
            text=True
        )
        print(logs.stdout)
    
    elif "Pending" in result.stdout:
        print("\nPending...\n")
        describe = subprocess.run(
            ["kubectl", "describe", "pod", "-n", NAMESPACE, "-l", selector],
            capture_output=True,
            text=True
        )
    
        events_start = describe.stdout.find("Events:")
        if events_start > 0:
            print(describe.stdout[events_start:])
    

Results:

  1. Logs of this type

    Status pod:
    
    NAME                             READY   STATUS    RESTARTS   AGE
    mnist-tfjob-optimized-worker-0   1/1     Running   0          3m54s
    
    
    Logs (last 30 lines):
    
    2026-01-08 14:28:12.513796: I external/local_tsl/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.
    2026-01-08 14:28:12.517668: I external/local_tsl/tsl/cuda/cudart_stub.cc:32] Could not find cuda drivers on your machine, GPU will not be used.
    2026-01-08 14:28:12.610560: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
    To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
    2026-01-08 14:28:14.458457: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
    Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz
    
           0/11490434
       16384/11490434
       40960/11490434
       57344/11490434
       81920/11490434
      114688/11490434
      163840/11490434
      221184/11490434
      294912/11490434
      393216/11490434
      532480/11490434
      704512/11490434 ━[
      933888/11490434 ━[0
     1245184/11490434 ━━
     1671168/11490434 ━━
     2244608/11490434 ━━━
     2998272/11490434 ━━━
     4030464/11490434 ━━━
     5373952/11490434 ━━━
     7192576/11490434 ━━━
     9584640/11490434 ━━━
    11490434/11490434 ━━━━━━━━━━━━━━━━━━━━ 1s 0us/step
    2026-01-08 14:28:18.719305: W external/local_tsl/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 188160000 exceeds 10% of free system memory.
    2026-01-08 14:28:19.267547: W external/local_tsl/tsl/framework/cpu_allocator_impl.cc:83] Allocation of 188160000 exceeds 10% of free system memory.
    
  2. Run in console

    kubectl logs mnist-tfjob-optimized-worker-0 -c tensorflow
    

    and check if the results are something like:

    Train Epoch: 1 [0/60000 (0%)]     loss=2.3303, accuracy=6.2500
    Train Epoch: 1 [1600/60000 (3%)]  loss=0.9199, accuracy=75.6807
    Train Epoch: 1 [3200/60000 (5%)]  loss=0.6078, accuracy=83.4888
    Train Epoch: 1 [4800/60000 (8%)]  loss=0.4944, accuracy=86.4203
    Train Epoch: 1 [6400/60000 (11%)] loss=0.4308, accuracy=88.1858
    Train Epoch: 1 [8000/60000 (13%)] loss=0.3820, accuracy=89.3837
    Train Epoch: 1 [9600/60000 (16%)] loss=0.3537, accuracy=90.1726
    Train Epoch: 1 [11200/60000 (19%)]        loss=0.3349, accuracy=90.5314
    Train Epoch: 1 [12800/60000 (21%)]        loss=0.3107, accuracy=91.2219
    Train Epoch: 1 [14400/60000 (24%)]        loss=0.2943, accuracy=91.6829
    Train Epoch: 1 [16000/60000 (27%)]        loss=0.2825, accuracy=91.9955
    Train Epoch: 1 [17600/60000 (29%)]        loss=0.2734, accuracy=92.2457
    Train Epoch: 1 [19200/60000 (32%)]        loss=0.2671, accuracy=92.3970
    Train Epoch: 1 [20800/60000 (35%)]        loss=0.2575, accuracy=92.6115
    Train Epoch: 1 [22400/60000 (37%)]        loss=0.2508, accuracy=92.7909
    Train Epoch: 1 [24000/60000 (40%)]        loss=0.2442, accuracy=92.9714
    Train Epoch: 1 [25600/60000 (43%)]        loss=0.2389, accuracy=93.0903
    Train Epoch: 1 [27200/60000 (45%)]        loss=0.2338, accuracy=93.2466
    Train Epoch: 1 [28800/60000 (48%)]        loss=0.2300, accuracy=93.3752
    Train Epoch: 1 [30400/60000 (51%)]        loss=0.2260, accuracy=93.4936
    Train Epoch: 1 [32000/60000 (53%)]        loss=0.2214, accuracy=93.6313
    Train Epoch: 1 [33600/60000 (56%)]        loss=0.2186, accuracy=93.6756
    Train Epoch: 1 [35200/60000 (59%)]        loss=0.2148, accuracy=93.7756
    Train Epoch: 1 [36800/60000 (61%)]        loss=0.2119, accuracy=93.8424
    Train Epoch: 1 [38400/60000 (64%)]        loss=0.2081, accuracy=93.9634
    Train Epoch: 1 [40000/60000 (67%)]        loss=0.2065, accuracy=94.0199
    Train Epoch: 1 [41600/60000 (69%)]        loss=0.2058, accuracy=94.0624
    Train Epoch: 1 [43200/60000 (72%)]        loss=0.2021, accuracy=94.1573
    Train Epoch: 1 [44800/60000 (75%)]        loss=0.1999, accuracy=94.2253
    Train Epoch: 1 [46400/60000 (77%)]        loss=0.1968, accuracy=94.3037
    Train Epoch: 1 [48000/60000 (80%)]        loss=0.1959, accuracy=94.3456
    Train Epoch: 1 [49600/60000 (83%)]        loss=0.1932, accuracy=94.3950
    Train Epoch: 1 [51200/60000 (85%)]        loss=0.1914, accuracy=94.4588
    Train Epoch: 1 [52800/60000 (88%)]        loss=0.1895, accuracy=94.4979
    Train Epoch: 1 [54400/60000 (91%)]        loss=0.1883, accuracy=94.5678
    Train Epoch: 1 [56000/60000 (93%)]        loss=0.1884, accuracy=94.5908
    Train Epoch: 1 [57600/60000 (96%)]        loss=0.1868, accuracy=94.6282
    Train Epoch: 1 [59200/60000 (99%)]        loss=0.1850, accuracy=94.6754
    Test Loss: 0.1166, Test Accuracy: 96.8000
    
  3. Cleanup after test

    import time
    from kubernetes.client.rest import ApiException
    
    jobs_to_delete = [TFJOB_NAME]
    
    for job_name in jobs_to_delete:
        try:
            custom_api.delete_namespaced_custom_object(
                group="kubeflow.org",
                version="v1",
                namespace=NAMESPACE,
                plural="tfjobs",
                name=job_name
            )
            print(f"Deleted {job_name}")
        except ApiException as e:
            if e.status != 404:
                raise
    
    time.sleep(5)
    print("Cleanup completed")
    

Scenario - launching Trainer for JAXJob

Steps:

  1. Create a Notebook with the pytorch-full option and connect to the notebook

  2. Add and run:

    !pip install -q kubernetes pyyaml pandas
    
  3. Add and run:

    from kubernetes import client, config
    from kubernetes.client.rest import ApiException
    import time
    import subprocess
    
    # Connect to the cluster
    config.load_incluster_config()
    api_client = client.ApiClient()
    
    custom_api = client.CustomObjectsApi(api_client)
    core_api = client.CoreV1Api(api_client)
    
    # Get namespace
    with open('/var/run/secrets/kubernetes.io/serviceaccount/namespace', 'r') as f:
        NAMESPACE = f.read().strip()
    
    print(f"Setup OK! Namespace: {NAMESPACE}")
    
    # Optional, without cluster-scope CRD check - verify access to jaxjobs in the namespace
    try:
        custom_api.list_namespaced_custom_object(
            group="kubeflow.org",
            version="v1",
            namespace=NAMESPACE,
            plural="jaxjobs",
            limit=1
        )
        print("JAXJob API: OK (you have access in the namespace)")
    except ApiException as e:
        if e.status == 404:
            print("JAXJob API: 404 (CRD/operator may not be installed or a different version is used)")
        elif e.status == 403:
            print("JAXJob API: 403 (missing RBAC permissions for jaxjobs in the namespace)")
        else:
            raise
    
  4. Add and run:

    JAXJOB_NAME = "jaxjob-optimized"
    COORD_SVC_NAME = f"{JAXJOB_NAME}-worker-0"
    
    # 1) Coordinator service for worker-0 - gives stable DNS: jaxjob-optimized-worker-0
    coord_svc = {
        "apiVersion": "v1",
        "kind": "Service",
        "metadata": {
            "name": COORD_SVC_NAME,
            "namespace": NAMESPACE
        },
        "spec": {
            "selector": {
                "training.kubeflow.org/job-name": JAXJOB_NAME,
                "training.kubeflow.org/replica-type": "worker",
                "training.kubeflow.org/replica-index": "0"
            },
            "ports": [{
                "name": "jax-dist",
                "port": 6666,
                "targetPort": 6666
            }]
        }
    }
    
    try:
        core_api.create_namespaced_service(namespace=NAMESPACE, body=coord_svc)
        print(f"Service created: {COORD_SVC_NAME}")
    except ApiException as e:
        if e.status == 409:
            print(f"Service already exists: {COORD_SVC_NAME} (OK)")
        else:
            raise
    
    # 2) JAXJob
    jax_job = {
        "apiVersion": "kubeflow.org/v1",
        "kind": "JAXJob",
        "metadata": {
            "name": JAXJOB_NAME,
            "namespace": NAMESPACE
        },
        "spec": {
            "jaxReplicaSpecs": {
                "Worker": {
                    "replicas": 2,
                    "restartPolicy": "OnFailure",
                    "template": {
                        "metadata": {
                            "annotations": {
                                # Safe in environments with Istio; harmless if Istio is not present
                                "sidecar.istio.io/inject": "false"
                            }
                        },
                        "spec": {
                            "containers": [{
                                "name": "jax",
                                "image": "ghcr.io/kubeflow/training-v1/jaxjob-simple:latest",
                                "command": ["python3", "train.py"],
                                "ports": [{"containerPort": 6666}],
                                "resources": {
                                    "requests": {"cpu": "200m", "memory": "512Mi"},
                                    "limits": {"cpu": "300m", "memory": "768Mi"}
                                }
                            }]
                        }
                    }
                }
            }
        }
    }
    
    try:
        custom_api.create_namespaced_custom_object(
            group="kubeflow.org",
            version="v1",
            namespace=NAMESPACE,
            plural="jaxjobs",
            body=jax_job
        )
        print("Job created!")
    except ApiException as e:
        if e.status == 409:
            print("Trainer - Error 409 - AlreadyExists (JAXJob already exists)")
        else:
            raise
    
  5. Add and run:

    import subprocess
    
    selector = f"training.kubeflow.org/job-name={JAXJOB_NAME}"
    
    # Check pod status
    result = subprocess.run(
        ["kubectl", "get", "pods", "-n", NAMESPACE, "-l", selector],
        capture_output=True,
        text=True
    )
    
    print("Pod status:\n")
    print(result.stdout)
    
    # If Running or Completed, show the logs of the coordinator (worker-0)
    if "Running" in result.stdout or "Completed" in result.stdout:
        print("\nLogs (last 30 lines) - worker-0 coordinator:\n")
        logs = subprocess.run(
            ["kubectl", "logs", "-n", NAMESPACE,
             "-l", f"{selector},training.kubeflow.org/replica-type=worker,training.kubeflow.org/replica-index=0",
             "--tail=30"],
            capture_output=True,
            text=True
        )
        print(logs.stdout)
    
    elif "Pending" in result.stdout:
        print("\nPending...\n")
        describe = subprocess.run(
            ["kubectl", "describe", "pod", "-n", NAMESPACE, "-l", selector],
            capture_output=True,
            text=True
        )
        events_start = describe.stdout.find("Events:")
        if events_start > 0:
            print(describe.stdout[events_start:])
    

Results:

  1. Results should look more or less like this:

    Status pod:
    
    NAME                        READY   STATUS      RESTARTS   AGE
    jaxjob-optimized-worker-0   0/1     Completed   0          62s
    jaxjob-optimized-worker-1   0/1     Completed   0          62s
    
    
    Logs (last 30 lines) - worker-0 coordinator:
    
    INFO:2026-01-08 22:09:43,003:jax._src.distributed:132: Starting JAX distributed service on [::]:6666
    I0108 22:09:43.003840 124997704158080 distributed.py:132] Starting JAX distributed service on [::]:6666
    INFO:2026-01-08 22:09:43,005:jax._src.distributed:149: Connecting to JAX distributed service on jaxjob-optimized-worker-0:6666
    I0108 22:09:43.005186 124997704158080 distributed.py:149] Connecting to JAX distributed service on jaxjob-optimized-worker-0:6666
    INFO:2026-01-08 22:09:46,139:jax._src.xla_bridge:752: Unable to initialize backend 'tpu': INTERNAL: Failed to open libtpu.so: libtpu.so: cannot open shared object file: No such file or directory
    I0108 22:09:46.139152 124997704158080 xla_bridge.py:752] Unable to initialize backend 'tpu': INTERNAL: Failed to open libtpu.so: libtpu.so: cannot open shared object file: No such file or directory
    JAX process 0/1 initialized on jaxjob-optimized-worker-0
    JAX global devices:[CpuDevice(id=0), CpuDevice(id=131072)]
    JAX local devices:[CpuDevice(id=0)]
    JAX device count:2
    JAX local device count:1
    [2.]
    
  2. Cleanup after test

    import time
    from kubernetes.client.rest import ApiException
    
    # Delete JAXJob
    try:
        custom_api.delete_namespaced_custom_object(
            group="kubeflow.org",
            version="v1",
            namespace=NAMESPACE,
            plural="jaxjobs",
            name=JAXJOB_NAME
        )
        print(f"Deleted {JAXJOB_NAME}")
    except ApiException as e:
        if e.status != 404:
            raise
    
    # Delete the coordinator Service
    try:
        core_api.delete_namespaced_service(
            name=COORD_SVC_NAME,
            namespace=NAMESPACE
        )
        print(f"Deleted Service {COORD_SVC_NAME}")
    except ApiException as e:
        if e.status != 404:
            raise
    
    time.sleep(5)
    print("Cleanup completed")
    

Scenario - launching Trainer for XGBoostJob

Steps:

  1. Create a Notebook with the pytorch-full option and connect to the notebook.

  2. Add and run:

    !pip install -q kubernetes pyyaml pandas
    
  3. Add and run:

    from kubernetes import client, config
    from kubernetes.client.rest import ApiException
    import time
    import subprocess
    
    # Connect to the cluster
    config.load_incluster_config()
    api_client = client.ApiClient()
    custom_api = client.CustomObjectsApi(api_client)
    
    # Get namespace
    with open('/var/run/secrets/kubernetes.io/serviceaccount/namespace', 'r') as f:
        NAMESPACE = f.read().strip()
    
    print(f"Setup OK! Namespace: {NAMESPACE}")
    
  4. Add and run:

    XGBJOB_NAME = "xgboost-optimized"
    
    xgb_job = {
        "apiVersion": "kubeflow.org/v1",
        "kind": "XGBoostJob",
        "metadata": {
            "name": XGBJOB_NAME,
            "namespace": NAMESPACE
        },
        "spec": {
            "runPolicy": {
                "cleanPodPolicy": "None"
            },
            "xgbReplicaSpecs": {
                "Master": {
                    "replicas": 1,
                    "restartPolicy": "Never",
                    "template": {
                        "metadata": {
                            "annotations": {
                                "sidecar.istio.io/inject": "false"
                            }
                        },
                        "spec": {
                            "containers": [{
                                "name": "xgboost",
                                "image": "docker.io/merlintang/xgboost-dist-iris:1.1",
                                "imagePullPolicy": "IfNotPresent",
                                "ports": [{
                                    "containerPort": 9991,
                                    "name": "xgboostjob-port",
                                    "protocol": "TCP"
                                }],
                                "args": [
                                    "--job_type=Train",
                                    "--xgboost_parameter=objective:multi:softprob,num_class:3",
                                    "--n_estimators=10",
                                    "--learning_rate=0.1",
                                    "--model_path=/tmp/xgboost-model",
                                    "--model_storage_type=local"
                                ],
                                "resources": {
                                    "requests": {"cpu": "300m", "memory": "768Mi"},
                                    "limits": {"cpu": "500m", "memory": "1Gi"}
                                }
                            }]
                        }
                    }
                },
                "Worker": {
                    "replicas": 2,
                    "restartPolicy": "ExitCode",
                    "template": {
                        "metadata": {
                            "annotations": {
                                "sidecar.istio.io/inject": "false"
                            }
                        },
                        "spec": {
                            "containers": [{
                                "name": "xgboost",
                                "image": "docker.io/merlintang/xgboost-dist-iris:1.1",
                                "imagePullPolicy": "IfNotPresent",
                                "ports": [{
                                    "containerPort": 9991,
                                    "name": "xgboostjob-port",
                                    "protocol": "TCP"
                                }],
                                "args": [
                                    "--job_type=Train",
                                    "--xgboost_parameter=objective:multi:softprob,num_class:3",
                                    "--n_estimators=10",
                                    "--learning_rate=0.1"
                                ],
                                "resources": {
                                    "requests": {"cpu": "300m", "memory": "768Mi"},
                                    "limits": {"cpu": "500m", "memory": "1Gi"}
                                }
                            }]
                        }
                    }
                }
            }
        }
    }
    
    try:
        custom_api.create_namespaced_custom_object(
            group="kubeflow.org",
            version="v1",
            namespace=NAMESPACE,
            plural="xgboostjobs",
            body=xgb_job
        )
        print("Job created!")
    except ApiException as e:
        if e.status == 409:
            print("Trainer - Error 409 - AlreadyExists")
        else:
            raise
    
  5. Add and run:

    import subprocess
    
    def kubectl_get_pods(label_selector: str):
        return subprocess.run(
            ["kubectl", "get", "pods", "-n", NAMESPACE, "-l", label_selector],
            capture_output=True,
            text=True
        )
    
    def has_pods(output: str) -> bool:
        lines = [l for l in output.strip().splitlines() if l.strip()]
        return len(lines) > 1  # header + at least 1 pod
    
    # 1) Try selector "job-name=..."
    sel_a = f"job-name={XGBJOB_NAME}"
    res_a = kubectl_get_pods(sel_a)
    
    # 2) If empty, try "training.kubeflow.org/job-name=..."
    sel_b = f"training.kubeflow.org/job-name={XGBJOB_NAME}"
    res_b = kubectl_get_pods(sel_b)
    
    if has_pods(res_a.stdout):
        selector = sel_a
        pods_out = res_a.stdout
    else:
        selector = sel_b
        pods_out = res_b.stdout
    
    print("Pod status:\n")
    print(pods_out)
    
    # If Running or Completed, show the logs of master-0
    if "Running" in pods_out or "Completed" in pods_out:
    
        # Try to find master-0 by replica-type/master
        def get_master_podname():
            # style A
            r1 = subprocess.run(
                ["kubectl", "get", "pods", "-n", NAMESPACE,
                 "-l", f"{selector},replica-type=master,replica-index=0",
                 "-o", "jsonpath={.items[0].metadata.name}"],
                capture_output=True, text=True
            )
            if r1.returncode == 0 and r1.stdout.strip():
                return r1.stdout.strip()
    
            # style B
            r2 = subprocess.run(
                ["kubectl", "get", "pods", "-n", NAMESPACE,
                 "-l", f"{selector},training.kubeflow.org/replica-type=master,training.kubeflow.org/replica-index=0",
                 "-o", "jsonpath={.items[0].metadata.name}"],
                capture_output=True, text=True
            )
            return r2.stdout.strip()
    
        master_pod = get_master_podname()
    
        print("\nLogs (last 30 lines) - master-0:\n")
        logs = subprocess.run(
            ["kubectl", "logs", "-n", NAMESPACE, master_pod, "--tail=30"],
            capture_output=True, text=True
        )
        print(logs.stdout)
    
    elif "Pending" in pods_out:
        print("\nPending...\n")
        describe = subprocess.run(
            ["kubectl", "describe", "pod", "-n", NAMESPACE, "-l", selector],
            capture_output=True,
            text=True
        )
        events_start = describe.stdout.find("Events:")
        if events_start > 0:
            print(describe.stdout[events_start:])
    

Results:

  1. Results should look more or less like this:

    Status pod:
    
    NAME                         READY   STATUS      RESTARTS   AGE
    xgboost-optimized-master-0   0/1     Completed   0          2m21s
    xgboost-optimized-worker-0   0/1     Completed   0          66s
    xgboost-optimized-worker-1   0/1     Completed   0          68s
    
    
    Logs (last 30 lines) - master-0:
    
    starting to train xgboost at node with rank 0
    @tracker All of 3 nodes getting started
    worker(ip_address=10.100.12.83) connected!
    [0] save global checkpoint #1
    [0] save global checkpoint #2
    [0] save global checkpoint #3
    [0] save global checkpoint #4
    [0] save global checkpoint #5
    [0] save global checkpoint #6
    [0] save global checkpoint #7
    [0] save global checkpoint #8
    [0] save global checkpoint #9
    [0] save global checkpoint #10
    [0] save global checkpoint #11
    [0] save global checkpoint #12
    [0] save global checkpoint #13
    [0] save global checkpoint #14
    [0] save global checkpoint #15
    [0] save global checkpoint #16
    [0] save global checkpoint #17
    [0] save global checkpoint #18
    [0] save global checkpoint #19
    [0] save global checkpoint #20
    finish xgboost training at node with rank 0
    xgboost training job finished!
    @tracker All nodes finishes job
    @tracker 5.76357889175415 secs between node start and job finish
    finish the model training, and start to dump model
    Dump model into local place /tmp/xgboost-model
    Finish distributed XGBoost job
    
  2. Cleanup at the end:

    import time
    from kubernetes.client.rest import ApiException
    
    jobs_to_delete = [XGBJOB_NAME]
    
    for job_name in jobs_to_delete:
        try:
            custom_api.delete_namespaced_custom_object(
                group="kubeflow.org",
                version="v1",
                namespace=NAMESPACE,
                plural="xgboostjobs",
                name=job_name
            )
            print(f"Deleted {job_name}")
        except ApiException as e:
            if e.status != 404:
                raise
    
    time.sleep(5)
    print("Cleanup completed")
    

What to do next

After validating these framework-specific scenarios, the next useful topics are:

  • comparing framework-specific job types with TrainJob,

  • testing distributed versus single-replica behavior,

  • adjusting resource requests and limits for each framework,

  • collecting logs and events for failed training pods,

  • building reusable notebook templates for training validation.