ImagePullJob
Kruise will create a NodeImage for each Node, and it contains images that should be downloaded on this Node.
Users can create an ImagePullJob to declare an image should be downloaded on which nodes.
Note that the NodeImage is quite a low-level API. You should only use it when you prepare to pull an image on a definite Node. Otherwise, you should use the ImagePullJob to pull an image on a batch of Nodes.
ImagePullJob is a namespaced-scope resource.
API definition:
Or you can write the podSelector to pull image on nodes of these pods. podSelector
is mutually exclusive with selector
.
Also, ImagePullJob has two completionPolicy types:
- means this job will eventually complete with either failed or succeeded.
ttlSecondsAfterFinished
: after this job finished (including success or failure) over this time, this job will be removed
Never
means this job will never complete, it will continuously pull image on the desired Nodes every day.
If the image is in a private registry, you may want to configure the pull secrets for the image:
Because of ImagePullJob is a namespaced-scope resource, the secrets should be in the same namespace of this ImagePullJob, and you should only put the secret names into field.
Attach metadata into cri interface
FEATURE STATE: Kruise v1.4.0
When kubelet creates pods, kubelet will attach pod metadata as podSandboxConfig params in the PullImage CRI interface. The OpenKruise ImagePullJob also supports the similar capability, as follows:
NodeImage (low-level)
API definition:
When Kruise has been installed, nodeimage-controller will create NodeImages for Nodes with the same names immediately. And when a Node has been added or removed, nodeimage-controller will also create or delete NodeImage for this Node.
What’s more, nodeimage-controller will also synchronize labels from Node to NodeImage. So the NodeImage and Node always have the same name and labels. You can get NodeImage with the Node name, or list NodeImage with the Node labels as selector.
Typically, an empty NodeImage looks like this:
If you want to pull an image such as ubuntu:latest
on this Node, you can:
kubectl patch nodeimage node-xxx --type=merge -p '{"spec":{"images":{"ubuntu":{"tags":[{"tag":"latest","pullPolicy":{"ttlSecondsAfterFinished":300}}]}}}}'
You can read the NodeImage status using , and you will find the task removed from spec and status after it has finished over 300s.