Kubernetes operators and client-go development
Build Kubernetes operators and controllers using client-go and controller-runtime. Use when creating custom resources, watching cluster events, or implementing reconciliation logic.
/plugin marketplace add pluginagentmarketplace/custom-plugin-go/plugin install go-development-assistant@pluginagentmarketplace-goThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/controller-example.goassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyBuild Kubernetes operators and controllers with client-go.
Develop custom Kubernetes controllers, operators, and CRDs using client-go and controller-runtime.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| type | string | yes | - | Type: "operator", "controller", "crd" |
| framework | string | no | "controller-runtime" | Framework |
import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)
func NewClient() (*kubernetes.Clientset, error) {
config, err := rest.InClusterConfig()
if err != nil {
// Fallback to kubeconfig
kubeconfig := filepath.Join(os.Getenv("HOME"), ".kube", "config")
config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
return nil, err
}
}
return kubernetes.NewForConfig(config)
}
func WatchPods(ctx context.Context, client *kubernetes.Clientset, namespace string) error {
watcher, err := client.CoreV1().Pods(namespace).Watch(ctx, metav1.ListOptions{})
if err != nil {
return err
}
defer watcher.Stop()
for event := range watcher.ResultChan() {
pod := event.Object.(*corev1.Pod)
switch event.Type {
case watch.Added:
fmt.Printf("Pod added: %s\n", pod.Name)
case watch.Modified:
fmt.Printf("Pod modified: %s (phase: %s)\n", pod.Name, pod.Status.Phase)
case watch.Deleted:
fmt.Printf("Pod deleted: %s\n", pod.Name)
}
}
return nil
}
type MyReconciler struct {
client.Client
Scheme *runtime.Scheme
Log logr.Logger
}
func (r *MyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("resource", req.NamespacedName)
var myResource myv1.MyResource
if err := r.Get(ctx, req.NamespacedName, &myResource); err != nil {
if apierrors.IsNotFound(err) {
return ctrl.Result{}, nil
}
return ctrl.Result{}, err
}
// Reconciliation logic
if myResource.Status.Phase == "" {
myResource.Status.Phase = "Pending"
if err := r.Status().Update(ctx, &myResource); err != nil {
return ctrl.Result{}, err
}
}
return ctrl.Result{RequeueAfter: time.Minute}, nil
}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: myresources.example.com
spec:
group: example.com
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
replicas:
type: integer
status:
type: object
properties:
phase:
type: string
scope: Namespaced
names:
plural: myresources
singular: myresource
kind: MyResource
| Symptom | Cause | Fix |
|---|---|---|
| RBAC denied | Missing permissions | Check ServiceAccount |
| CRD not found | Not installed | kubectl apply CRD |
| Leader election fail | Lease conflict | Check replicas |
Skill("go-kubernetes")
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.