diff --git a/cmd/crio/config.go b/cmd/crio/config.go index fdce55bc..e71969b5 100644 --- a/cmd/crio/config.go +++ b/cmd/crio/config.go @@ -35,6 +35,12 @@ storage_option = [ # listen is the path to the AF_LOCAL socket on which crio will listen. listen = "{{ .Listen }}" +# stream_address is the IP address on which the stream server will listen +stream_address = "{{ .StreamAddress }}" + +# stream_port is the port on which the stream server will listen +stream_port = "{{ .StreamPort }}" + # The "crio.runtime" table contains settings pertaining to the OCI # runtime used and options for how to set up and manage the OCI runtime. [crio.runtime] diff --git a/cmd/crio/main.go b/cmd/crio/main.go index 2d02c0ab..7def0e53 100644 --- a/cmd/crio/main.go +++ b/cmd/crio/main.go @@ -71,6 +71,12 @@ func mergeConfig(config *server.Config, ctx *cli.Context) error { if ctx.GlobalIsSet("listen") { config.Listen = ctx.GlobalString("listen") } + if ctx.GlobalIsSet("stream-address") { + config.StreamAddress = ctx.GlobalString("stream-address") + } + if ctx.GlobalIsSet("stream-port") { + config.StreamPort = ctx.GlobalString("stream-port") + } if ctx.GlobalIsSet("runtime") { config.Runtime = ctx.GlobalString("runtime") } @@ -145,6 +151,14 @@ func main() { Name: "listen", Usage: "path to crio socket", }, + cli.StringFlag{ + Name: "stream-address", + Usage: "bind address for streaming socket", + }, + cli.StringFlag{ + Name: "stream-port", + Usage: "bind port for streaming socket (default: \"10010\")", + }, cli.StringFlag{ Name: "log", Value: "", diff --git a/server/config.go b/server/config.go index aea4bf7b..99cac43e 100644 --- a/server/config.go +++ b/server/config.go @@ -65,6 +65,12 @@ type APIConfig struct { // This may support proto://addr formats later, but currently this is just // a path. Listen string `toml:"listen"` + + // StreamAddress is the IP address on which the stream server will listen. + StreamAddress string `toml:"stream_address"` + + // StreamPort is the port on which the stream server will listen. + StreamPort string `toml:"stream_port"` } // RuntimeConfig represents the "crio.runtime" TOML config table. @@ -207,7 +213,9 @@ func DefaultConfig() *Config { LogDir: "/var/log/crio/pods", }, APIConfig: APIConfig{ - Listen: "/var/run/crio.sock", + Listen: "/var/run/crio.sock", + StreamAddress: "", + StreamPort: "10010", }, RuntimeConfig: RuntimeConfig{ Runtime: "/usr/bin/runc", diff --git a/server/server.go b/server/server.go index 8c7f4b0e..82e96f4e 100644 --- a/server/server.go +++ b/server/server.go @@ -613,14 +613,22 @@ func New(config *Config) (*Server, error) { s.restore() s.cleanupSandboxesOnShutdown() - bindAddress, err := knet.ChooseBindAddress(net.IP{0, 0, 0, 0}) + bindAddress := net.ParseIP(config.StreamAddress) + if bindAddress == nil { + bindAddress, err = knet.ChooseBindAddress(net.IP{0, 0, 0, 0}) + if err != nil { + return nil, err + } + } + + _, err = net.LookupPort("tcp", config.StreamPort) if err != nil { return nil, err } // Prepare streaming server streamServerConfig := streaming.DefaultConfig - streamServerConfig.Addr = bindAddress.String() + ":10101" + streamServerConfig.Addr = net.JoinHostPort(bindAddress.String(), config.StreamPort) s.stream.runtimeServer = s s.stream.streamServer, err = streaming.NewServer(streamServerConfig, s.stream) if err != nil {