k8s-modification
Safely modify a live Kubernetes resource — detect whether it is Helm-, GitOps- (Flux/Argo), or kubectl-managed; preview every change with kubectl/helm diff and dry-run; prefer Helm-native changes for Helm releases; and fall back to server-side apply / strategic-merge patch with care so future helm upgrades are not broken. Use whenever a change to a live cluster is required (apply, patch, scale, set image, edit values, helm upgrade).
- License 许可
- MIT
- 所属仓库
- blouargant/omnis
- 最近更新
- 2026-11-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- k8s-modification
- metadata
- { "tags": "kubernetes, helm, modification, apply, server-side-apply, gitops, playbook", "author": "blouargant@chapsvision.com" }
- description
- Safely modify a live Kubernetes resource — detect whether it is Helm-, GitOps- (Flux/Argo), or kubectl-managed; preview every change with kubectl/helm diff and dry-run; prefer Helm-native changes for Helm releases; and fall back to server-side apply / strategic-merge patch with care so future helm upgrades are not broken. Use whenever a change to a live cluster is required (apply, patch, scale, set image, edit values, helm upgrade).
02 资源文件 1
- 参考文档permissions.json1.5 KB
03 SKILL.md 正文
Kubernetes Safe Modification
The playbook for CHANGING a live Kubernetes resource with the smallest blast
radius and without breaking the tool that owns it (especially Helm). Read this
before any apply, patch, scale, set, edit, or helm upgrade.
Every mutating command is permission-gated — it prompts the user for confirmation before it runs. Do not try to work around the prompt. If a call is denied, report it and stop; never retry with a different flag or identity.
Phase 1 — Establish the target and guardrails
- Confirm the cluster context.
kubectl config current-contextand quote it back before doing anything else. If the leader/user named a target context, thread it as--context=<ctx>on every command instead — neverkubectl config use-context(it rewrites the shared kubeconfig). - Pin the target: namespace + kind/name + the exact intended change.
- Production guardrail. Never modify production namespaces or contexts
(name contains
prod,prd,production) without an explicit user override.
Phase 2 — Determine who OWNS the resource
Read the resource's labels/annotations before choosing a method:
kubectl get <kind> <name> -n <ns> \
-o jsonpath='labels={.metadata.labels}{"\n"}annotations={.metadata.annotations}{"\n"}'
- Helm-managed — label
app.kubernetes.io/managed-by=Helmand annotationsmeta.helm.sh/release-name,meta.helm.sh/release-namespace. Confirm withhelm status <release> -n <rel-ns>andhelm get values <release> -n <rel-ns>. - GitOps-managed (Flux/Argo) — labels like
kustomize.toolkit.fluxcd.io/name,helm.toolkit.fluxcd.io/name(Flux) orargocd.argoproj.io/instance/ annotationargocd.argoproj.io/tracking-id(Argo CD). The desired state lives in Git. - kubectl / manual — annotation
kubectl.kubernetes.io/last-applied-configuration(client-side apply) or no manager markers at all.
Phase 3 — Choose the change strategy by owner
- Helm → change through Helm:
helm upgrade <release> <chart> -n <rel-ns>with-f values.yamlor--set, using--reuse-valuesso you do not drop other settings. Neverkubectl edit/patcha Helm-owned resource for a persistent change — the nexthelm upgradewill revert it (drift) or hit a field-manager conflict. If the chart/values source is not available to you, say so: a persistent change needs the chart; a direct kubectl change will be reconciled away on the next upgrade, so do it only as an explicitly acknowledged stop-gap. - GitOps → the source of truth is Git; a direct cluster change will be reconciled away (often within minutes). Recommend changing the Git source (or deliberately suspending reconciliation). Apply directly only as an acknowledged temporary measure, and state that it is temporary.
- kubectl / manual → prefer
kubectl apply --server-side -f <manifest>(declarative, tracks field ownership) or a targetedkubectl patch(strategic-merge by default;--type=merge/jsonwhen needed). Save the manifest to a file first (Write tool) so the change is reviewable and revertible. Avoidkubectl edit(no diff, no audit trail).
Phase 4 — Preview before you change (always)
Prefer previews that do not prompt:
kubectl diff -f change.yaml # exactly what apply would change
helm diff upgrade <release> <chart> -n <ns> -f values.yaml # helm-diff plugin
helm template <chart> -f values.yaml # render locally
Only when a diff is insufficient, fall back to a dry-run apply
(kubectl apply --server-side --dry-run=server -f change.yaml or
helm upgrade --dry-run=server). If the helm-diff plugin is missing, use
helm upgrade --dry-run=server and inspect the rendered output.
Phase 5 — Apply the smallest change
- Change only the intended fields. Do not re-apply a whole fetched manifest (that steals field ownership and can wipe other managers' fields).
- Keep existing labels/annotations, especially
app.kubernetes.io/managed-byandmeta.helm.sh/*. - Server-side apply conflicts: if
apply --server-sidereports a conflict with another manager (e.g.helm,argocd), STOP. Do not--force-conflictson a field owned by Helm/Argo/Flux — stealing ownership breaks that tool. Resolve through the owner (helm upgrade / git) instead.--force-conflictsis only for a manually-owned resource, and only with explicit user approval. - Immutable fields (Service
.spec.clusterIP, Deployment.spec.selector, Job template, …) cannot be patched — they require recreate. For a Helm release that meanshelm upgrade; never manually delete+recreate a Helm-owned resource.
Phase 6 — Verify and report
kubectl rollout status/kubectl getthe target; for Helm,helm status+helm history(confirm a NEW, deployed revision — not a failed one).- Report: the ownership determination, the strategy chosen and why, the exact commands run, the diff, and the post-change health. Cite command + output.
Hard rules
- Preview (diff/dry-run) before every real change — no exceptions.
- Never break the owner. Do not diverge a Helm-owned resource from its
chart; do not
--force-conflictsa field owned by helm/argo/flux; do not manually delete+recreate a Helm resource. - Prod protection. Never modify production namespaces/contexts without an explicit user override.
- Never
deletewithout explicit user confirmation (deletion is destructive; it is gated). - Smallest change. Touch the fewest fields that achieve the goal; preserve existing labels/annotations.
- RBAC denial → escalate, do not retry with a different account.
Output rule
Always finish with a single line:
Result: applied | previewed | blocked | needs-confirmation.
04 同仓库更多 Skills
skill-creator
Create or update a skill playbook (SKILL.md) for the agent. Use when the user wants to create a new skill, add a skill, define a new agent capability, update an existing skill, edit a skill, refine a skill playbook, or specialise the agent for a new domain.
review
Review a body of work (source code, configuration, documents, infra manifests, …) for correctness, clarity, and obvious risks. Use this skill whenever the user asks for a review, audit or critique.
Fallback PDF text extractor using pdftotext (poppler). Use ONLY when the preferred `liteparse` skill is unavailable or for a quick plain-text dump of a simple text PDF — for the best PDF parsing (scanned, multi-column, layout-heavy, or non-PDF formats) prefer the `liteparse` skill.
pandoc
This skill should be used when converting documents between formats (Markdown, DOCX, PDF, HTML, LaTeX, etc.) using pandoc. Use for format conversion, document generation, and preparing markdown for Google Docs or other word processors.
liteparse
Preferred local parser for extracting text from PDFs, images, and scanned/layout-heavy documents (OCR, screenshots, complex PDFs) — far better than pdftotext. Use this FIRST for any PDF, image, or OCR text-extraction or conversion task. NOTE for Office documents (DOCX, PPTX, XLSX, ODT) — for plain text extraction prefer the `pandoc` skill, which needs no LibreOffice; only use LiteParse for Office docs when you need its layout/OCR/screenshot output. The `pdf` skill (pdftotext) is only a fallback for when LiteParse cannot be installed.
linux-admin
Safely make a change to a Linux workstation — install/remove packages, manage systemd services and timers, edit and validate configuration files, manage users/permissions and networking. Detect the distro and package manager, determine whether the target is package-managed or hand-maintained, preview or simulate every change, back up configs before editing, and prefer the package manager and drop-in overrides so the host stays consistent and secure. Use whenever a change to the local Linux host is required (install, remove, enable, disable, start, stop, edit a config, add a user, change permissions or networking).