skandragon / grpc-cluster

An example of a Kubernetes GRPC client in Go, which discovers other instances in a stateful set.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

grpc-cluster

This is an example of a simple GRPC server which uses a Kubernetes headless service to discover and maintain a connection to all other running instances.

This is not a robust solution to the problem of maintaining shared state, but is an experiment in how to use a headless service to enumerate pods, and track them as they come and go.

This implementation makes sure to avoid connecting to itself, using an injected environment variable to provide the list of addresses.

It's not clear if IPv4 and IPv6 are both added to the headless service for the same pod, or if at most one address is added. For now, I think it's up to the code to handle this situation and de-dupelicate connections in some way.

About

An example of a Kubernetes GRPC client in Go, which discovers other instances in a stateful set.


Languages

Language:Go 77.1%Language:Makefile 14.3%Language:Dockerfile 8.6%