A kubernetes operator for creating and managing a cache of container images directly on the cluster worker nodes, so application pods start almost instantly
A kubernetes operator for creating and managing a cache of container images directly on the cluster worker nodes, so application pods start almost instantly
kube-fledged is a kubernetes operator for creating and managing a cache of container images directly on the worker nodes of a kubernetes cluster. It allows a user to define a list of images and onto which worker nodes those images should be cached (i.e. pulled). As a result, application pods start almost instantly, since the images need not be pulled from the registry.
kube-fledged provides CRUD APIs to manage the lifecycle of the image cache, and supports several configurable parameters to customize the functioning as per one's needs.
These instructions install kube-fledged to a separate namespace called "kube-fledged", using YAML manifests and pre-built images in Docker Hub.
Clone the source code repository
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/kube-fledged
$ cd $HOME/kube-fledgedDeploy kube-fledged to the cluster
$ make deploy-using-yamlVerify if kube-fledged deployed successfully
$ kubectl get pods -n kube-fledged -l app=kubefledged
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')Create the namespace where kube-fledged will be installed
$ export KUBEFLEDGED_NAMESPACE=kube-fledged
$ kubectl create namespace ${KUBEFLEDGED_NAMESPACE}Install latest version of kube-fledged helm chart
$ helm repo add kubefledged-charts https://senthilrch.github.io/kubefledged-charts/
$ helm repo update
$ helm install kube-fledged kubefledged-charts/kube-fledged -n ${KUBEFLEDGED_NAMESPACE} --waitThese instructions install kube-fledged to a separate namespace called "kube-fledged", using Helm operator and pre-built images in Docker Hub.
Clone the source code repository
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/kube-fledged
$ cd $HOME/kube-fledgedDeploy the helm operator and kube-fledged to namespace "kube-fledged". If you need to deploy to a different namespace, export the variable KUBEFLEDGED_NAMESPACE
$ make deploy-using-operatorVerify if kube-fledged deployed successfully
$ kubectl get pods -n kube-fledged -l app.kubernetes.io/name=kube-fledged
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')Parameters of the helm chart are documented here
These instructions will help you build kube-fledged from source and deploy it to a separate namespace called "kube-fledged". If you need to deploy it to a different namespace, edit the namespace field of the manifests in "kube-fledged/deploy" accordingly.
Clone the source code repository
$ git clone https://github.com/senthilrch/kube-fledged.git $HOME/kube-fledged
$ cd $HOME/kube-fledgedIf you are behind a proxy, export the following ENV variables (UPPER case)
export HTTP_PROXY=http://proxy_ip_or_hostname:port
export HTTPS_PROXY=https://proxy_ip_or_hostname:portBuild and push the docker images to registry (e.g. Docker hub)
$ export RELEASE_VERSION=<your_tag>
$ export CONTROLLER_IMAGE_REPO=docker.io/<your_dockerhub_username>/kubefledged-controller
$ export WEBHOOK_SERVER_IMAGE_REPO=docker.io/<your_dockerhub_username>/kubefledged-webhook-server
$ export CRI_CLIENT_IMAGE_REPO=docker.io/<your_dockerhub_username>/kubefledged-cri-client
$ export OPERATOR_IMAGE_REPO=docker.io/<your_dockerhub_username>/kubefledged-operator
$ docker login -u <username> -p <password>
$ export DOCKER_CLI_EXPERIMENTAL=enabled
$ make install-buildx && make release-amd64Note:- You need to have 'cluster-admin' privileges to deploy
All manifests required for deploying kube-fledged are present in 'kube-fledged/deploy' directory.
Edit "kubefledged-deployment-controller.yaml".
Set "image" to "<your_docker_hub_username>/kubefledged-controller:<your_tag>"
image: <your_docker_hub_username>/kubefledged-controller:<your_tag>If you pushed the image to a private repository, add 'imagePullSecrets' to the end of "kubefledged-deployment-controller.yaml". Refer to kubernetes documentation on Specifying ImagePullSecrets on a Pod. The secret <your_registry_key> should be created in "kube-fledged" namespace.
serviceAccountName: kubefledged
imagePullSecrets:
- name: <your_registry_key>Edit "kubefledged-deployment-webhook-server.yaml".
Set "image" to "<your_docker_hub_username>/kubefledged-webhook-server:<your_tag>"
image: <your_docker_hub_username>/kubefledged-webhook-server:<your_tag>Deploy kube-fledged to the cluster
$ make deploy-using-yamlVerify if kube-fledged deployed successfully
$ kubectl get pods -n kube-fledged -l app=kubefledged
$ kubectl logs -f <pod_name_obtained_from_above_command> -n kube-fledged
$ kubectl get imagecaches -n kube-fledged (Output should be: 'No resources found')kube-fledged provides APIs to perform CRUD operations on image cache. These APIs can be consumed via kubectl or curl
Refer to sample image cache manifest in "deploy/kubefledged-imagecache.yaml". Edit it as per your needs before creating image cache. If images are in private repositories requiring credentials to pull, add "imagePullSecrets" to the end.
imagePullSecrets:
- name: myregistrykeyCreate the image cache using kubectl. Verify successful creation
$ kubectl create -f deploy/kubefledged-imagecache.yaml
$ kubectl get imagecaches -n kube-fledgedUse following command to view the status of image cache in "json" format.
$ kubectl get imagecaches imagecache1 -n kube-fledged -o jsonUse kubectl edit command to add/remove images in image cache. The edit command opens the manifest in an editor. Edit your changes, save and exit.
$ kubectl edit imagecaches imagecache1 -n kube-fledged
$ kubectl get imagecaches imagecache1 -n kube-fledged -o jsonkube-fledged supports both automatic and on-demand refresh of image cache. Auto refresh is enabled using the flag --image-cache-refresh-frequency:. To request for an on-demand refresh, run the following command:-
$ kubectl annotate imagecaches imagecache1 -n kube-fledged kubefledged.io/refresh-imagecache=Before you could delete the image cache, you need to purge the images in the cache using the following command. This will remove all cached images from the worker nodes.
$ kubectl annotate imagecaches imagecache1 -n kube-fledged kubefledged.io/purge-imagecache=View the status of purging the image cache. If any failures, such images should be removed manually or you could decide to leave the images in the worker nodes.
$ kubectl get imagecaches imagecache1 -n kube-fledged -o jsonFinally delete the image cache using following command.
$ kubectl delete imagecaches imagecache1 -n kube-fledgedRun the following command to remove kube-fledged from the cluster.
$ make remove-kubefledged (if you deployed using YAML manifests)
$ helm delete kube-fledged -n ${KUBEFLEDGED_NAMESPACE} (if you deployed using Helm chart)
$ make remove-kubefledged-and-operator (if you deployed using Helm Operator)Kubernetes allows developers to extend the kubernetes api via Custom Resources. kube-fledged defines a custom resource of kind “ImageCache” and implements a custom controller (named kubefledged-controller). kubefledged-controller does the heavy-lifting for managing image cache. Users can use kubectl commands for creation and deletion of ImageCache resources.
kubefledged-controller has a built-in image manager routine that is responsible for pulling and deleting images. Images are pulled or deleted using kubernetes jobs. If enabled, image cache is refreshed periodically by the refresh worker. kubefledged-controller updates the status of image pulls, refreshes and image deletions in the status field of ImageCache resource.
For more detailed description, go through kube-fledged's design proposal.
--cri-socket-path: path to the cri socket on the node e.g. /run/containerd/containerd.sock (default: /var/run/docker.sock, /run/containerd/containerd.sock, /var/run/crio/crio.sock)
--image-cache-refresh-frequency: The image cache is refreshed periodically to ensure the cache is up to date. Setting this flag to "0s" will disable refresh. default "15m"
--image-delete-job-host-network: Whether the pod for the image delete job should be run with 'HostNetwork: true'. Default value: false.
`--image-pull-deadline
No open issues yet, or sync has not completed.