Skip to content

Minimal Go Kubernetes client based on Generics

License

Notifications You must be signed in to change notification settings

EmilyShepherd/k8s-client-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Minimal Go Kubernetes client based on Generics

Installing

go get github.com/EmilyShepherd/k8s-client-go

Usage

import (
    "context"
    "log"
    "fmt"
    client "github.com/EmilyShepherd/k8s-client-go"
)
func main() {
	kc, err := client.NewInCluster()
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Backgroud()

	endpointsAPI := client.NewObjectAPI[corev1.Endpoints](kc)

	endpoints, err := endpointsAPI.Get(ctx, "kube-system", "kubelet", metav1.GetOptions{})
	if err != nil {
		// Handle err
		return
	}
	fmt.Printf("%+v\n", endpoints)

	events, err := endpointsAPI.Watch(ctx, "kube-system", "kubelet", metav1.ListOptions{})
	if err != nil {
		// Handle err
		return
	}
	for e := range events.ResultChan() {
		fmt.Printf("%s: %+v\n", e.Type, e.Object)
	}
}

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.

About

Minimal Go Kubernetes client based on Generics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 97.4%
  • Shell 2.3%
  • Dockerfile 0.3%