etcdmain: support v3 tls

This commit is contained in:
Anthony Romano 2016-01-28 16:48:25 -08:00
parent 4380617e1a
commit 563850bcc1

View File

@ -33,6 +33,7 @@ import (
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus"
"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc"
"github.com/coreos/etcd/Godeps/_workspace/src/google.golang.org/grpc/credentials"
"github.com/coreos/etcd/discovery"
"github.com/coreos/etcd/etcdserver"
"github.com/coreos/etcd/etcdserver/api/v3rpc"
@ -330,7 +331,16 @@ func startEtcd(cfg *config) (<-chan struct{}, error) {
if cfg.v3demo {
// set up v3 demo rpc
grpcServer := grpc.NewServer()
creds, err := credentials.NewServerTLSFromFile(
cfg.clientTLSInfo.CertFile,
cfg.clientTLSInfo.KeyFile)
if err != nil {
s.Stop()
<-s.StopNotify()
return nil, err
}
grpcServer := grpc.NewServer(grpc.Creds(creds))
etcdserverpb.RegisterKVServer(grpcServer, v3rpc.NewKVServer(s))
etcdserverpb.RegisterWatchServer(grpcServer, v3rpc.NewWatchServer(s))
etcdserverpb.RegisterLeaseServer(grpcServer, v3rpc.NewLeaseServer(s))