server: do not use localhost for streaming service
The bug is silly if you have a master/node cluster where node is on a different machine than the master. The current behavior is to give our addresses like "0.0.0.0:10101". If you run "kubectl exec ..." from another host, that's not going to work since on a different host 0.0.0.0 resolves to localhost and kubectl exec fails with: error: unable to upgrade connection: 404 page not found This patch fixes the above by giving our correct addresses for reaching from outside. Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
36255b8663
commit
315c385371
1 changed files with 8 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -22,6 +23,7 @@ import (
|
||||||
"github.com/kubernetes-incubator/cri-o/server/seccomp"
|
"github.com/kubernetes-incubator/cri-o/server/seccomp"
|
||||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
|
knet "k8s.io/apimachinery/pkg/util/net"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/server/streaming"
|
"k8s.io/kubernetes/pkg/kubelet/server/streaming"
|
||||||
)
|
)
|
||||||
|
@ -606,9 +608,14 @@ func New(config *Config) (*Server, error) {
|
||||||
s.restore()
|
s.restore()
|
||||||
s.cleanupSandboxesOnShutdown()
|
s.cleanupSandboxesOnShutdown()
|
||||||
|
|
||||||
|
bindAddress, err := knet.ChooseBindAddress(net.IP{0, 0, 0, 0})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare streaming server
|
// Prepare streaming server
|
||||||
streamServerConfig := streaming.DefaultConfig
|
streamServerConfig := streaming.DefaultConfig
|
||||||
streamServerConfig.Addr = "0.0.0.0:10101"
|
streamServerConfig.Addr = bindAddress.String() + ":10101"
|
||||||
s.stream.runtimeServer = s
|
s.stream.runtimeServer = s
|
||||||
s.stream.streamServer, err = streaming.NewServer(streamServerConfig, s.stream)
|
s.stream.streamServer, err = streaming.NewServer(streamServerConfig, s.stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue