Give pods a per-node cache
A named cache is a directory that one or more pods fill with items they can make again, such as decoded art or fetched files. When a copy lacks an item, the pod makes it again. A pod that moves to a new node starts with an empty cache and warms it. A pod that comes back to a node it ran on before has the items it made there.
The objects are the same two as a
replicated store
: a PersistentVolume that
names the driver and the handle, and a PersistentVolumeClaim that
binds to it. Take the manifests from that guide and give the volume a
name of its own. The access mode is ReadWriteMany, because many nodes
mount the one volume read-write, and each node holds its own copy.
No process keeps cache copies in agreement, and a cache does not need agreement. An item made on one node is not on the next, and a pod on the next node makes it again. A single-pod cache therefore needs no anti-affinity. With several pods, each pod warms the copy on its own node.
The driver keeps no size budget. A cache grows until the workload trims it or the filesystem that holds the store fills. Every copy shares that filesystem with every other volume on the node, so a cache that grows without a trim takes space from them. The gauge reports each copy’s bytes, so a person can watch a cache grow.