agentleFS
selamy-labsselamy-labs/agent-skills/skills/colocated-pod-tolerations/SKILL.md

colocated-pod-tolerations

Skill0 starsChanged 6 days agoMITView on GitHub

Use when a Kubernetes Job, CronJob, or Pod is pinned to a specific node (via podAffinity, nodeSelector, or nodeAffinity) to share a node or an RWO volume. It must also carry that node's tolerations or it is permanently unschedulable.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When you pin a Pod to a particular node so it can share something node-local — most often a ReadWriteOnce PersistentVolume already mounted …

    line 8
  2. Very specific:

    If you copy affinity/nodeSelector from another workload to colocate with it, copy that workload's tolerations in the same edit.

    line 34
  3. Distinctive:

    Add a render/template test that fails the build when a manifest declares node-pinning without tolerations:

    line 62

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Colocated Pod Tolerations

When you pin a Pod to a particular node so it can share something node-local — most often a ReadWriteOnce PersistentVolume already mounted by a StatefulSet pod, or a GPU/local disk on a tainted node — you express the pinning with podAffinity + topologyKey: kubernetes.io/hostname, nodeSelector, or nodeAffinity. That makes the scheduler want a specific node.

But the target node is frequently tainted (dedicated node pools, GPU pools, spot pools, and StatefulSet-owned nodes commonly are). Affinity does not grant the right to land on a tainted node — only a matching toleration does. A pod with the affinity but no toleration is steered toward a node it is then forbidden to run on, so it sits Pending/Unschedulable forever.

Why this is so easy to miss

  • It is silent. A CronJob just produces Failed/never-started runs; nothing crashes loudly. The pod template looks correct in review.
  • It can lie dormant. It works while the node is untainted, then breaks the day a taint is added (node pool migration, dedicating a node to a StatefulSet) — long after the manifest was written.
  • Real incident: halt-recovery CronJobs were dead for ~46 hours because they co-located onto a tainted node without inheriting its tolerations. Every scheduled run silently failed; nobody was being recovered.

The rule

Any pod you pin to a node must carry the full toleration set of that node. If you copy affinity/nodeSelector from another workload to colocate with it, copy that workload's tolerations in the same edit. Affinity and tolerations are a pair when targeting tainted nodes — never one without the other.

spec:
  affinity:
    podAffinity:                       # land on the same node as the owner pod
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchLabels: { app: stateful-owner }
          topologyKey: kubernetes.io/hostname
  tolerations:                         # REQUIRED — the owner's node is tainted
    - key: dedicated
      operator: Equal
      value: stateful-owner
      effect: NoSchedule

Prefer not to contend at all

Sharing one node to reach an RWO volume is a smell. Before colocating, ask whether the job can read a snapshot/clone of the volume, or whether the volume should be ReadWriteMany, so the job needs no node pinning and no tolerations. Colocation is the fallback, not the default.

Make it a regression you cannot reship

Add a render/template test that fails the build when a manifest declares node-pinning without tolerations:

  1. Render the chart/manifests (helm template, kustomize build, or your generator).
  2. For every Pod-spec-bearing object, assert: if it has podAffinity/nodeSelector/nodeAffinity targeting a known tainted pool, it also has a toleration matching that pool's taint.
  3. Fail the test otherwise.

A unit test on the rendered YAML catches the silent class before it ships; a cluster smoke check (kubectl get pods --field-selector status.phase=Pending after deploy, alert on age) catches the dormant case after a taint appears.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.