Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

advanced-kubernetes

БесплатноЗапускает вложенные скриптыНе проверен

Custom Resource Definitions (CRDs) extend Kubernetes API with custom object types. Operators are controllers that manage these custom resources using…

williamzujkowskiот williamzujkowski★ 23 звезды на GitHub17 установок в других каталогах

Об этом скилле

Advanced Kubernetes: Operators & CRDs

Level 1: Quick Reference

Core Concepts at a Glance

Custom Resource Definitions (CRDs) extend Kubernetes API with custom object types. Operators are controllers that manage these custom resources using domain-specific logic.

CRD vs ConfigMap Comparison:

Aspect CRD ConfigMap
API Integration Full Kubernetes API support (CRUD, watch, RBAC) Simple key-value storage
Validation OpenAPI v3 schema validation, admission webhooks No built-in validation
Versioning Multiple versions with conversion webhooks Single version only
Use Case Complex application state, declarative APIs Configuration data, environment variables
Controller Support Reconciliation loops, status tracking Manual polling required
Example Database instances, ML workflows, backup policies App config files, feature flags

Operator Pattern Overview

┌─────────────────────────────────────────────────────────┐
│                    Kubernetes API Server                 │
│  (stores desired state in etcd)                         │
└────────────┬────────────────────────────┬───────────────┘
             │                            │
             │ Watch                      │ Update Status
             ↓                            ↑
    ┌────────────────┐         ┌─────────────────────┐
    │   Controller   │────────→│  External Resources │
    │  (Reconcile)   │  Manage │  (DBs, APIs, etc.)  │
    └────────────────┘         └─────────────────────┘
         ↑
         │ Compare
         │
    ┌────┴─────┐
    │ Desired  │
    │ vs Actual│
    └──────────┘

Reconciliation Loop:

  1. Watch - Controller watches for changes to custom resources
  2. Compare - Reconcile function compares desired vs actual state
  3. Act - Controller takes actions to align actual state with desired
  4. Update Status - Controller updates resource status with current state
  5. Requeue - Schedule next reconciliation (periodic or event-driven)

Controller Reconciliation Logic

// Simplified reconciliation pattern
func (r *MyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
    // 1. Fetch the custom resource
    obj := &myapi.MyResource{}
    if err := r.Get(ctx, req.NamespacedName, obj); err != nil {
        return ctrl.Result{}, client.IgnoreNotFound(err)
    }

    // 2. Handle deletion (finalizers)
    if !obj.DeletionTimestamp.IsZero() {
        return r.handleDeletion(ctx, obj)
    }

    // 3. Reconcile external state
    if err := r.reconcileExternal(ctx, obj); err != nil {
        return ctrl.Result{}, err
    }

    // 4. Update status
    obj.Status.Ready = true
    if err := r.Status().Update(ctx, obj); err != nil {
        return ctrl.Result{}, err
    }

    return ctrl.Result{}, nil // Success, no requeue
}

Essential Checklist

Prerequisites:

  • Kubernetes cluster (v1.25+) - local (kind, minikube) or remote
  • kubectl configured with admin access
  • Go 1.21+ installed
  • Docker/Podman for building operator images

Development Tools:

  • kubebuilder (v3.12+) - scaffolding and code generation
  • operator-sdk (optional) - alternative framework
  • controller-gen - generates CRDs, RBACs, webhooks
  • kustomize - manages Kubernetes manifests

Testing Tools:

  • envtest - runs API server locally for unit tests
  • kind - Kubernetes in Docker for integration tests
  • ginkgo - BDD testing framework (optional)

Key Files in Operator Project:

my-operator/
├── api/v1/           # CRD definitions (Go structs)
├── config/
│   ├── crd/          # Generated CRD YAML
│   ├── rbac/         # Generated RBAC YAML
│   ├── manager/      # Operator deployment
│   └── webhook/      # Webhook configurations
├── controllers/      # Reconciliation logic
├── main.go           # Entrypoint (manager setup)
└── Dockerfile        # Container image build

Quick Commands:

# Initialize operator project
kubebuilder init --domain example.com --repo github.com/myorg/my-operator

# Create CRD + controller
kubebuilder create api --group apps --version v1 --kind MyApp

# Generate manifests
make manifests

# Run locally (connects to current kubeconfig cluster)
make install run

# Run tests
make test

# Build and deploy
make docker-build docker-push deploy IMG=myregistry/my-operator:v1.0.0

Common Pitfalls:

  • ❌ Forgetting to update CRD when changing API structs → run make manifests
  • ❌ Infinite reconciliation loops → use ctrl.Result{RequeueAfter: time.Minute}
  • ❌ Not handling deletion properly → implement finalizers
  • ❌ Blocking operations in reconcile → use background workers for long tasks
  • ❌ Not setting owner references → orphaned resources on deletion

When to Use Operators:

  • ✅ Managing complex stateful applications (databases, message queues)
  • ✅ Automatin
Полный SKILL.md на GitHub

Установить advanced-kubernetes в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

REFERENCE.mdresources/operator-patterns.mdscripts/setup-operator-dev.shtemplates/crd-definition.yamltemplates/operator-scaffold.gotemplates/rbac.yamltemplates/webhook.go

FAQ

Что делает скилл advanced-kubernetes?

Custom Resource Definitions (CRDs) extend Kubernetes API with custom object types. Operators are controllers that manage these custom resources using domain-specific logic.

Как установить скилл advanced-kubernetes?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл advanced-kubernetes запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить advanced-kubernetes с