Removes a deployed llm-d inference stack (v1.0+) from Kubernetes or OpenShift, including router Helm releases, model servers, monitoring objects, and guide-specific extras. Handles partial cleanup and prefers the guide's own cleanup steps.
Ships in teardown-llm-d. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Cleanly remove a deployed llm-d stack from a Kubernetes namespace. An llm-d v1.0 stack consists of:
| Part | Created by | Removed by |
|---|---|---|
Router: EPP Deployment, Services <guide>-epp and <guide>-epp-model-servers, ConfigMaps, Roles, the chart's ClusterRole and ClusterRoleBinding, InferencePool <guide>, and in gateway mode the HTTPRoute <guide> with provider policies | `helm install llm-d-router-standalone | gateway` |
Model servers: Deployment (aggregated) or DisaggregatedSet (prefill/decode, wide-EP), ServiceAccount, ConfigMaps, PVCs or ResourceClaimTemplates in some overlays | kubectl apply -k guides/<guide>/modelserver/<accelerator>/<engine>/<provider> | the guide's cleanup.modelserver step, which is kubectl delete -k of the same overlay |
Monitoring objects (PodMonitor, PodMonitoring) | kubectl apply -k guides/recipes/modelserver/components/monitoring[-pd] | kubectl delete -k of the same component |
| Guide-specific extras (objectives, render pods, Mooncake store, model-cache PVC, metrics-reader ClusterRoleBindings) | guide-specific deploy steps | the guide's other cleanup.* steps |
Gateway llm-d-inference-gateway (gateway mode) | kubectl apply -k guides/recipes/gateway/<provider> | user decision (opt-in) |
Secret llm-d-hf-token, PVCs, the namespace | prerequisites | kept unless the user asks |
Workload pods carry the labels llm-d.ai/guide=<guide> and llm-d.ai/role=prefill|decode. Chart-created objects carry no llm-d.ai/guide label; they are found through helm list. The helper scripts/inventory.sh prints all of the above for a namespace.
Always confirms with the user before deleting anything.
NAMESPACE environment variable is set, use it.oc project:
oc project -q 2>/dev/null
Verify the stack is present:
helm list -n $NAMESPACE
kubectl get pods -n $NAMESPACE -L llm-d.ai/guide,llm-d.ai/role
If no llm-d resources are found, tell the user and stop.
The removal commands are the guide's own cleanup steps when the guide and its variables are known. Recover them, in this order:
deploy-llm-d skill writes deployments/deploy-YYYYMMDD.sh with a header naming the guide and namespace and an env block with the variables:
REC=$(grep -l "namespace: ${NAMESPACE}" deployments/deploy-*.sh 2>/dev/null | sort | tail -1)
[ -n "$REC" ] && grep -E '^# llm-d:|^# sections:|^export (REPO_ROOT|GUIDE_NAME|NAMESPACE|ACCELERATOR_TYPE|MODEL_SERVER|INFRA_PROVIDER|MODEL|TOPOLOGY|VARIANT|CONNECTOR|HOST_TYPE|TASK)=' "$REC"
From it set LLMD_PATH (the REPO_ROOT export), GUIDE_DIR (REPO_ROOT joined with the guide: path of the header), and the --var values that were used. The # sections: line names the deploy sections that ran (for example deploy.modelserver.standard); the matching cleanup.modelserver.standard is the removal step. Also note the custom overlays or values files the record references (Step 4.4 of deploy-llm-d); those replace the corresponding guide steps.helm list -n $NAMESPACE -o json | jq -r '.[] | "\(.name)\t\(.chart)"'. A release whose chart starts with llm-d-router- is a router release; for a guide deployment its name is the guide name (GUIDE_NAME), hand-rolled stacks may use any name. Other llm-d charts (llm-d-async, batch-gateway, ipp, FMA) belong to README-only operations guides.kubectl get deployments,statefulsets,disaggregatedsets.disaggregatedset.x-k8s.io -n $NAMESPACE -L llm-d.ai/guide,llm-d.ai/role gives the guide name when no record exists.LLMD_PATH is still unknown, use the environment variable, a nearby clone, or ask. Without a checkout, the guide's cleanup steps cannot be emitted; fall back to Step 4b.Set GUIDE_PY="python3 ${LLMD_PATH}/scripts/guide.py" (or uv run ${LLMD_PATH}/scripts/guide.py) when a checkout exists.
Run the inventory and read it with the user:
bash skills/teardown-llm-d/scripts/inventory.sh $NAMESPACE ${GUIDE_NAME:-}
When a guide.yaml is available, read its cleanup steps and their when: and skip_in: filters:
sed -n '/^cleanup:/,$p' ${GUIDE_DIR}/guide.yaml
(The deploy-llm-d skill's scripts/list-guide-steps.py, when installed, prints the same information classified per step path.)
Present the plan before touching anything:
Teardown plan for namespace: <NAMESPACE>
Guide: <GUIDE_NAME> (<GUIDE_DIR> | unknown) Source of commands: guide.yaml cleanup | kubectl delete -k | label selectors
1. Model servers (removed first, so pods drain before the router goes):
- <Deployment|DisaggregatedSet names> (<n> pods, roles: ...)
- command: <cleanup.modelserver command | kubectl delete -k <overlay> | label-based delete>
2. Monitoring and guide extras:
- <PodMonitors, objectives, render pods, ...> with their commands
3. Router Helm release(s):
- helm uninstall <release> -n <NAMESPACE> (removes EPP, InferencePool, chart RBAC, HTTPRoute in gateway mode)
Opt-in (ask separately, default keep):
- HTTPRoutes not owned by the release: <list or none>
- Gateway llm-d-inference-gateway: <present | none>
- PVCs: <list or none>
- Secret llm-d-hf-token: <present | none>
- Namespace <NAMESPACE>
- Cluster-scoped objects the guide created (ClusterRoleBindings named <guide>-metrics-reader, CRDs): <list or none>
Shall I proceed with items 1 to 3?
For a partial teardown (for example "remove only the model servers, keep the router"), keep only the requested items in the plan and say explicitly what stays.
Write the plan's commands to deployments/teardown-YYYYMMDD.sh (header with namespace, guide, and source of commands; opt-in commands commented out with an # OPT-IN: prefix). This file is the record of what ran.
Do not proceed until the user confirms.
With GUIDE_DIR and the variables known, emit the guide's own cleanup steps into the teardown record. Select the sections first:
cleanup that is a flat list (flow-control, pod-snapshot, fast-model-actuation): the single section cleanup.cleanup with sub-groups (cleanup.modelserver, cleanup.rest, and guide extras such as cleanup.render, cleanup.storage, cleanup.mooncake, cleanup.router): every sub-group, in the guide's order. Where a sub-group has members (cleanup.modelserver.standard and cleanup.modelserver.dynamic_slice in optimized-baseline), take only the member that matches the deployed variant, which is the deploy.<group>.<member> recorded in the # sections: line. Members gated by when: select themselves from the variables; members without when: are alternatives and emitting the whole group would run the wrong overlay deletion and abort the script.The guide's order is already model servers first, router release and monitoring last:
EMIT_VARS=(--var REPO_ROOT=${LLMD_PATH} --var NAMESPACE=${NAMESPACE} --var ACCELERATOR_TYPE=... --var MODEL_SERVER=... --var INFRA_PROVIDER=... --var MODEL=...)
CLEANUP_SECTIONS=(cleanup.modelserver.standard cleanup.rest) # per the selection above
mkdir -p deployments
{
echo "# Teardown script generated by teardown-llm-d on $(date -u +%Y-%m-%dT%H:%MZ)"
echo "# llm-d: $(git -C ${LLMD_PATH} describe --tags --always) guide: ${GUIDE_DIR#${LLMD_PATH}/} namespace: ${NAMESPACE}"
${GUIDE_PY} emit ${GUIDE_DIR} env "${CLEANUP_SECTIONS[@]}" "${EMIT_VARS[@]}"
} > deployments/teardown-$(date +%Y%m%d).sh
grep -nE 'kubectl delete (namespace|crd|clusterrole|clusterrolebinding)|(pvc|persistentvolumeclaim|secret)' deployments/teardown-*.sh
Review the file. Every step that the grep flags (namespace, CRDs, ClusterRoles and ClusterRoleBindings, PVCs, Secrets) is opt-in: comment out all of its lines with an # OPT-IN: prefix (steps can span several lines, so edit the step, not a single line). If the deployment used a custom overlay (deployments/<name>/kustomization.yaml), replace the guide's kubectl delete -k .../modelserver/... step with kubectl delete -n ${NAMESPACE} -k deployments/<name>. Show the resulting script to the user; after confirmation:
bash deployments/teardown-$(date +%Y%m%d).sh
kubectl wait --for=delete pod -n ${NAMESPACE} -l llm-d.ai/guide=${GUIDE_NAME} --timeout=300s
The script runs with set -euo pipefail, so it stops at the first failing step. A step that fails because the object is already gone (not found, release: not found) is not an error: run the remaining steps of the file by hand and continue.
kubectl delete deployments,statefulsets,disaggregatedsets.disaggregatedset.x-k8s.io -n ${NAMESPACE} -l llm-d.ai/guide=${GUIDE_NAME} --ignore-not-found
kubectl wait --for=delete pod -n ${NAMESPACE} -l llm-d.ai/guide=${GUIDE_NAME} --timeout=300s
kubectl delete services,serviceaccounts,configmaps,resourceclaimtemplates.resource.k8s.io -n ${NAMESPACE} -l llm-d.ai/guide=${GUIDE_NAME} --ignore-not-found
Objects of the overlay that carry no label (the ServiceAccount of some DisaggregatedSet overlays, PodMonitors, ScaledObjects) appear in the inventory by name; list them to the user and delete them by name after confirmation.helm uninstall <release> -n ${NAMESPACE} for every router release the user confirmed.helm list -n ${NAMESPACE} and the inventory script.InferencePool.helm uninstall <release> -n ${NAMESPACE}. The model servers keep running without a router in front of them.Ask about each group separately and only act on an explicit yes. Never remove these as part of "tear down the stack".
| Item | Command | Notes |
|---|---|---|
| HTTPRoutes not owned by the release | kubectl delete httproute <name> -n ${NAMESPACE} | the chart's HTTPRoute is already gone with helm uninstall |
| Gateway | kubectl delete gateway llm-d-inference-gateway -n ${NAMESPACE} | shared by every guide deployed in gateway mode in this namespace |
| PVCs | kubectl delete pvc <name> -n ${NAMESPACE} | model caches, FS KV tiers, benchmark workload-pvc; data loss |
Secret llm-d-hf-token | kubectl delete secret llm-d-hf-token -n ${NAMESPACE} | needed again by the next deployment |
| Namespace | kubectl delete namespace ${NAMESPACE} | removes everything above as well |
| Cluster-scoped objects the guide created | the guide's own kubectl delete clusterrolebinding ... or kubectl delete crd ... cleanup lines | confirm they were created for this deployment and are not shared; otherwise hand to the cluster administrator |
Never uninstall shared controllers (LeaderWorkerSet in lws-system, KEDA, Gateway providers, the Gateway API and Inference Extension CRDs). They are cluster infrastructure.
bash skills/teardown-llm-d/scripts/inventory.sh $NAMESPACE ${GUIDE_NAME:-}
helm list -n $NAMESPACE
kubectl get pods -n $NAMESPACE
Report what remains and whether it is expected (kept PVCs, the Secret, the Gateway, unrelated workloads). Pods of a DisaggregatedSet can take a minute to terminate; kubectl get leaderworkersets.leaderworkerset.x-k8s.io -n $NAMESPACE must be empty once the set is gone.
compare-llm-d-configurations calls this skill between runs with fixed constraints: uninstall the Helm releases, remove the model servers, remove HTTPRoutes and the Gateway, keep PVCs, keep the Secret, keep the namespace, and do not ask about the optional steps. Apply exactly those constraints when the caller states them.
$NAMESPACE. The only cluster-scoped deletions are the ones the guide's own cleanup lists, and they are opt-in (Step 5).kubectl delete -k of the recorded overlay, then label selectors.deployments/teardown-YYYYMMDD.sh.guide.yaml guide, from a custom overlay under deployments/, or by hand with helm and kubectl apply -kWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
/teardown-llm-d:teardown-llm-dfrom teardown-llm-d
npx claudepluginhub llm-d-incubation/llm-d-skills --plugin teardown-llm-d