Claude-skill-registry kubernetes-cluster-cleanup-automator
Identifies and cleans up outdated Kubernetes deployments based on namespace patterns and application version age. Discovers deployments, analyzes release dates from annotations, performs cleanup actions, and notifies stakeholders.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/kubernetes-cluster-cleanup-automator" ~/.claude/skills/majiayu000-claude-skill-registry-kubernetes-cluster-cleanup-automator && rm -rf "$T"
manifest:
skills/data/kubernetes-cluster-cleanup-automator/SKILL.mdsource content
Instructions
Primary Objective
Automatically identify Kubernetes deployments in target namespaces that are running application versions older than a specified threshold, stop those deployments, and notify the responsible cluster administrator.
Core Workflow
1. Discover Target Namespaces
- Use
to list all namespacesk8s-kubectl_get - Filter namespaces by name pattern (default: names starting with 'dev-')
- Store the filtered namespace list for subsequent operations
2. Discover Deployments in Target Namespaces
- For each target namespace, use
to list all deploymentsk8s-kubectl_get - Collect deployment metadata including name, namespace, and creation timestamp
3. Analyze Deployment Version Information
- For each discovered deployment, use
to get detailed informationk8s-kubectl_describe - Extract the
annotation (expected format: ISO 8601 timestamp)app-version-release-date - Calculate the age of the version relative to current date
- Flag deployments where version age exceeds threshold (default: 30 days)
4. Identify Cluster Administrator Contact
- Search for contact information using multiple approaches:
- Search emails for relevant keywords: "cluster management", "cluster admin", "kubernetes", "infrastructure"
- Examine local filesystem for contact documents or configuration files
- Check PDF documents for team contact information (look for "Cluster & Computing Resources" or similar sections)
- Extract email address of responsible person (typically found in team contact tables)
5. Perform Cleanup Actions
- For each outdated deployment, use
to set replicas to 0k8s-kubectl_scale - This effectively "stops" the deployment without deleting it
- Verify each scale operation completes successfully
6. Compile and Send Notification
- Sort outdated deployments chronologically from oldest to newest release date
- Calculate exact number of days since each version was released
- Format email according to specified template
- Use
to notify the identified cluster administratoremails-send_email - Include count of cleaned deployments and detailed list with namespace/deployment names and version ages
Key Parameters & Configuration
- Namespace Pattern: Default 'dev-*' (configurable via user input)
- Age Threshold: Default 30 days (configurable via user input)
- Date Annotation: Looks for
annotation on deploymentsapp-version-release-date - Contact Search: Multiple fallback strategies for finding cluster admin
Error Handling & Edge Cases
- If no namespaces match the pattern, report this and exit gracefully
- If deployments lack the version annotation, skip them with a note
- If cluster admin contact cannot be found, pause and request guidance
- If scale operations fail, log the error but continue with others
- Always verify email was sent successfully
Output Format
The final email must follow this exact format: