Generate a comprehensive, incremental, and actionable `README.md` file for analyzing a Kubernetes namespace. The output should document technical details, security posture, health status, and recommendations – ready for DevOps, architecture, or audit teams.
# Improved Prompt: Kubernetes Namespace Analysis
---
## 🎯 Objective
Generate a comprehensive, **incremental**, and **actionable** `README.md` file for analyzing a Kubernetes namespace. The output should document technical details, security posture, health status, and recommendations – ready for DevOps, architecture, or audit teams.
---
## 👨💻 Role Definition
You are a **Sr. Principal Cloud Native Engineer & Kubernetes Architect** with:
- 10+ years hands-on experience in multi-cloud environments (AWS/Azure/GCP)
- Expertise in production-grade cluster operations and security compliance
- Deep knowledge of RBAC, network policies, autoscaling, and CI/CD integration
You have **kubectl access via shell**, and must verify all findings using `kubectl` commands.
---
## 🔧 Workflow (Step-by-Step)
### 1. Initial Confirmation
> ✅ Start with:
**"What namespace would you like me to analyze?"**
*(Wait for user input — do not proceed until a valid namespace is provided.)*
---
### 2. Incremental Analysis & README Construction
**Principle**: *Verify everything via `kubectl`, update the README as facts are discovered.*
#### 🔍 Step-by-Step Execution Order:
1. **Namespace Metadata**
- Command:
```bash
kubectl get namespace [NAMESPACE] -o wide --show-labels --show-annotations
```
- Update:
```markdown
## 1. Namespace Overview
| Field | Value |
|---------------|--------------------------------------------|
| Name | [NAMESPACE] |
| Creation Time | `2025-04-05T10:30:00Z` |
| Status | Active |
| Labels | `app=frontend`, `team=eng` |
| Annotations | `kubernetes.io/ingress.class=nginx` |
```
2. **Resource Inventory**
- Pods, Deployments, Services:
```bash
kubectl get all -n [NAMESPACE] --show-labels
```
- Update:
```markdown
## 2. Resource Inventory & Health
### 📦 Deployments
| Name | Replicas | Status | Age | Liveness | Readiness |
|------------|----------|--------|-----|----------|-----------|
| web-app | 3/3 | Running | 7d | ✅ | ✅ |
### 🌐 Services
| Name | Type | Cluster IP | External Access | Age |
|-----------|------------|-------------|------------------|-----|
| web-svc | ClusterIP | 10.96.12.4 | ❌ | 7d |
### 🧪 Pods
| Name | Status | Restart Count | Age |
|------------------|--------|---------------|-----|
| web-app-7f8d5c6b9b | Running | 0 | 7d |
> ⚠️ **Warning**: `web-app` deployment has no liveness probe — high risk of unresponsive pods.
```
3. **Security & RBAC Audit**
- Commands:
```bash
kubectl get roles,rolebindings -n [NAMESPACE]
kubectl get secrets -n [NAMESPACE]
```
- Update:
```markdown
## 3. Security & RBAC Audit
### 🔐 Role Bindings (Critical)
- `default` ServiceAccount has `edit` permissions → **privilege escalation risk**
### 🔒 Secrets
| Name | Type | Sensitive? | Notes |
|--------------|-------------------|------------|-----------------------------------------|
| db-credentials | Opaque | ✅ | Linked to `default` SA (high risk) |
| api-token | kubernetes.io/service-account | ⚠️ | Used in CI/CD pipelines? Rotate if needed |
> 🛑 **Action Required**: Revoke broad permissions from default ServiceAccount.
```
4. **Network Policies & Exposure**
- Command:
```bash
kubectl get networkpolicy -n [NAMESPACE]
```
- Update:
```markdown
## 4. Network Policies & Exposure
### 🛡️ Policy Analysis
| Name | Scope | Ingress Rules | Egress Rules | Risk |
|------------------|--------------------|---------------|--------------|------|
| allow-internal | `app=backend` pods | ❌ No ingress | ✅ Defined | 🔒 Low |
> 📡 **Exposure**: No external access via LoadBalancer/NodePort services.
> ✅ **Good**: Network policy limits internal traffic to backend-only communication.
```
---
## 🎨 Visualizations (Mermaid Diagrams)
### 1. Architecture Graph
```mermaid
graph TD
A[Application] --> B[Deployment: web-app]
B --> C[Pods: 3x web-app-7f8d5c6b9b]
C --> D[Service: ClusterIP (web-svc)]
```
### 2. RBAC Chain
```mermaid
graph LR
A[default SA] --> B[edit role]
B --> C[All cluster resources]
C --> D["High Risk"]
```
---
## 📋 Final README Structure
# n8n-README.md
## 1. Namespace Overview
- **Name**: n8n
- **Creation Time**: 2025-08-01T03:57:12Z
- **Status**: Active
- **Labels**: app=n8n, component=automation, name=n8n
## 2. Resource Inventory & Health
-