Chapter 9. Caching images for faster workspace start
To improve the start time performance of CodeReady Workspaces workspaces, use the Image Puller. The Image Puller is an additional OpenShift deployment. It creates a DaemonSet downloading and running the relevant container images on each node. These images are already available when a CodeReady Workspaces workspace starts.
The Image Puller loads its configuration from a ConfigMap
accepting following parameters. The installation method determines the procedure to configure the ConfigMap.
Table 9.1. Image Puller ConfigMap
parameters
Parameter | Usage | Default |
---|---|---|
| DaemonSets health checks interval in hours |
|
| The memory request for each cached image when the puller is running. See Section 9.2, “Defining the memory parameters for the Image Puller”. |
|
| The memory limit for each cached image when the puller is running. See Section 9.2, “Defining the memory parameters for the Image Puller”. |
|
| The processor request for each cached image when the puller is running |
|
| The processor limit for each cached image when the puller is running |
|
| Name of DaemonSet to create |
|
| Name of the Deployment to create |
|
| OpenShift project containing DaemonSet to create |
|
|
Semicolon separated list of images to pull, in the format |
|
| Node selector to apply to the Pods created by the DaemonSet |
|
Additional resources
- Section 9.1, “Defining the list of images to pull”
- Section 9.2, “Defining the memory parameters for the Image Puller”.
- Section 9.3, “Installing Image Puller using the CodeReady Workspaces Operator”
- Section 9.4, “Installing Image Puller on OpenShift 4 using OperatorHub”
- Section 9.5, “Installing Image Puller on OpenShift using OpenShift templates”
- Kubernetes Image Puller source code repository
9.1. Defining the list of images to pull
Prerequisites
-
The
curl
tool is available. See curl homepage. -
The
jq
tool is available. See jq homepage. -
The
yq
tool is available. See yq homepage.
Procedure
Get the list of relevant container images.
Example 9.1. Getting the list of all relevant images for CodeReady Workspaces
$ curl -sSLo- https://raw.githubusercontent.com/redhat-developer/codeready-workspaces-operator/crw-2.6-rhel-8/manifests/codeready-workspaces.csv.yaml | \ yq -r '.spec.relatedImages[]'
Exclude from the list the container images not containing the
sleep
command.Example 9.2. Images incompatibles with {image-puller-short}, missing the
sleep
command-
FROM scratch
images. -
che-machine-exec
-
- Exclude from the list the container images mounting volumes in Dockerfile.
Additional resources
9.2. Defining the memory parameters for the Image Puller
Define the memory requests and limits parameters to ensure pulled containers and the platform have enough memory to run.
Prerequisites
Procedure
-
To define the minimal value for
CACHING_MEMORY_REQUEST
orCACHING_MEMORY_LIMIT
, consider the necessary amount of memory required to run each of the container images to pull. To define the maximal value for
CACHING_MEMORY_REQUEST
orCACHING_MEMORY_LIMIT
, consider the total memory allocated to the DaemonSet Pods in the cluster:(memory limit) * (number of images) * (number of nodes in the cluster)
Pulling 5 images on 20 nodes, with a container memory limit of
20Mi
requires2000Mi
of memory.
9.3. Installing Image Puller using the CodeReady Workspaces Operator
This section describes how to use the CodeReady Workspaces Operator to install the Image Puller. This is a Community-supported technology preview feature.
Prerequisites
- Section 9.1, “Defining the list of images to pull”
- Section 9.2, “Defining the memory parameters for the Image Puller”
- Operator Lifecycle Manager and OperatorHub are available on the OpenShift instance. OpenShift provides them starting with version 4.2.
- The CodeReady Workspaces Operator is available. See https://access.redhat.com/documentation/en-us/red_hat_codeready_workspaces/2.6/html-single/installation_guide/index#installing-codeready-workspaces-on-openshiftt-4-using-operatorhub_crw
Procedure
Edit the
CheCluster
Custom Resource and set.spec.imagePuller.enable
totrue
Example 9.3. Enabling Image Puller in the
CheCluster
Custom ResourceapiVersion: org.eclipse.che/v1 kind: CheCluster metadata: name: codeready-workspaces spec: # ... imagePuller: enable: true
Uninstalling Image Puller using CodeReady Workspaces Operator-
Edit the
CheCluster
Custom Resource and set.spec.imagePuller.enable
tofalse
.
-
Edit the
Edit the
CheCluster
Custom Resource and set the.spec.imagePuller.spec
to configure the optional Image Puller parameters for the CodeReady Workspaces Operator.Example 9.4. Configuring Image Puller in the
CheCluster
Custom ResourceapiVersion: org.eclipse.che/v1 kind: CheCluster metadata: name: codeready-workspaces spec: ... imagePuller: enable: true spec: configMapName: <kubernetes-image-puller> daemonsetName: <kubernetes-image-puller> deploymentName: <kubernetes-image-puller> images: <{image-puller-images}>
Verification steps
-
OpenShift creates a
{image-puller-operator-id}
Subscription. The
eclipse-che namespace
contains acommunity supported Kubernetes Image Puller Operator
ClusterServiceVersion
:$ oc get clusterserviceversions
The
eclipse-che namespace
contains these deployments:kubernetes-image-puller
and{image-puller-deployment-id}
.$ oc get deployments
The community supported Kubernetes Image Puller Operator creates a
KubernetesImagePuller
Custom Resource:$ oc get kubernetesimagepullers
9.4. Installing Image Puller on OpenShift 4 using OperatorHub
This procedure describes how to install the community supported Kubernetes Image Puller Operator on OpenShift 4 using the Operator.
Prerequisites
- An administrator account on a running instance of OpenShift 4.
- Section 9.1, “Defining the list of images to pull”
- Section 9.2, “Defining the memory parameters for the Image Puller”.
Procedure
- To create an OpenShift project <kubernetes-image-puller> to host the Image Puller, open the OpenShift web console, navigate to the Home → Projects section and click Create Project.
Specify the project details:
- Name: <kubernetes-image-puller>
- Display Name: <Image Puller>
- Description: <Kubernetes Image Puller>
- Navigate to Operators → OperatorHub.
-
Use the Filter by keyword box to search for
community supported Kubernetes Image Puller Operator
. Click the community supported Kubernetes Image Puller Operator. - Read the description of the Operator. Click Continue → Install.
- Select A specific project on the cluster for the Installation Mode. In the drop-down find the OpenShift project <kubernetes-image-puller>. Click Subscribe.
- Wait for the community supported Kubernetes Image Puller Operator to install. Click the KubernetesImagePuller → Create instance.
-
In a redirected window with a YAML editor, make modifications to the
KubernetesImagePuller
Custom Resource and click Create. - Navigate to the Workloads and Pods menu in the <kubernetes-image-puller> OpenShift project. Verify that the Image Puller is available.
9.5. Installing Image Puller on OpenShift using OpenShift templates
This procedure describes how to install the Kubernetes Image Puller on OpenShift using OpenShift templates.
Prerequisites
- A running OpenShift cluster.
-
The
oc
tool is available. - Section 9.1, “Defining the list of images to pull”.
- Section 9.2, “Defining the memory parameters for the Image Puller”.
Procedure
Clone the Image Puller repository and get in the directory containing the OpenShift templates:
$ git clone https://github.com/che-incubator/kubernetes-image-puller $ cd kubernetes-image-puller/deploy/openshift
Configure the
app.yaml
,configmap.yaml
andserviceaccount.yaml
OpenShift templates using following parameters:Table 9.2. Image Puller OpenShift templates parameters in
app.yaml
Value Usage Default DEPLOYMENT_NAME
The value of
DEPLOYMENT_NAME
in the ConfigMapkubernetes-image-puller
IMAGE
Image used for the
kubernetes-image-puller
deploymentregistry.redhat.io/codeready-workspaces/imagepuller-rhel8:2.6
IMAGE_TAG
The image tag to pull
latest
SERVICEACCOUNT_NAME
The name of the ServiceAccount created and used by the deployment
{image-puller-serviceaccount-name}
Table 9.3. Image Puller OpenShift templates parameters in
configmap.yaml
Value Usage Default CACHING_CPU_LIMIT
The value of
CACHING_CPU_LIMIT
in the ConfigMap.2
CACHING_CPU_REQUEST
The value of
CACHING_CPU_REQUEST
in the ConfigMap.05
CACHING_INTERVAL_HOURS
The value of
CACHING_INTERVAL_HOURS
in the ConfigMap"1"
CACHING_MEMORY_LIMIT
The value of
CACHING_MEMORY_LIMIT
in the ConfigMap"20Mi"`
CACHING_MEMORY_REQUEST
The value of
CACHING_MEMORY_REQUEST
in the ConfigMap"10Mi"
DAEMONSET_NAME
The value of
DAEMONSET_NAME
in the ConfigMapkubernetes-image-puller
DEPLOYMENT_NAME
The value of
DEPLOYMENT_NAME
in the ConfigMapkubernetes-image-puller
IMAGES
The value of
IMAGES
in the ConfigMap{image-puller-images}
NODE_SELECTOR
The value of
NODE_SELECTOR
in the ConfigMap"{}"
Table 9.4. Image Puller OpenShift templates parameters in
serviceaccount.yaml
Value Usage Default SERVICEACCOUNT_NAME
The name of the ServiceAccount created and used by the deployment
{image-puller-serviceaccount-name}
Create an OpenShift project to host the Image Puller:
$ oc new-project <kubernetes-image-puller>
Process and apply the templates to install the puller:
$ oc process -f serviceaccount.yaml | oc apply -f - $ oc process -f configmap.yaml | oc apply -f - $ oc process -f app.yaml | oc apply -f -
Verification steps
Verify the existence of a <kubernetes-image-puller> deployment and a <kubernetes-image-puller> DaemonSet. The DaemonSet needs to have a Pod for each node in the cluster:
$ oc get deployment,daemonset,pod --namespace <kubernetes-image-puller>
Verify the values of the <kubernetes-image-puller>
ConfigMap
.$ oc get configmap <kubernetes-image-puller> --output yaml