This section describes installing the Kubernetes Image Puller on a Che cluster to cache images on cluster nodes.
Kubernetes Image Puller overview
Slow starts of Eclipse Che 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 Kubernetes Image Puller can be used to pre-pull images and shorten workspace start times.
The Kubernetes Image Puller is an additional deployment that runs alongside Eclipse Che. 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 application can be deployed via Helm or by processing and applying OpenShift templates.
The Kubernetes 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 |
|
|
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, but should be configured when deploying |
|
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.
Deploying the Kubernetes Image Puller using OpenShift templates
The Kubernetes Image Puller repository contains OpenShift templates for deploying on OpenShift.
Alternatively, you can use Helm for deploying the Kubernetes Image Puller to OpenShift.
-
An OpenShift cluster to install to.
-
The
ocbinary.
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 Kubernetes Image Puller parameters for more information about configuration values, such as DAEMONSET_NAME, CACHING_INTERVAL_HOURS, and CACHING_MEMORY_REQUEST.
Installing
-
Clone the
kubernetes-image-pullerrepository:$ git clone https://github.com/che-incubator/kubernetes-image-puller $ cd kubernetes-image-puller
-
Log into the OpenShift cluster and create a namespace to deploy the puller into:
$ oc login -u username -p password https://openshift-cluster-api:6443 $ oc create namespace k8s-image-puller
-
Process and apply the templates:
$ for template in $(ls deploy/openshift); \ do oc process -f deploy/openshift/$template | oc apply -f -; done deployment.apps/kubernetes-image-puller created configmap/k8s-image-puller created role.rbac.authorization.k8s.io/create-daemonset created rolebinding.rbac.authorization.k8s.io/create-daemonset created serviceaccount/k8s-image-puller created
To set different values than the defaults, use:
$ oc process -p <parameterName>=<value> -f deploy/openshift/<template> | oc apply -f -
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:$ 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 -
Check that the
ConfigMapnamedk8s-image-pullerhas 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: | java11-maven=quay.io/eclipse/che-java11-maven:nightly; che-theia=eclipse/che-theia:next; java-plugin-runner=eclipse/che-remote-plugin-runner-java8:latest; 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":"java11-maven=quay.io/eclipse/che-java11-maven:nightly; che-th eia=eclipse/che-theia:next; java-plugin-runner=eclipse/che-remote-plugin-runner-java8:latest;\n","NAMESPACE":"k8s-image-puller","NODE_SELECTOR":"{}"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"k8s-image-puller","namespace":"k 8s-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
Deploying the Kubernetes Image Puller using Helm
The Kubernetes Image Puller can be installed using Helm.
-
The
helmbinary -
An OpenShift or Kubernetes cluster to install to
-
The
ocor thekubectlbinaryIn the instructions below, use the occommand when installing on OpenShift and thekubectlcommand for installing on Kubernetes.
The following parameters are available for configuring the installation with Helm:
| Value | Usage | Default |
|---|---|---|
|
The value of |
|
|
The repository to pull the image from |
|
|
The image tag to pull |
|
|
The name of the ServiceAccount to create |
|
|
The name of the ConfigMap to create |
|
|
The value of |
|
|
The value of |
|
|
The value of |
|
|
The value of |
|
Installing
-
Clone the
kubernetes-image-pullerrepository:$ git clone https://github.com/che-incubator/kubernetes-image-puller $ cd kubernetes-image-puller
-
Create a namespace to deploy the puller into:
$ oc create namespace k8s-image-puller
-
Run
helm install:$ helm install kubernetes-image-puller --namespace k8s-image-puller deploy/helm
To set values, edit the
deploy/helm/values.yamlfile, or use the--set property.name=<value>parameter.
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:$ oc get deployment,daemonset,pod --namespace k8s-image-puller NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/kubernetes-image-puller 1/1 1 1 4m21s NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE daemonset.apps/kubernetes-image-puller 3 3 3 3 3 <none> 3m40s NAME READY STATUS RESTARTS AGE pod/kubernetes-image-puller-b556c8bd4-qxwwl 1/1 Running 0 4m21s pod/kubernetes-image-puller-glh87 3/3 Running 0 3m40s pod/kubernetes-image-puller-h7lxf 3/3 Running 0 3m40s pod/kubernetes-image-puller-nrt6p 3/3 Running 0 3m40s -
Check that the
ConfigMapnamedk8s-image-pullerhas the values specified in the Helm configuration, 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: java11-maven=quay.io/eclipse/che-java11-maven:nightly; che-theia=eclipse/che-theia:next; java-plugin-runner=eclipse/che-remote-plugin-runner-java8:latest; NAMESPACE: k8s-image-puller NODE_SELECTOR: '{}' kind: ConfigMap metadata: creationTimestamp: "2020-02-17T22:15:22Z" name: k8s-image-puller namespace: k8s-image-puller resourceVersion: "3078" selfLink: /api/v1/namespaces/k8s-image-puller/configmaps/k8s-image-puller uid: 71bc5ce4-d095-468e-ab7b-23c1e0a36638