Skip to content

Disable client caching for Pods - #5082

Merged
caseydavenport merged 1 commit into
tigera:masterfrom
caseydavenport:casey-disable-pod-cache
Jul 21, 2026
Merged

Disable client caching for Pods#5082
caseydavenport merged 1 commit into
tigera:masterfrom
caseydavenport:casey-disable-pod-cache

Conversation

@caseydavenport

@caseydavenport caseydavenport commented Jul 21, 2026

Copy link
Copy Markdown
Member

The operator's controller-runtime client caches every object type it reads, so the first cached pod read starts a shared informer that lists and watches every pod in the cluster and holds them all in memory. Nothing needs a full in-memory pod cache - the handful of controllers that read pods (status diagnosis, dex/guardian proxy resolution, finalizer cleanup, CSR validation) all query by label and namespace, and a couple do single Gets by name, and all run conditionally in specific situations and aren't part of steady-state.

This adds Pod to the client's DisableFor list so those reads go straight to the apiserver. The label/namespace selectors that were previously applied client-side over the cached store now become server-side filters, so responses are smaller too.

Measured with a throwaway envtest harness (synthetic pods, heap after 2x GC):

pods cached uncached saved
1,000 39.9 MiB 3.7 MiB 36.2 MiB
5,000 184.2 MiB 3.8 MiB 180.4 MiB
10,000 364.0 MiB 3.7 MiB 360.2 MiB

The uncached footprint stays flat regardless of cluster size.

Depends on #4987, which removes the pod spec.nodeName field index. That index starts the shared pod informer on its own, so this change only fully takes effect once #4987 lands - merge this after #4987. This PR doesn't include #4987's commits; I'll rebase once it merges.

Reduces Tigera operator memory usage in large clusters by no longer caching all Pods in memory.

Pods are read only by label/namespace selector from a few controllers,
so route those reads to the apiserver instead of holding every pod in a
shared informer.
@caseydavenport
caseydavenport marked this pull request as ready for review July 21, 2026 23:31
@caseydavenport
caseydavenport requested a review from a team as a code owner July 21, 2026 23:31
@caseydavenport
caseydavenport merged commit 48a6d43 into tigera:master Jul 21, 2026
11 checks passed
@caseydavenport
caseydavenport deleted the casey-disable-pod-cache branch July 21, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants