Skip to content
Back to skills

Kubernetes Database Analyst

ASecurity

Analyzes data from databases in Kubernetes clusters by setting up port forwarding, executing SQL queries, and generating CSV reports.

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

Security analysis

A100/100

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

Scanned May 29, 2026

npx -y skills add zjunlp/Skills --skill kubernetes-database-analyst --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Kubernetes Database Analyst?

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

Security grade badge for Kubernetes Database Analyst
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/zjunlp-kubernetes-database-analyst/badge)](https://www.skillsdirectory.com/skills/zjunlp-kubernetes-database-analyst)

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-database-analyst
description: Analyzes data from databases in Kubernetes clusters by setting up port forwarding, executing SQL queries, and generating CSV reports.
---
# Instructions

## Phase 1: Initial Setup & Discovery
1.  **Read the Task:** Use `filesystem-read_file` to read the task file (e.g., `task.md`) to understand the analytical questions and required output format.
2.  **Inspect Kubernetes Resources:** Use `k8s-kubectl_get` to list all resources in the target namespace (e.g., `data`). Identify the database `Service` (e.g., `mysql-f1`) and its corresponding `Pod`.
3.  **Establish Database Connection:** Use `k8s-port_forward` to create a persistent port forward from a local port (e.g., `30124`) to the database service's target port (e.g., `3306`). **Note the `portForwardId`** to keep it alive.
4.  **List Workspace Files:** Use `filesystem-list_directory` to identify any template or input files in the workspace.

## Phase 2: Database Schema Exploration
5.  **Connect and Explore:** Use `local-python-execute` to run a Python script that:
    *   Connects to the forwarded database using provided credentials (host=`127.0.0.1`, port=`[LOCAL_PORT]`).
    *   Lists all tables to understand the data structure.
    *   Examines the schema of key tables relevant to the task (e.g., `drivers`, `constructors`, `results`, `races`, `standings` tables).

## Phase 3: Query Execution & Analysis
6.  **Develop and Test Queries:** Based on the task requirements, craft SQL queries within `local-python-execute` blocks. Test them iteratively to ensure correctness.
    *   For ranking/aggregation tasks (e.g., "highest points per year"), join `races`, `standings`, and dimension tables (`drivers`, `constructors`). Use window functions or subqueries with `GROUP BY` and `MAX()`.
    *   For complex conditional logic (e.g., "same constructor in first and last race"), use Common Table Expressions (CTEs) to break down the problem: filter by date/year, calculate first/last race per driver-season, count distinct rounds, and join on constructor ID.
7.  **Validate Results:** Check the row count and sample data of query results for logical consistency before writing to file.

## Phase 4: Report Generation & Cleanup
8.  **Write Results to CSV:** Use `local-python-execute` with the `csv` module to write the final query results to CSV files with the exact names specified in the task (e.g., `results_1.csv`, `results_2.csv`). Ensure headers match the template format.
9.  **Remove Template Files:** Use `local-python-execute` with `os.remove()` to delete any provided template files from the workspace as instructed.
10. **Verify Output:** Use `filesystem-read_multiple_files` to confirm the final CSV files exist and contain the expected data.
11. **Finalize:** The port forward started in Step 3 should remain active. Use `local-claim_done` to signal task completion.

Files in this skill

  • SKILL.md2.8 KB
  • references/kubernetes_commands.md72 B
  • references/sql_patterns.md80 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.

View all in databases →

Comments

Loading comments…

Newsletter

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