Minimal Go Kubernetes client based on Generics
go get github.com/castai/k8s-client-go
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()
endpointsOperator := client.NewEndpointsOperator(kc)
endpoints, err := endpointsOperator.Get(ctx, "kube-system", "kubelet", client.GetOptions{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v", endpoints)
}
See more in Examples
- 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.