Katib UI and namespace isolation validation

Scenario 6. Launching Katib via the UI

Goal

Verify that as a user, you can from the MLOps Studio UI:

  • create a Katib experiment,

  • view its status,

  • view trials that finish successfully.

Prerequisites

Let us assume the experiment name is mnist-katib-ui-quick. If it already exists in this namespace, change it, for example to mnist-katib-ui-quick-2.

Steps

  1. Set your namespace.

    • Log in to the MLOps Studio Central Dashboard.

    • In the upper right corner, or wherever you have the namespace selection, set your namespace.

  2. Go to Katib.

    • In the left menu, find an item like Katib / Experiments / HP Tuning, depending on the version.

    • Click it. A list of Katib experiments for your namespace should appear. It may be empty or already have something.

  3. Create a new experiment from YAML.

  4. Click + New Experiment / Create Experiment.

  5. If a form opens, switch to the YAML tab, for example YAML, Advanced, or Manual.

  6. Paste the YAML of your working experiment and pay attention to the namespace.

    apiVersion: kubeflow.org/v1beta1
    kind: Experiment
    metadata:
      name: mnist-katib-ui-quick
      namespace: <namespace_name>
    spec:
      maxTrialCount: 2
      maxFailedTrialCount: 1
      parallelTrialCount: 2
    
      objective:
        type: minimize
        goal: 0.01
        objectiveMetricName: loss
    
      algorithm:
        algorithmName: random
    
      parameters:
        - name: learning_rate
          parameterType: double
          feasibleSpace:
            min: "0.01"
            max: "0.05"
        - name: batch_size
          parameterType: int
          feasibleSpace:
            min: "80"
            max: "100"
    
      trialTemplate:
        primaryContainerName: tensorflow
        trialParameters:
          - name: learningRate
            description: Learning rate for the training model
            reference: learning_rate
          - name: batchSize
            description: Batch size for the model
            reference: batch_size
        trialSpec:
          apiVersion: kubeflow.org/v1
          kind: TFJob
          spec:
            tfReplicaSpecs:
              Chief:
                replicas: 1
                restartPolicy: OnFailure
                template:
                  metadata:
                    annotations:
                      sidecar.istio.io/inject: "false"
                  spec:
                    containers:
                      - name: tensorflow
                        image: docker.io/liuhougangxa/tf-estimator-mnist
                        command:
                          - python
                          - /opt/model.py
                          - --tf-train-steps=50
                          - --tf-learning-rate=${trialParameters.learningRate}
                          - --tf-batch-size=${trialParameters.batchSize}
              Worker:
                replicas: 1
                restartPolicy: OnFailure
                template:
                  metadata:
                    annotations:
                      sidecar.istio.io/inject: "false"
                  spec:
                    containers:
                      - name: tensorflow
                        image: docker.io/liuhougangxa/tf-estimator-mnist
                        command:
                          - python
                          - /opt/model.py
                          - --tf-train-steps=50
                          - --tf-learning-rate=${trialParameters.learningRate}
                          - --tf-batch-size=${trialParameters.batchSize}
    
  7. Click Create / Submit.

Result

The experiment passes and has a Succeeded status.

Scenario 7. Attempt to create a Katib experiment in a foreign namespace via the UI

Goal

Verify that a user working in their namespace is not able to create a Katib experiment in another namespace, in this case qa, even if they manually set metadata.namespace: qa in the YAML section in the UI. The system should ignore the attempt to change the namespace and still create the experiment only in their namespace.

Steps

  1. Set your namespace.

    • Log in to the MLOps Studio Central Dashboard.

    • In the upper right corner, or wherever you have the namespace selection, set your namespace.

    • Check that you do not have access to the qa namespace.

  2. In the left menu, go to Katib / Experiments / HP Tuning, as in the happy path.

  3. Create a new experiment, but with the qa namespace in YAML.

    • Click + New Experiment / Create Experiment.

    • Switch to the YAML tab.

    • Paste the following manifest and pay attention to the namespace qa:

    apiVersion: kubeflow.org/v1beta1
    kind: Experiment
    metadata:
      name: mnist-katib-ui-quick-forbidden
      namespace: qa
    spec:
      maxTrialCount: 2
      maxFailedTrialCount: 1
      parallelTrialCount: 2
    
      objective:
        type: minimize
        goal: 0.01
        objectiveMetricName: loss
    
      algorithm:
        algorithmName: random
    
      parameters:
        - name: learning_rate
          parameterType: double
          feasibleSpace:
            min: "0.01"
            max: "0.05"
        - name: batch_size
          parameterType: int
          feasibleSpace:
            min: "80"
            max: "100"
    
      trialTemplate:
        primaryContainerName: tensorflow
        trialParameters:
          - name: learningRate
            description: Learning rate for the training model
            reference: learning_rate
          - name: batchSize
            description: Batch size for the model
            reference: batch_size
        trialSpec:
          apiVersion: kubeflow.org/v1
          kind: TFJob
          spec:
            tfReplicaSpecs:
              Chief:
                replicas: 1
                restartPolicy: OnFailure
                template:
                  metadata:
                    annotations:
                      sidecar.istio.io/inject: "false"
                  spec:
                    containers:
                      - name: tensorflow
                        image: docker.io/liuhougangxa/tf-estimator-mnist
                        command:
                          - python
                          - /opt/model.py
                          - --tf-train-steps=50
                          - --tf-learning-rate=${trialParameters.learningRate}
                          - --tf-batch-size=${trialParameters.batchSize}
              Worker:
                replicas: 1
                restartPolicy: OnFailure
                template:
                  metadata:
                    annotations:
                      sidecar.istio.io/inject: "false"
                  spec:
                    containers:
                      - name: tensorflow
                        image: docker.io/liuhougangxa/tf-estimator-mnist
                        command:
                          - python
                          - /opt/model.py
                          - --tf-train-steps=50
                          - --tf-learning-rate=${trialParameters.learningRate}
                          - --tf-batch-size=${trialParameters.batchSize}
    
  4. Click Create / Submit.

  5. After creation:

    • go to the details of the mnist-katib-ui-quick-forbidden experiment,

    • open the YAML tab and check the field:

    metadata:
      namespace: <namespace_name>
    
  6. From the console, check:

    kubectl -n qa get experiments
    kubectl -n <namespace_name> get experiments
    

Results

  1. In the experiment’s YAML tab you see:

    metadata:
      namespace: <namespace_name>
    

    This means the UI or API ignored the namespace: qa entered in the form and enforced the namespace consistent with the context.

  2. In the qa namespace:

    kubectl -n qa get experiments
    

    as a result, there is no mnist-katib-ui-quick-forbidden experiment.

  3. In your namespace:

    kubectl -n <namespace_name> get experiments
    
  4. The experiment runs and finishes successfully.