agentleFS
AWSKnown publisherawslabs/do-agent-aws/Container-Root/agent/skills/k8s-configmap-runtime-patch/SKILL.md

k8s-configmap-runtime-patch

Skill3 starsChanged 2 days agoApache-2.0View on GitHub

Use when injecting Python patches or config files into containers at runtime without rebuilding images, when base64 encoding makes YAMLs unreadable, or when private repos block curl-based downloads

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 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.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Idempotent: Check for marker before patching

    line 80

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

K8s ConfigMap Runtime Patching

Overview

Mount Python patch scripts as ConfigMaps into containers at runtime. Avoids base64-encoded blobs in YAMLs, doesn't depend on GitHub access (works with private repos), and patches are version-controlled separately.

When to Use

  • Container image has a bug you can't rebuild for
  • YAML has unreadable base64-encoded patches
  • Private repo blocks curl from downloading patches
  • Need to iterate patches without rebuilding images
  • Multiple manifests need the same patches

Pattern

1. Create patch files in repo

patches/
  patch_worker_v5.py    # Standalone Python scripts
  patch_grpo_v9.py      # Each is self-contained, idempotent

2. Create ConfigMap from files

kubectl create configmap nemo-rl-patches \
  --from-file=patch_worker_v5.py=patches/patch_worker_v5.py \
  --from-file=patch_grpo_v9.py=patches/patch_grpo_v9.py \
  --dry-run=client -o yaml > deploy/kubernetes/patches-configmap.yaml

kubectl apply -f deploy/kubernetes/patches-configmap.yaml

3. Mount in pod spec

volumes:
  - name: patches
    configMap:
      name: nemo-rl-patches
# ...
containers:
  - volumeMounts:
      - name: patches
        mountPath: /opt/patches
        readOnly: true

4. Run patches at startup

command: ["/bin/bash", "-c"]
args:
  - |
    python3 /opt/patches/patch_worker_v5.py
    python3 /opt/patches/patch_grpo_v9.py
    # ... rest of startup

Patch Script Best Practices

#!/usr/bin/env python3
"""Each patch must be idempotent."""

f = '/path/to/target.py'
c = open(f).read()

if 'PATCH_MARKER_V1' in c:
    print('Already patched')
    exit(0)

# Apply patch...
open(f, 'w').write(modified)
print('PATCH_MARKER_V1: Applied')

Key rules:

  • Idempotent: Check for marker before patching
  • Versioned markers: PATCH_V1, PATCH_V2 etc.
  • Print confirmation: Log what was patched
  • Clean .pyc after: find /path -name '*.pyc' -delete

Comparison of Approaches

ApproachReadabilityPrivate RepoIteration Speed
Base64 in YAMLPoorWorksMust re-encode
curl from GitHubGoodFailsPush + redeploy
ConfigMap mountGoodWorkskubectl apply
Rebuild imageN/AWorksSlow (minutes)
<!-- imported on 2026-10-31 by tools/import-skills.py from a native Claude Code instance's skill library; the source site's names, ids, hosts and paths are scrubbed to <placeholders>; its other files were not copied -->

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.