Add option to register on TCP server

Signed-off-by: Aldo Culquicondor <acondor@google.com>
This commit is contained in:
Aldo Culquicondor 2019-06-24 11:13:19 -04:00
parent 5fdb4b8eef
commit 4b43303203
3 changed files with 23 additions and 3 deletions

View File

@ -15,6 +15,10 @@ version = 2
# The 'plugins."io.containerd.grpc.v1.cri"' table contains all of the server options. # The 'plugins."io.containerd.grpc.v1.cri"' table contains all of the server options.
[plugins."io.containerd.grpc.v1.cri"] [plugins."io.containerd.grpc.v1.cri"]
# disable_tcp_service disables serving CRI on the TCP server.
# Note that a TCP server is enabled for containerd if TCPAddress is set in section [grpc].
disable_tcp_service = true
# stream_server_address is the ip address streaming server is listening on. # stream_server_address is the ip address streaming server is listening on.
stream_server_address = "127.0.0.1" stream_server_address = "127.0.0.1"

View File

@ -138,6 +138,8 @@ type PluginConfig struct {
CniConfig `toml:"cni" json:"cni"` CniConfig `toml:"cni" json:"cni"`
// Registry contains config related to the registry // Registry contains config related to the registry
Registry Registry `toml:"registry" json:"registry"` Registry Registry `toml:"registry" json:"registry"`
// DisableTCPService disables serving CRI on the TCP server.
DisableTCPService bool `toml:"disable_tcp_service" json:"disableTCPService"`
// StreamServerAddress is the ip address streaming server is listening on. // StreamServerAddress is the ip address streaming server is listening on.
StreamServerAddress string `toml:"stream_server_address" json:"streamServerAddress"` StreamServerAddress string `toml:"stream_server_address" json:"streamServerAddress"`
// StreamServerPort is the port streaming server is listening on. // StreamServerPort is the port streaming server is listening on.
@ -219,6 +221,7 @@ func DefaultConfig() PluginConfig {
}, },
}, },
}, },
DisableTCPService: true,
StreamServerAddress: "127.0.0.1", StreamServerAddress: "127.0.0.1",
StreamServerPort: "0", StreamServerPort: "0",
StreamIdleTimeout: streaming.DefaultConfig.StreamIdleTimeout.String(), // 4 hour StreamIdleTimeout: streaming.DefaultConfig.StreamIdleTimeout.String(), // 4 hour

View File

@ -171,9 +171,15 @@ func NewCRIService(config criconfig.Config, client *containerd.Client) (CRIServi
// Register registers all required services onto a specific grpc server. // Register registers all required services onto a specific grpc server.
// This is used by containerd cri plugin. // This is used by containerd cri plugin.
func (c *criService) Register(s *grpc.Server) error { func (c *criService) Register(s *grpc.Server) error {
instrumented := newInstrumentedService(c) return c.register(s)
runtime.RegisterRuntimeServiceServer(s, instrumented) }
runtime.RegisterImageServiceServer(s, instrumented)
// RegisterTCP register all required services onto a GRPC server on TCP.
// This is used by containerd CRI plugin.
func (c *criService) RegisterTCP(s *grpc.Server) error {
if !c.config.DisableTCPService {
return c.register(s)
}
return nil return nil
} }
@ -267,6 +273,13 @@ func (c *criService) Close() error {
return nil return nil
} }
func (c *criService) register(s *grpc.Server) error {
instrumented := newInstrumentedService(c)
runtime.RegisterRuntimeServiceServer(s, instrumented)
runtime.RegisterImageServiceServer(s, instrumented)
return nil
}
// imageFSPath returns containerd image filesystem path. // imageFSPath returns containerd image filesystem path.
// Note that if containerd changes directory layout, we also needs to change this. // Note that if containerd changes directory layout, we also needs to change this.
func imageFSPath(rootDir, snapshotter string) string { func imageFSPath(rootDir, snapshotter string) string {