Files
coredns/plugin/traffic/grpc_lb.go
Miek Gieben fafb347966 More grpc LB tweaks
Signed-off-by: Miek Gieben <miek@miek.nl>
2020-03-30 16:10:07 +02:00

20 lines
626 B
Go

package traffic
import (
"fmt"
"github.com/miekg/dns"
)
// See https://github.com/grpc/grpc/blob/master/doc/service_config.md for the fields in this proto.
// We encode it as json and return it in a TXT field.
// TOOD(miek): balancer name should not be hardcoded
var lbTXT = `grpc_config=[{"serviceConfig":{"loadBalancingConfig":[{"eds_experimental":{"Cluster": "xds", "EDSServiceName":"%s", "BalancerName":"xds"}}]}}]`
func txt(z, cluster string) []dns.RR {
return []dns.RR{&dns.TXT{
Hdr: dns.RR_Header{Name: z, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 5},
Txt: []string{fmt.Sprintf(lbTXT, cluster)},
}}
}