Image download optimization

After a new image was uploaded to the target registry, it is not automatically downloaded to IBM® Software Hub. You can use the following Job JSON file to prepull the new image to each compute node.

To download the new image to all compute nodes on the cluster, do the following:
  1. Create a Job JSON file based on the following content:
    {
    
        "kind": "Job",
        "apiVersion": "batch/v1",
        "metadata": {
            "name": "REPLACE_WITH_IMAGE_NAME-pull",
            "labels": {
                "app": "imagePrepull",
                "run": "REPLACE_WITH_IMAGE_NAME"
            }
        },
        "spec": {
            "parallelism": 20,
            "completions": 20,
            "template": {
                "metadata": {
                    "labels": {
                        "app": "imagePrepull",
                        "run": "REPLACE_WITH_IMAGE_NAME"
                    }
                },
                "spec": {
                    "containers": [
                        {
                            "name": "jupyter-custom-container",
                            "image": "REPLACE_BY_FULL_NAME_OF_YOUR_IMAGE",
                            "command": [
                                "echo",
                                "Image preloaded"
                            ],
                            "resources": {},
                            "terminationMessagePath": "/get-started/termination-log",
                            "terminationMessagePolicy": "File",
                            "imagePullPolicy": "Always"
                        }
                    ],
                    "restartPolicy": "OnFailure",
                    "affinity": {
                        "nodeAffinity": {
                            "requiredDuringSchedulingIgnoredDuringExecution": {
                                "nodeSelectorTerms": [
                                    {
                                        "matchExpressions": [
                                            {
                                                "key": "kubernetes.io/arch",
                                                "operator": "In",
                                                "values": [
                                                    "REPLACE_WITH_ARCHITECTURE"
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        },
                        "podAntiAffinity": {
                            "requiredDuringSchedulingIgnoredDuringExecution": [
                                {
                                    "labelSelector": {
                                        "matchExpressions": [
                                            {
                                                "key": "run",
                                                "operator": "In",
                                                "values": [
                                                    "REPLACE_WITH_IMAGE_NAME"
                                                ]
                                            }
                                        ]
                                    },
                                    "topologyKey": "kubernetes.io/hostname"
                                }
                            ]
                        }
                    }
                }
            }
        }
    }
    Insert the following values in the sample JSON:
    • REPLACE_WITH_IMAGE_NAME: myimage
    • REPLACE_BY_FULL_NAME_OF_YOUR_IMAGE: registry/myimage:0.1
    • REPLACE_WITH_ARCHITECTURE: amd64 or ppc64le
  2. Execute the job: oc create -f prepull.json
  3. Verify the state of the job pods: oc get pods | grep -i REPLACE_WITH_IMAGE_NAME-pull

    If all the listed pods are in Completed state, the prepull finished successfully.