kubernetes-internals
Use when the user asks about Kubernetes internals, etcd Raft and compaction, resourceVersion, the watch cache, informers and list-watch, the admission chain…
от j4flmao★ 47 звёзд на GitHub
Установить kubernetes-internals в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Kubernetes Control Plane Internals
Purpose
Kubernetes is a set of independent control loops coordinating through one strongly consistent API. Knowing how writes are persisted, how watches are served, and how the kubelet realizes pods explains conflicts (409), "too old resource version" (410), slow API servers, and pods stuck in ContainerCreating.
Agent Protocol
Trigger
"kubernetes internals", "etcd raft", "resourceVersion", "watch cache", "list-watch", "admission chain", "kubelet pod lifecycle", "CRI CNI CSI", "apiserver request flow", "optimistic concurrency", "etcd defrag".
Input Context
- Cluster size (nodes, pods, objects), managed vs self-managed control plane.
- Symptom: latency, errors (409/410/429), etcd alarms, stuck pods.
Output Artifact
Explanation + diagnostic commands + tuning. No file unless requested.
Response Format
Layer: {etcd|apiserver|controller|scheduler|kubelet|CRI|CNI|CSI}
Mechanism: {...}
Evidence: {metric / log / command}
Action: {fix or tuning}
Completion Criteria
- Symptom attributed to a specific layer with evidence.
- Tuning suggestions are safe for the managed/self-managed context.
1. etcd: Raft + MVCC
- Raft: one leader; writes go to the leader, which appends to its log and replicates
AppendEntriesto followers; an entry commits when a majority persists it. 3 members tolerate 1 failure, 5 tolerate 2. More members = slower writes. - MVCC: every write creates a new revision of the keyspace; old revisions are retained until compaction (the apiserver compacts every 5 minutes by default via
--etcd-compaction-interval). Compaction frees logical space; defragmentation returns disk space to the filesystem (run per member, one at a time — it blocks that member). - Quota: default backend quota 2 GiB (
--quota-backend-bytes, commonly raised to 8 GiB). Exceeding it raises aNOSPACEalarm and etcd becomes read-only until compaction + defrag +etcdctl alarm disarm. - Disk latency dominates etcd performance: watch
etcd_disk_wal_fsync_duration_seconds(p99 should stay well under ~10 ms) andetcd_server_leader_changes_seen_total.
etcdctl endpoint status --write-out=table --cluster
etcdctl alarm list
etcdctl defrag --endpoints=https://10.0.0.11:2379 # one member at a time
2. kube-apiserver Request Pipeline
TLS → authentication → audit → impersonation → API priority & fairness → authorization (RBAC/Node/Webhook) → mutating admission (webhooks, MutatingAdmissionPolicy) → schema validation → validating admission (ValidatingAdmissionPolicy, webhooks) → etcd write
- resourceVersion is derived from the etcd revision. Updates send the object's
resourceVersion; if it changed meanwhile, the write fails with 409 Conflict (optimistic concurrency). Clients re-read and retry. - Watch cache: the apiserver keeps a cache of recent events per resource type and serves most LIST/WATCH requests from memory. A watch from a
resourceVersionolder than the cache window returns 410 Gone ("too old resource version") → clients relist. - API Priority and Fairness (
FlowSchema,PriorityLevelConfiguration) queues/limits requests per flow; rejected requests get 429. Misbehaving controllers doing full LISTs are a common cause of apiserver overload. - Large LISTs: clients should paginate (
limit/continue) or use informers; streaming lists (WatchList) reduce memory spikes in newer versions.
3. Controllers and the Informer Pattern
Controllers LIST once, then WATCH; a shared informer keeps a local cache and an indexer, event handlers enqueue object keys into a rate-limited work queue, and workers reconcile from cache state. Leader election uses Lease objects in coordination.k8s.io.
func (c *Controller) reconcile(ctx context.Context, key string) error {
ns, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
return err
}
obj, err := c.lister.Deployments(ns).Get(name) // from informer cache
if apierrors.IsNotFound(err) {
return nil // deleted; owned objects are garbage collected
}
if err != nil {
return err
}
desired := desiredReplicaSet(obj)
current, err := c.rsLister.ReplicaSets(ns).Get(desired.Name)
if apierrors.IsNotFound(err) {
_, err = c.client.AppsV1().ReplicaSets(ns).Create(ctx, desired, metav1.CreateOptions{})
return err
}
if err != nil {
return err
}
if !equality.Semantic.DeepEqual(current.Spec, desired.Spec) {
updated := current.DeepCopy() // never mutate cache objects
updated.Spec = desired.Spec
_, err = c.client.AppsV1().ReplicaSets(ns).Update(ctx, updated, metav1.UpdateOptions{})
return err // 409 → requeued with backoff
}
return nil
}
4. Scheduler
Watches pods with empty spec.nodeName; runs filter plugins (resources, taints, affinity, topology spread, volume binding) then score plugins; writes a Binding. Unschedulable pods go to a backoff queue; kubectl describe pod shows the filter reasons ("0/1
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл kubernetes-internals?
Use when the user asks about Kubernetes internals, etcd Raft and compaction, resourceVersion, the watch cache, informers and list-watch, the admission chain, kubelet pod lifecycle, CRI/CNI/CSI, or why a pod is OOMKilled at the cgroup level. Explains the control plane for debugging. Not for an overview (use kubernetes-architecture) or writing operators (use devops-kubernetes-operators).
Как установить скилл kubernetes-internals?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл kubernetes-internals запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…