Skip to content
Back to skills

Kubernetes Cluster Cleanup Automator

ASecurity

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.

  • 8 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added May 29, 2026
devopskubernetes

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned May 29, 2026

npx -y skills add zjunlp/Skills --skill kubernetes-cluster-cleanup-automator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kubernetes Cluster Cleanup Automator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Kubernetes Cluster Cleanup Automator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/zjunlp-kubernetes-cluster-cleanup-automator/badge)](https://www.skillsdirectory.com/skills/zjunlp-kubernetes-cluster-cleanup-automator)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: kubernetes-cluster-cleanup-automator
description: 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.
---
# 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 `k8s-kubectl_get` to list all namespaces
- 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 `k8s-kubectl_get` to list all deployments
- Collect deployment metadata including name, namespace, and creation timestamp

### 3. Analyze Deployment Version Information
- For each discovered deployment, use `k8s-kubectl_describe` to get detailed information
- Extract the `app-version-release-date` annotation (expected format: ISO 8601 timestamp)
- 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 `k8s-kubectl_scale` to set replicas to 0
- 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 `emails-send_email` to notify the identified cluster administrator
- 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 `app-version-release-date` annotation on deployments
- **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:

Files in this skill

  • SKILL.md3.2 KB
  • references/annotation_schema.md454 B
  • references/contact_discovery_flow.md167 B
  • references/email_template.md116 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.