此内容没有您所选择的语言版本。

Chapter 9. Caching images for faster workspace start


This section describes installing the Image Puller on a CodeReady Workspaces cluster to cache images on cluster nodes.

9.1. Image Puller overview

Slow starts of Red Hat CodeReady Workspaces workspaces may be caused by waiting for the underlying cluster to pull images used in workspaces from remote registries. As such, pre-pulling images can improve start times significantly. The Image Puller can be used to pre-pull images and shorten workspace start times.

The Image Puller is an additional deployment that runs alongside Red Hat CodeReady Workspaces. Given a list of images to pre-pull, the application runs inside a cluster and creates a DaemonSet that pulls the images on each node.

Note

The minimal requirement for an image to be pre-pulled is the availability of the sleep command, which means that FROM scratch images (for example, 'che-machine-exec') are currently not supported. Also, images that mount volumes in the dockerfile are not supported for pre-pulling on OpenShift.

The application can be deployed:

The image puller loads its configuration from a ConfigMap with the following available parameters:

Expand
Table 9.1. Image Puller default parameters
ParameterUsageDefault

CACHING_INTERVAL_HOURS

Interval, in hours, between checking health of DaemonSets

"1"

CACHING_MEMORY_REQUEST

The memory request for each cached image when the puller is running

10Mi

CACHING_MEMORY_LIMIT

The memory limit for each cached image when the puller is running

20Mi

CACHING_CPU_REQUEST

The CPU request for each cached image when the puller is running

.05

CACHING_CPU_LIMIT

The CPU limit for each cached image when the puller is running

.2

DAEMONSET_NAME

Name of DaemonSet to be created

kubernetes-image-puller

NAMESPACE

Namespace where DaemonSet is to be created

k8s-image-puller

IMAGES

List of images to be cached, in the format <name>=<image>;…​

Contains a default list of images. Before deploying, fill this with the images that fit the current requirements

NODE_SELECTOR

Node selector applied to the Pods created by the DaemonSet

'{}'

The default memory requests and limits ensure that the container has enough memory to start. When changing CACHING_MEMORY_REQUEST or CACHING_MEMORY_LIMIT, you will need to consider the total memory allocated to the DaemonSet Pods in the cluster:

(memory limit) * (number of images) * (number of nodes in the cluster)

For example, running the image puller that caches 5 images on 20 nodes, with a container memory limit of 20Mi requires 2000Mi of memory.

9.2. Deploying Image Puller using the Operator

The recommended way to deploy the Image Puller is through the Operator.

Prerequisites

  • A project in your cluster to host the image puller. This document uses the project image-puller as an example.

Procedure

  1. Navigate to your OpenShift cluster console, navigate to Operators OperatorHub.
  2. Use the Filter by keyword box to search for OpenShift Image Puller Operator. Click the OpenShift Image Puller Operator.
  3. Read the description of the Operator. Click Continue Install.
  4. Select A specific project on the cluster for the Installation Mode. In the drop-down find the project you created to install the image puller. Click Subscribe.
  5. Wait for the Image Puller Operator to install. Click the OpenShiftImagePuller Create instance.
  6. In a redirected window with a YAML editor, make modifications to the OpenShiftImagePuller Custom Resource and click Create.
  7. Navigate to the Workloads and Pods menu in the project and verify that the image puller is installed.

9.3. Deploying Image Puller using OpenShift templates

The Image Puller repository contains OpenShift templates for deploying on OpenShift.

Prerequisites

  • A running OpenShift cluster.
  • The oc tool is available.

The following parameters are available to further configure the OpenShift templates:

Expand
Table 9.2. Parameters for installing with OpenShift templates
ValueUsageDefault

DAEMONSET_NAME

The value of DAEMONSET_NAME to set in the ConfigMap

kubernetes-image-puller

IMAGE

Image used for the kubernetes-image-puller deployment

registry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.3

IMAGE_TAG

The image tag to pull

2.3

SERVICEACCOUNT_NAME

The name of the ServiceAccount used by the deployment (created as part of installation)

k8s-image-puller

CACHING_INTERVAL_HOURS

The value of CACHING_INTERVAL_HOURS to set in the ConfigMap

"1"

CACHING_INTERVAL_REQUEST

The value of CACHING_MEMORY_REQUEST to set in the ConfigMap

"10Mi"

CACHING_INTERVAL_LIMIT

The value of CACHING_MEMORY_LIMIT to set in the ConfigMap

"20Mi"`

NODE_SELECTOR

The value of NODE_SELECTOR to set in the ConfigMap

"{}"

See Table 9.1, “Image Puller default parameters” for more information about configuration values, such as DAEMONSET_NAME, CACHING_INTERVAL_HOURS, and CACHING_MEMORY_REQUEST.

Expand
Table 9.3. List of recommended images to pre-pull
ImageURLTag

theia-rhel8

codeready-workspaces/theia-rhel8

2.3

theia-endpoint-rhel8

theia-endpoint-image

2.3

machineexec-rhel8

registry.redhat.io/codeready-workspaces/machineexec-rhel8:2.3

2.3

pluginbroker-metadata-rhel8

registry.redhat.io/codeready-workspaces/pluginbroker-metadata-rhel8:2.3

2.3

pluginbroker-artifacts-rhel8

registry.redhat.io/codeready-workspaces/pluginbroker-artifacts-rhel8:2.3

2.3

plugin-java8-rhel8

registry.redhat.io/codeready-workspaces/plugin-java8-rhel8:2.3

2.3

plugin-java11-rhel8

registry.redhat.io/codeready-workspaces/plugin-java11-rhel8:2.3

2.3

plugin-kubernetes-rhel8

registry.redhat.io/codeready-workspaces/plugin-kubernetes-rhel8:2.3

2.3

plugin-openshift-rhel8

registry.redhat.io/codeready-workspaces/plugin-openshift-rhel8:2.3

2.3

stacks-cpp-rhel8

registry.redhat.io/codeready-workspaces/stacks-cpp-rhel8:2.3

2.3

stacks-dotnet-rhel8

registry.redhat.io/codeready-workspaces/stacks-dotnet-rhel8:2.3

2.3

stacks-golang-rhel8

registry.redhat.io/codeready-workspaces/stacks-golang-rhel8:2.3

2.3

stacks-php-rhel8

registry.redhat.io/codeready-workspaces/stacks-php-rhel8:2.3

2.3

See Table 9.1, “Image Puller default parameters” for more information about configuration values, such as DAEMONSET_NAME, CACHING_INTERVAL_HOURS, and CACHING_MEMORY_REQUEST.

Procedure

Installing

  1. Clone the kubernetes-image-puller repository:

    $ git clone https://github.com/che-incubator/kubernetes-image-puller
    $ cd kubernetes-image-puller
  2. Create a new OpenShift project to deploy the puller into:

    $ oc new-project k8s-image-puller
  3. Process and apply the templates to deploy the puller:

    In CodeReady Workspaces you must use custom values to deploy the image puller. To set custom values, add to the oc process an option: -p <parameterName>=<value>:

    $ oc process -f deploy/serviceaccount.yaml \
        | oc apply -f -
    $ oc process -f deploy/configmap.yaml \
        -p IMAGES='plugin-java8-rhel8=registry.redhat.io/codeready-workspaces/plugin-java8-rhel8:2.3;\
        theia-rhel8=registry.redhat.io/codeready-workspaces/theia-rhel8:2.3;\
        stacks-golang-rhel8=registry.redhat.io/codeready-workspaces/stacks-golang-rhel8:2.3;\
        plugin-java11-rhel8=registry.redhat.io/codeready-workspaces/plugin-java11-rhel8:2.3;\
        theia-endpoint-rhel8=registry.redhat.io/codeready-workspaces/theia-rhel8:2.3;\
        pluginbroker-metadata-rhel8=registry.redhat.io/codeready-workspaces/pluginbroker-metadata-rhel8:2.3;\
        pluginbroker-artifacts-rhel8=registry.redhat.io/codeready-workspaces/pluginbroker-artifacts-rhel8:2.3;' \
        | oc apply -f -
    $ oc process -f deploy/app.yaml \
        -p IMAGE=registry.redhat.io/codeready-workspaces/imagepuller-rhel8 \
        -p IMAGE_TAG='2.3' \
        | oc apply -f -

Verifying the installation

  1. Confirm that a new deployment, kubernetes-image-puller, and a DaemonSet (named based on the value of the DAEMONSET_NAME parameter) exist. The DaemonSet needs to have a Pod for each node in the cluster:

    $ oc get deployment,daemonset,pod --namespace k8s-image-puller
    deployment.extensions/kubernetes-image-puller   1/1       1            1           2m19s
    
    NAME                                           DESIRED   CURRENT   READY     UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
    daemonset.extensions/kubernetes-image-puller   1         1         1         1            1           <none>          2m10s
    
    NAME                                           READY     STATUS    RESTARTS   AGE
    pod/kubernetes-image-puller-5495f46497-mkd4p   1/1       Running   0          2m18s
    pod/kubernetes-image-puller-n8bmf              3/3       Running   0          2m10s
  2. Check that the ConfigMap named k8s-image-puller has the values you specified in your parameter substitution, or that they contain the default values:

    $ oc get configmap k8s-image-puller --output yaml
    apiVersion: v1
    data:
      CACHING_INTERVAL_HOURS: "1"
      CACHING_MEMORY_LIMIT: 20Mi
      CACHING_MEMORY_REQUEST: 10Mi
      DAEMONSET_NAME: kubernetes-image-puller
      IMAGES: |
        theia-rhel8=registry.redhat.io/codeready-workspaces/theia-rhel8:{prod-ver};
        theia-endpoint-rhel8=registry.redhat.io/codeready-workspaces/theia-rhel8:{prod-ver};
        pluginbroker-metadata-rhel8=registry.redhat.io/codeready-workspaces/pluginbroker-metadata-rhel8:{prod-ver};
        pluginbroker-artifacts-rhel8=registry.redhat.io/codeready-workspaces/pluginbroker-artifacts-rhel8:{prod-ver};
        plugin-java8-rhel8=registry.redhat.io/codeready-workspaces/plugin-java8-rhel8:{prod-ver};
        plugin-java11-rhel8=registry.redhat.io/codeready-workspaces/plugin-java11-rhel8:{prod-ver};
        stacks-golang-rhel8=registry.redhat.io/codeready-workspaces/stacks-golang-rhel8:{prod-ver};
      NAMESPACE: k8s-image-puller
      NODE_SELECTOR: '{}'
    kind: ConfigMap
    metadata:
      annotations:
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"v1","data":{"CACHING_INTERVAL_HOURS":"1","CACHING_MEMORY_LIMIT":"20Mi","CACHING_MEMORY_REQUEST":"10Mi","DAEMONSET_NAME":"kubernetes-image-puller","IMAGES":"theia-rhel8=registry.redhat.io/codeready-workspaces/theia-rhel8:{prod-ver}; theia-endpoint-rhel8=registry.redhat.io/codeready-workspaces/theia-rhel8:{prod-ver}; pluginbroker-metadata-rhel8=registry.redhat.io/codeready-workspaces/pluginbroker-metadata-rhel8:{prod-ver}; pluginbroker-artifacts-rhel8=registry.redhat.io/codeready-workspaces/pluginbroker-artifacts-rhel8:{prod-ver}; plugin-java8-rhel8=registry.redhat.io/codeready-workspaces/plugin-java8-rhel8:{prod-ver}; plugin-java11-rhel8=registry.redhat.io/codeready-workspaces/plugin-java11-rhel8:{prod-ver}; stacks-golang-rhel8=registry.redhat.io/codeready-workspaces/stacks-golang-rhel8:{prod-ver};\n","NAMESPACE":"k8s-image-puller","NODE_SELECTOR":"{}"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"k8s-image-puller","namespace":"k8s-image-puller"},"type":"Opaque"}
      creationTimestamp: 2020-02-17T22:40:13Z
      name: k8s-image-puller
      namespace: k8s-image-puller
      resourceVersion: "72250"
      selfLink: /api/v1/namespaces/k8s-image-puller/configmaps/k8s-image-puller
      uid: 76430ed6-51d6-11ea-9c19-52fdfc072182
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部