kubernetes-expert
Deploy secure, production-ready Kubernetes workloads with proper security contexts, resource limits, probes, and network policies. Use when creating Kubernetes manifests, configuring Deployments/StatefulSets/Services, setting up RBAC, or tuning resource limits. Trigger: Kubernetes Deployment, StatefulSet, Service, Ingress, ConfigMap, RBAC, HPA, kubeconform, kube-linter. Do NOT trigger for: Helm chart creation, Dockerfile optimization, Terraform infrastructure provisioning.
- License 许可
- MIT
- 最近更新
- 2026-08-27
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- kubernetes-expert
- license
- MIT
- metadata
- { "author": "Community", "status": "stable", "version": "1.0", "category": "infrastructure" }
- description
- Deploy secure, production-ready Kubernetes workloads with proper security contexts, resource limits, probes, and network policies. Use when creating Kubernetes manifests, configuring Deployments/StatefulSets/Services, setting up RBAC, or tuning resource limits. Trigger: Kubernetes Deployment, StatefulSet, Service, Ingress, ConfigMap, RBAC, HPA, kubeconform, kube-linter. Do NOT trigger for: Helm chart creation, Dockerfile optimization, Terraform infrastructure provisioning.
02 资源文件 13
- 参考文档evals/evals.json2.3 KB
- 参考文档references/autoscaling.md10.2 KB
- 参考文档references/availability.md8.5 KB
- 参考文档references/checklist.md2.7 KB
- 参考文档references/config-secrets.md10.5 KB
- 参考文档references/labels.md7.9 KB
- 参考文档references/networking.md9.3 KB
- 参考文档references/overview.md1.7 KB
- 参考文档references/probes.md9.9 KB
- 参考文档references/rbac.md10.1 KB
- 参考文档references/resources.md7.6 KB
- 参考文档references/security.md9.7 KB
- 参考文档references/validation.md7.6 KB
03 SKILL.md 正文
Kubernetes Expert
Deploy secure, production-ready K8s workloads with proper security contexts, resources, and probes.
Validation
kubeconform -strict | kube-linter lint | kubectl apply --dry-run=server
→ references/validation.md
Security (NON-NEGOTIABLE)
- Forbidden:
privileged|runAsUser: 0|hostNetwork - Required:
runAsNonRoot| drop ALL capabilities | Pod Security Standard:restricted
Resources (MANDATORY)
Define requests/limits on all containers. Rule: memory limit = 2x request. → references/resources.md
Probes (MANDATORY)
Liveness + Readiness + Startup → references/probes.md
Components
labels | networking(Services/NetworkPolicies/Ingress) | rbac(ServiceAccounts/Roles) | availability(PDB/anti-affinity) | autoscaling(HPA) | config-secrets
Checklist
SecurityContext | Resources | Probes | Labels | NetworkPolicy | PDB | HPA | Secrets | Validation → references/checklist.md
Constraints
- NEVER
privileged|runAsUser: 0|hostNetwork| secrets in manifests - ALWAYS define resources+probes | ALWAYS validate with
kubeconform+kube-linter
Overview
Production-grade Kubernetes deployments require mandatory security contexts (non-root, dropped capabilities), resource limits, health probes, and validation pipelines. Every workload must pass kubeconform and kube-linter before deployment.
Quick Reference
| Component | Mandatory Requirement | Example |
|---|---|---|
| SecurityContext | runAsNonRoot: true, drop ALL capabilities |
securityContext: { runAsNonRoot: true, capabilities: { drop: ["ALL"] } } |
| Resources | Requests + limits on all containers | requests.cpu: 100m, limits.memory: 256Mi |
| Probes | Liveness + Readiness + Startup | httpGet: { path: /health, port: 8080 } |
| NetworkPolicy | Restrict pod-to-pod traffic | podSelector: {}, policyTypes: [Ingress] |
| PDB | Minimum available pods | minAvailable: 2 |
| HPA | Auto-scale based on CPU/memory | targetCPUUtilizationPercentage: 70 |
| PodAntiAffinity | Spread across nodes | preferredDuringSchedulingIgnoredDuringExecution |
Workflow
- Create Deployment with non-root security context, resource requests/limits, and all three probes (startup, liveness, readiness)
- Define Service, NetworkPolicy, and Ingress for networking with least-privilege access
- Set up PDB (minAvailable) and HPA (target CPU 70%) for availability and scaling
- Add ConfigMaps and Secrets (never inline secrets) with proper volume mounts
- Validate:
kubeconform -strict→kube-linter lint→kubectl apply --dry-run=server - Deploy via ArgoCD or CI/CD with rollout monitoring
Anti-patterns
FAIL: Running containers as root
# BAD
securityContext:
runAsUser: 0
PASS: Run as non-root user
# GOOD
securityContext:
runAsNonRoot: true
runAsUser: 1001
runAsGroup: 1001
capabilities:
drop: ["ALL"]
readOnlyRootFilesystem: true
FAIL: Missing resource limits
# BAD — container can consume all node resources
resources: {}
PASS: Always set requests and limits
# GOOD
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
FAIL: Using hostNetwork without justification
# BAD
spec:
hostNetwork: true
PASS: Use proper Service networking
# GOOD — never use hostNetwork
apiVersion: v1
kind: Service
spec:
type: ClusterIP
ports:
- port: 8080
FAIL: Privileged container
# BAD
securityContext:
privileged: true
PASS: Drop all capabilities
# GOOD
securityContext:
capabilities:
drop: ["ALL"]
allowPrivilegeEscalation: false
References
- Kubernetes Security Best Practices · last_verified: 2026-05-25
- kube-linter Documentation · last_verified: 2026-05-25
- Kubernetes Production Best Practices Checklist · last_verified: 2026-05-25
Verification Checklist
- [ ] SecurityContext configured:
runAsNonRoot: true,capabilities.drop: ["ALL"] - [ ] Resource requests and limits defined on every container
- [ ] Liveness, readiness, and startup probes configured for all deployments
- [ ] NetworkPolicy restricts pod-to-pod traffic to minimum required
- [ ] PodDisruptionBudget (PDB) set with
minAvailableormaxUnavailable - [ ] HPA configured with target CPU utilization (or custom metric)
- [ ] Manifests pass
kubeconform -strictandkube-linter lint
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Pod stuck in CrashLoopBackOff |
Startup probe failing or resource limits too low | Check probe endpoint and timing; increase initialDelaySeconds or resource limits |
| ImagePullBackOff | Wrong image tag or registry credentials missing | Verify image name and tag in deployment; check imagePullSecrets |
| Pod evicted due to disk pressure | Node disk space exhausted | Review logging configuration; add log rotation; increase node disk size |
| Known issue: HPA fails to scale when using custom metrics | Metrics adapter not deployed or custom metric name mismatch | Verify metrics-server or Prometheus adapter is running; check metric name in HPA matches exported metric exactly |
| [WARN] HPA scales down too aggressively after traffic spike | Default scaleDown stabilization window (5 min) too short for sporadic workloads | Set behavior.scaleDown.stabilizationWindowSeconds: 300; add pods metric with longer window |
| Pod anti-affinity with topologyKey hostname prevents scheduling when node count < replica count | preferredDuringScheduling blocks all pods on same node due to soft constraint conflict | Use requiredDuringScheduling only for must-have; soften with preferred + weight: 50 for flexibility |
| Gotcha: kubectl apply --server-side conflicts with client-side ownerReferences | Server-side apply uses field management; ownerReferences set by controller cause manageFields conflict | Use --server-side=true or disable ownership in controller; check managedFields before apply |
04 同仓库更多 Skills
web-browsing-agent-expert
Web browsing for AI agents: driving a headless browser (Playwright, Puppeteer) from agent tooling, navigation and page-state grounding, DOM extraction and structured data capture, form interaction, session and cookie management, anti-bot mitigation awareness, and safe browsing rules (no PII exfiltration, respect robots and terms). Use when building a browsing tool or MCP server for an agent, teaching an agent to navigate and read web pages, extracting structured content from dynamic sites, or handling login walls and pagination in agent workflows. Trigger: web browsing agent, headless browser, Playwright MCP, Puppeteer, browser automation for agents, DOM extraction, page navigation, session management. Do NOT trigger for: end-to-end UI testing of an application (use playwright-expert); writing standalone scraping scripts for data pipelines (use python-expert); fetching a single public URL (use the fetch tool).
vector-databases
Design and operate vector databases for cloud-native AI features. Use when selecting between pgvector, Pinecone, or Weaviate for AI context layer or integration-hub; designing embedding schemas and index parameters; implementing ANN search with metadata filtering; managing embedding model versions; optimizing query latency; or debugging low retrieval quality. Pairs with rag-architecture for pipeline design and postgres-database-expert for pgvector specifics. Trigger: vector database, pgvector, Pinecone, Weaviate, embedding, ANN search, HNSW, cosine similarity. Do NOT trigger for: relational SQL optimization, standard PostgreSQL schema design, Redis caching.
typescript-expert
Full-stack TypeScript stack for modern projects: frontend SSR/CSR with Next.js 14 App Router and React, backend APIs with Node.js (Express/Fastify), state management with Zustand/Redux Toolkit, unit and integration testing with Vitest/Jest + React Testing Library + MSW, and static analysis with ESLint/Prettier/tsc. Use when building React components or hooks, implementing Next.js App Router or Server Components, writing Node.js REST API handlers, implementing middleware (auth, rate-limit, logging), managing client state (Zustand/RTK), writing frontend/backend tests, or running TypeScript linting/type checks. Trigger: TypeScript, Next.js, React, Zustand, Node.js, Express, Fastify, MSW, Vitest. Do NOT trigger for: Python backend development, Go microservices, iOS/mobile development.
tool-usage
Guide correct tool selection, design, and orchestration for AI agents. Use when choosing between dedicated vs Bash tools, designing MCP tool interfaces, naming tool parameters, handling tool response limits, orchestrating parallel vs sequential calls, evaluating tool accuracy, applying ACI design principles, selecting workflow patterns, or reading/filtering/transforming/generating structured data (JSON, YAML, CSV, TOML, XML). Trigger: tool selection, MCP tool design, orchestration, ACI, parallel execution, composite tool, structured data, jq, yq, dasel, mlr, csvkit. Do NOT trigger for: writing application business logic, domain-specific development (route to domain skill), database migrations.
token-efficiency
Enforce token-efficient output, compression, caching, and model routing. Use when calibrating response verbosity, applying compression strategies to logs or RAG chunks, routing tasks to the right model tier, setting thinking budgets, enforcing word limits, compressing context before reinitiation, applying KV-cache ordering, masking tool output observations, or applying clarification-first protocol before irreversible actions. Trigger: token efficiency, compression, model routing, thinking budget, KV-cache, clarification protocol. Do NOT trigger for: non-agent tooling, CI/CD pipeline scripting, infrastructure provisioning.
time-series-db
Time-series database patterns for cloud-native metrics and analytics: TimescaleDB, InfluxDB, and Amazon Timestream selection; continuous aggregates, retention policies, downsampling, and integration with Prometheus/Grafana. Use when storing business metrics over time, building custom business dashboards, designing high-frequency event storage, or querying time-bucketed aggregations. Trigger: time-series, TimescaleDB, InfluxDB, Prometheus, Grafana, hypertable, continuous aggregate, retention policy. Do NOT trigger for: relational PostgreSQL schema design, NoSQL document stores, Kafka event streaming.