Este conteúdo não está disponível no idioma selecionado.
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 Copiar o linkLink copiado para a área de transferência!
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.
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:
- using OperatorHub or installing the kubernetes image puller operator
- by processing and applying OpenShift templates.
The Image Puller pulls its configuration from a ConfigMap with the following available parameters:
| Parameter | Usage | Default |
|---|---|---|
|
| Interval, in hours, between checking health of DaemonSets |
|
|
| The memory request for each cached image when the puller is running |
|
|
| The memory limit for each cached image when the puller is running |
|
|
| The CPU request for each cached image when the puller is running |
|
|
| The CPU limit for each cached image when the puller is running |
|
|
| Name of DaemonSet to be created |
|
|
| Namespace where DaemonSet is to be created |
|
|
|
List of images to be cached, in the format | Contains a default list of images. Before deploying, fill this with the images that fit the current requirements |
|
| 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 Copiar o linkLink copiado para a área de transferência!
The recommended way to deploy the Image Puller is through the Operator.
9.2.1. Installing the Image Puller on OpenShift using OperatorHub Copiar o linkLink copiado para a área de transferência!
First, create a project in your cluster to host the image puller. Our example will use the project "image-puller".
Navigate to your OpenShift cluster’s console, and select Operators. Select OperatorHub and type "image puller" into the "Filter by keyword.." search bar. Click the OpenShift Image Puller Operator, click Continue and click Install. At the Installation Mode selection, choose A specific project on the cluster, and use the drop-down to find the project you created to install the image puller. Click Subscribe.
Wait for the OpenShift Image Puller Operator to install, and click the installation. Click the OpenShiftImagePuller tab, and then click Create instance. You will be taken to a screen with a YAML editor with a OpenShiftImagePuller Custom Resource. Make any modifications to the Custom resource and click Create.
Navigate to the Workloads and Pods menu in the project that the image puller was installed, and you should see pods being created.
9.2.2. Installing the Image Puller on OpenShift using the Operator Copiar o linkLink copiado para a área de transferência!
Create a project to host the kubernetes image puller, and apply the following manifests from the GitHub repository:
Then create a OpenShiftImagePuller Custom Resource:
9.3. Deploying Image Puller using OpenShift templates Copiar o linkLink copiado para a área de transferência!
The Image Puller repository contains OpenShift templates for deploying on OpenShift.
Prerequisites
- A running OpenShift cluster.
-
The
ocbinary file.
The following parameters are available to further configure the OpenShift templates:
| Value | Usage | Default |
|---|---|---|
|
|
The value of |
|
|
|
Image used for the |
|
|
| The image tag to pull |
|
|
| The name of the ServiceAccount used by the deployment (created as part of installation) |
|
|
|
The value of |
|
|
|
The value of |
|
|
|
The value of |
|
|
|
The value of |
|
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.
| Image | URL | Tag |
|---|---|---|
| stacks-java-rhel8 | registry.access.redhat.com/codeready-workspaces/stacks-java-rhel8 | 2.2 |
| theia-rhel8 | registry.access.redhat.com/codeready-workspaces/theia-rhel8 | 2.2 |
| stacks-golang-rhel8 | registry.access.redhat.com/codeready-workspaces/stacks-golang-rhel8 | 2.2 |
| stacks-node-rhel8 | registry.access.redhat.com/codeready-workspaces/stacks-node-rhel8 | 2.2 |
| theia-endpoint-rhel8 | registry.access.redhat.com/codeready-workspaces/theia-rhel8 | 2.2 |
| pluginbroker-metadata-rhel8 | registry.access.redhat.com/codeready-workspaces/pluginbroker-metadata-rhel8 | 2.2 |
| pluginbroker-artifacts-rhel8 | registry.access.redhat.com/codeready-workspaces/pluginbroker-artifacts-rhel8 | 2.2 |
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
Clone the
kubernetes-image-pullerrepository:git clone https://github.com/che-incubator/kubernetes-image-puller cd kubernetes-image-puller
$ git clone https://github.com/che-incubator/kubernetes-image-puller $ cd kubernetes-image-pullerCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a new OpenShift project to deploy the puller into:
oc new-project k8s-image-puller
$ oc new-project k8s-image-pullerCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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 processan option:-p <parameterName>=<value>:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verifying the installation
Confirm that a new deployment,
kubernetes-image-puller, and a DaemonSet (named based on the value of theDAEMONSET_NAMEparameter) exist. The DaemonSet needs to have a Pod for each node in the cluster:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check that the
ConfigMapnamedk8s-image-pullerhas the values you specified in your parameter substitution, or that they contain the default values:Copy to Clipboard Copied! Toggle word wrap Toggle overflow