allowed-tools: Read, WebFetch, Bash(kubectl:*), Bash(fd:*), Bash(rg:*), Bash(jq:*), Bash(gdate:*), Bash(helm:*)
name: "Context Load K8s"
description: "Load comprehensive Kubernetes documentation context with cluster-specific optimization"
author: "wcygan"
tags: ["context","k8s"]
version: "1.0.0"
created_at: "2025-07-14T00:00:00Z"
updated_at: "2025-07-14T00:00:00Z"
- Session ID: !`gdate +%s%N`
- Current directory: !`pwd`
- K8s config: !`kubectl config current-context 2>/dev/null || echo "No kubectl context"`
- K8s cluster info: !`kubectl cluster-info --short 2>/dev/null || echo "No cluster connection"`
- K8s manifests: !`fd "\.(yaml|yml)$" . | rg -l "(apiVersion|kind)" | head -10 || echo "No K8s manifests found"`
- Helm charts: !`fd "Chart\.(yaml|yml)$" . | head -5 || echo "No Helm charts found"`
- K8s tools: !`(which kubectl helm kustomize 2>/dev/null | wc -l | tr -d ' ') || echo "0"` available
- Namespaces: !`kubectl get namespaces --no-headers 2>/dev/null | wc -l | tr -d ' ' || echo "0"`
- Running pods: !`kubectl get pods --all-namespaces --no-headers 2>/dev/null | wc -l | tr -d ' ' || echo "0"`
- Technology stack: !`fd "(deno\.json|package\.json|Cargo\.toml|go\.mod)" . | head -3 || echo "K8s-only project"`
STEP 1: Initialize context loading session
- CREATE session state file: `/tmp/k8s-context-$SESSION_ID.json`
- VALIDATE session ID generation and file creation permissions
- SET initial state:
{
"sessionId": "$SESSION_ID",
"phase": "discovery",
"cluster_context": null,
"context_sources": [],
"loaded_topics": [],
"k8s_features_detected": [],
"documentation_cache": {}
}STEP 2: Kubernetes environment analysis
- ANALYZE cluster connectivity and context from Context section
- DETERMINE active Kubernetes features and configurations
- IDENTIFY documentation priorities based on detected environment
IF cluster connection available:
- FOCUS on operational guides, troubleshooting, and cluster management
- PRIORITIZE monitoring, networking, and security documentation
- INCLUDE deployment patterns and best practices for detected workloads
ELSE IF K8s manifests found:
- FOCUS on resource definitions, configuration patterns, and deployment strategies
- PRIORITIZE YAML reference documentation and validation guides
- INCLUDE development workflow and CI/CD integration patterns
ELSE:
- LOAD general Kubernetes foundation and getting-started guides
- EMPHASIZE core concepts, setup guides, and learning resources
- INCLUDE cluster setup and tool installation documentation
STEP 3: Strategic documentation loading
Think deeply about optimal Kubernetes learning and operational documentation strategies for this specific environment. Analyze the cluster configuration, detected workloads, and technology stack to prioritize the most relevant documentation areas.
TRY:
- EXECUTE systematic context loading from prioritized sources
- FOR complex environments with many detected features: Use parallel sub-agents to load different documentation areas simultaneously
- USE WebFetch tool for each documentation URL with targeted focus
- PROCESS and organize information by Kubernetes functional area
- SAVE loaded context to session state
**Core Documentation Sources:**
FOR EACH priority source:
1. **Kubernetes Core Documentation**
- URL: `https://kubernetes.io/docs/concepts/`
- FETCH: Core concepts, architecture, cluster components
- FOCUS: Pods, Services, Deployments, ConfigMaps, Secrets
- EXTRACT: Resource relationships and lifecycle management
2. **Kubernetes API Reference**
- URL: `https://kubernetes.io/docs/reference/kubernetes-api/`
- FETCH: Resource specifications, field definitions, API versioning
- FOCUS: Workload APIs, Service APIs, Config and Storage APIs
- EXTRACT: Schema validation and field requirements
3. **Kubectl Command Reference**
- URL: `https://kubernetes.io/docs/reference/kubectl/`
- FETCH: Command syntax, usage patterns, practical examples
- FOCUS: Resource management, debugging commands, advanced usage
- EXTRACT: Troubleshooting workflows and automation patterns
4. **Kubernetes Networking Documentation**
- URL: `https://kubernetes.io/docs/concepts/services-networking/`
- FETCH: Service types, Ingress, Network Policies, DNS
- FOCUS: Service discovery, load balancing, network security
- EXTRACT: Networking patterns and troubleshooting guides
5. **Security and RBAC Guide**
- URL: `https://kubernetes.io/docs/concepts/security/`
- FETCH: RBAC, Security Contexts, Pod Security Standards
- FOCUS: Authentication, authorization, security policies
- EXTRACT: Security best practices and compliance patterns
6. **Configuration Management**
- URL: `https://kubernetes.io/docs/concepts/configuration/`
- FETCH: ConfigMaps, Secrets, Resource Management
- FOCUS: Environment configuration, secret management
- EXTRACT: Configuration patterns and security practices
7. **Storage Documentation**
- URL: `https://kubernetes.io/docs/concepts/storage/`
- FETCH: Volumes, Persistent Volumes, Storage Classes
- FOCUS: Data persistence, backup strategies, storage providers
- EXTRACT: Storage architecture and management patterns
8. **Monitoring and Observability**
- URL: `https://kubernetes.io/docs/tasks/debug/`
- FETCH: Debugging techniques, monitoring setup, logging
- FOCUS: Troubleshooting workflows, metrics collection
- EXTRACT: Observability patterns and tool integration
CATCH (documentation_fetch_failed):
- LOG failed sources to session state
- CONTINUE with available documentation
- PROVIDE manual context loading instructions
- SAVE fallback documentation references
STEP 4: Environment-specific context optimization
CASE k8s_environment: WHEN "production_cluster":
- PRIORITIZE: Monitoring, security, troubleshooting, upgrades
- FOCUS: Production best practices, disaster recovery, performance tuning
- EXAMPLES: High availabilit