k8s-client-go

Minimal Go Kubernetes client based on Generics

Usage

import (
    "context"
    "log"
    "fmt"
    client "github.com/castai/k8s-client-go"
)

func main() {
    kc, err := client.NewInCluster()
    if err != nil {
        log.Fatal(err)
    }
    ctx := context.Backgroud()
    endpoints, err := client.Get[*client.Endpoints](kc, ctx, "/api/v1/namespaces/kube-system/endpoints/kubelet", client.GetOptions{})
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%+v", endpoints)
}

See more in Examples

Use cases

  • Embedding in Go applications for minimal binary size overhead.
  • Service discovery by listing and watching endpoints. See kuberesolver as example for gRPC client side load balancing.

GitHub

View Github