$npx -y skills add mjunaidca/mjs-agent-skills --skill kubernetesProduction-grade Kubernetes manifests and debugging for containerized applications. This skill should be used when users ask to deploy to Kubernetes, create K8s manifests, containerize for K8s, set up Deployments/Services/Jobs/StatefulSets/CronJobs, create namespaces with resourc
| 1 | # Kubernetes |
| 2 | |
| 3 | Production-grade K8s manifests with security-first defaults and educational comments. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## Resource Detection & Adaptation |
| 8 | |
| 9 | **Before generating manifests, detect the target environment:** |
| 10 | |
| 11 | ```bash |
| 12 | # Detect node resources |
| 13 | kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}: {.status.capacity.memory}, {.status.capacity.cpu}{"\n"}{end}' |
| 14 | |
| 15 | # Detect if Docker Desktop (local) or real cluster |
| 16 | kubectl get nodes -o jsonpath='{.items[0].metadata.labels.node\.kubernetes\.io/instance-type}' 2>/dev/null || echo "local" |
| 17 | |
| 18 | # Detect available resources |
| 19 | kubectl describe nodes | grep -A 5 "Allocated resources" |
| 20 | ``` |
| 21 | |
| 22 | **Adapt configurations based on detection:** |
| 23 | |
| 24 | | Detected Environment | Profile | Default Limits | Agent Action | |
| 25 | |---------------------|---------|----------------|--------------| |
| 26 | | Docker Desktop < 6GB | Minimal | 128Mi-256Mi | Warn, reduce replicas | |
| 27 | | Docker Desktop 6-10GB | Standard | 256Mi-512Mi | Normal deployment | |
| 28 | | Cloud/Real cluster | Production | Based on node size | Full features | |
| 29 | |
| 30 | ### Agent Behavior |
| 31 | |
| 32 | 1. **Detect** cluster type and resources before generating manifests |
| 33 | 2. **Adapt** resource requests/limits to cluster capacity |
| 34 | 3. **Warn** if requested workload exceeds available resources |
| 35 | 4. **Calculate** safe limits: `(node_memory * 0.7) / expected_pod_count` |
| 36 | |
| 37 | ### Adaptive Resource Templates |
| 38 | |
| 39 | **Local/Constrained (< 6GB allocatable):** |
| 40 | ```yaml |
| 41 | resources: |
| 42 | requests: |
| 43 | memory: 128Mi |
| 44 | cpu: 100m |
| 45 | limits: |
| 46 | memory: 256Mi |
| 47 | cpu: 500m |
| 48 | ``` |
| 49 | |
| 50 | **Standard (6-16GB allocatable):** |
| 51 | ```yaml |
| 52 | resources: |
| 53 | requests: |
| 54 | memory: 256Mi |
| 55 | cpu: 100m |
| 56 | limits: |
| 57 | memory: 512Mi |
| 58 | cpu: 1000m |
| 59 | ``` |
| 60 | |
| 61 | **Production (> 16GB or cloud):** |
| 62 | ```yaml |
| 63 | resources: |
| 64 | requests: |
| 65 | memory: 512Mi |
| 66 | cpu: 250m |
| 67 | limits: |
| 68 | memory: 1Gi |
| 69 | cpu: 2000m |
| 70 | ``` |
| 71 | |
| 72 | ### Pre-Deployment Validation |
| 73 | |
| 74 | Before applying manifests, agent should verify: |
| 75 | ```bash |
| 76 | # Check if deployment would exceed node capacity |
| 77 | kubectl get nodes -o jsonpath='{.items[0].status.allocatable.memory}' |
| 78 | ``` |
| 79 | |
| 80 | If insufficient: warn user and suggest scaling down or increasing Docker Desktop resources. |
| 81 | |
| 82 | --- |
| 83 | |
| 84 | ## What This Skill Does |
| 85 | |
| 86 | **Analysis & Detection:** |
| 87 | - Auto-detects from Dockerfile: ports, health endpoints, resources |
| 88 | - Identifies workload type from project structure |
| 89 | - Reads existing manifests to understand patterns |
| 90 | - Detects GPU requirements from dependencies |
| 91 | |
| 92 | **Generation:** |
| 93 | - Creates production-hardened manifests (non-root, read-only, resource limits) |
| 94 | - Generates all supporting resources (Service, ConfigMap, HPA, PDB) |
| 95 | - Creates namespace governance (ResourceQuota, LimitRange, NetworkPolicy) |
| 96 | - Supports multi-team isolation with environment progression (dev → staging → prod) |
| 97 | - Adds educational comments explaining WHY each config choice |
| 98 | - Outputs ArgoCD-compatible directory structure |
| 99 | |
| 100 | **Validation:** |
| 101 | - Verifies kubectl context exists |
| 102 | - Creates namespace if needed |
| 103 | - Deploys to local cluster (kind/minikube) |
| 104 | - Confirms pods are running before delivering |
| 105 | |
| 106 | **Security:** |
| 107 | - Non-root user by default (runAsNonRoot: true) |
| 108 | - Read-only root filesystem |
| 109 | - No privilege escalation |
| 110 | - Dropped capabilities |
| 111 | - Resource limits always set |
| 112 | - **Unprivileged ports only** (>=1024) - privileged ports (<1024) require root |
| 113 | |
| 114 | ## What This Skill Does NOT Do |
| 115 | |
| 116 | - Generate Helm charts (document in references for future) |
| 117 | - Create Kustomize overlays (document in references for future) |
| 118 | - Handle Dapr sidecar injection (separate skill) |
| 119 | - Deploy Kafka/Strimzi operators (separate skill) |
| 120 | - Generate ArgoCD Application CRDs (separate skill) |
| 121 | |
| 122 | --- |
| 123 | |
| 124 | ## Before Implementation |
| 125 | |
| 126 | Gather context to ensure successful implementation: |
| 127 | |
| 128 | | Source | Gather | |
| 129 | |--------|--------| |
| 130 | | **Codebase** | Dockerfile, existing manifests, port/health patterns | |
| 131 | | **Conversation** | Target environment, namespace, special requirements | |
| 132 | | **Skill References** | Security contexts, health probes, resource limits | |
| 133 | | **User Guidelines** | Cluster conventions, naming standards | |
| 134 | |
| 135 | --- |
| 136 | |
| 137 | ## Required Clarifications |
| 138 | |
| 139 | After auto-detection, confirm with user if ambiguous: |
| 140 | |
| 141 | | Question | When to Ask | |
| 142 | |----------|-------------| |
| 143 | | Target environme |