Skip to content
Back to skills

Go Kubernetes

ASecurity

Kubernetes operators and client-go development

  • 666 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added February 8, 2026
devopsgokubernetesapidevops

Works with

  • cli
  • api

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill go-kubernetes --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Go Kubernetes?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Go Kubernetes
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-go-kubernetes/badge)](https://www.skillsdirectory.com/skills/majiayu000-go-kubernetes)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: go-kubernetes
description: Kubernetes operators and client-go development
sasmp_version: "1.3.0"
bonded_agent: 08-go-devops
bond_type: PRIMARY_BOND
---

# Go Kubernetes Skill

Build Kubernetes operators and controllers with client-go.

## Overview

Develop custom Kubernetes controllers, operators, and CRDs using client-go and controller-runtime.

## Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| type | string | yes | - | Type: "operator", "controller", "crd" |
| framework | string | no | "controller-runtime" | Framework |

## Core Topics

### Client Setup
```go
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)
}
```

### Watch Resources
```go
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
}
```

### Controller-Runtime Reconciler
```go
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
}
```

### Custom Resource Definition
```yaml
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
```

## Troubleshooting

### Failure Modes
| Symptom | Cause | Fix |
|---------|-------|-----|
| RBAC denied | Missing permissions | Check ServiceAccount |
| CRD not found | Not installed | kubectl apply CRD |
| Leader election fail | Lease conflict | Check replicas |

## Usage

```
Skill("go-kubernetes")
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.