vmware-archive / kubernetes-image-mapper

[Prototype] Apply relocation mappings on the fly to kubernetes resources
Apache License 2.0
0 stars 2 forks source link
golang image-relocation kubernetes mutating-admission-webhook

Kubernetes Image Mapper Prototype

The goal of this repository is to allow a kubernetes application to be deployed with images which have been moved to a private registry, but without editing the application configuration. A webhook rewrites the image references in the application's pods according to a mapping which is configured using custom resources.

To do:

For more context, please see the image relocation repository's README.

Details

This repository consists of a MutatingAdmissionWebhook which rewrites kubernetes pods to use relocated image references. The mapping from original to relocated image references is built by deploying imagemap custom resources which are processed by a controller also provided by this repository.

Each imagemap is namespaced and applies only to pods in the same namespace.

When an imagemap is deployed, if it is inconsistent with other imagemaps in the namespace, it is rejected and the status of the imagemap details the inconsistency (in a Ready condition with status false). After the inconsistency has been corrected, the rejected imagemap is automatically redeployed after a short delay (currently one minute).

If an imagemap is updated and this results in the imagemap being rejected, the original imagemap is undeployed.

Usage

The following was tested using a GKE cluster.

Note: the image value under containerStatuses may not be the relocated value. This is a known issue when an image has multiple references referring to it.