groupcache icon indicating copy to clipboard operation
groupcache copied to clipboard

Peer pods autodiscovery within kubernetes cluster

Open udhos opened this issue 3 years ago • 1 comments

Hi,

I am experimenting with a simple standalone package to automatically keep pod peers up-to-date within a kubernetes cluster:

https://github.com/udhos/kubegroup

Recipe currently looks like this:

groupcachePort := ":5000"

// 1. get my groupcache URL
myURL, errURL = kubegroup.FindMyURL(groupcachePort)

// 2. spawn groupcache peering server
pool := groupcache.NewHTTPPool(myURL)
server := &http.Server{Addr: groupcachePort, Handler: pool}
go func() {
    log.Printf("groupcache server: listening on %s", groupcachePort)
    err := server.ListenAndServe()
    log.Printf("groupcache server: exited: %v", err)
}()

// 3. spawn peering autodiscovery
go kubegroup.UpdatePeers(pool, groupcachePort)

// 4. create groupcache groups, etc: groupOne := groupcache.NewGroup()

Does it look reasonable!?

udhos avatar Sep 01 '22 03:09 udhos

It does look reasonable! We did something similar with https://github.com/mailgun/gubernator/blob/master/kubernetes.go

thrawn01 avatar Sep 12 '22 16:09 thrawn01