Merge pull request #33810 from feiskyer/portforward

Automatic merge from submit-queue

Fake docker portfoward for in-process docker CRI integration

This is necessary to pass e2e tests for in-process docker CRI integration.

This is part of #31459.

cc/ @Random-Liu @kubernetes/sig-node
pull/6/head
Kubernetes Submit Queue 2016-09-30 00:52:34 -07:00 committed by GitHub
commit e05d568b40
3 changed files with 15 additions and 2 deletions

View File

@ -40,7 +40,7 @@ func (ds *dockerService) GetContainerLogs(pod *api.Pod, containerID kubecontaine
}
func (ds *dockerService) PortForward(pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error {
return fmt.Errorf("not implemented")
return dockertools.PortForward(ds.client, pod, port, stream)
}
func (ds *dockerService) ExecInContainer(containerID kubecontainer.ContainerID, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan term.Size) error {

View File

@ -1273,11 +1273,16 @@ func noPodInfraContainerError(podName, podNamespace string) error {
// - should we support nsenter + socat on the host? (current impl)
// - should we support nsenter + socat in a container, running with elevated privs and --pid=host?
func (dm *DockerManager) PortForward(pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error {
return PortForward(dm.client, pod, port, stream)
}
// Temporarily export this function to share with dockershim.
func PortForward(client DockerInterface, pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error {
podInfraContainer := pod.FindContainerByName(PodInfraContainerName)
if podInfraContainer == nil {
return noPodInfraContainerError(pod.Name, pod.Namespace)
}
container, err := dm.client.InspectContainer(podInfraContainer.ID.ID)
container, err := client.InspectContainer(podInfraContainer.ID.ID)
if err != nil {
return err
}

View File

@ -32,6 +32,7 @@ import (
internalApi "k8s.io/kubernetes/pkg/kubelet/api"
runtimeApi "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/dockershim"
"k8s.io/kubernetes/pkg/kubelet/events"
"k8s.io/kubernetes/pkg/kubelet/images"
"k8s.io/kubernetes/pkg/kubelet/lifecycle"
@ -851,5 +852,12 @@ func (m *kubeGenericRuntimeManager) GetPodContainerID(pod *kubecontainer.Pod) (k
// Forward the specified port from the specified pod to the stream.
func (m *kubeGenericRuntimeManager) PortForward(pod *kubecontainer.Pod, port uint16, stream io.ReadWriteCloser) error {
// Use docker portforward directly for in-process docker integration
// now to unblock other tests.
// TODO: remove this hack after portforward is defined in CRI.
if ds, ok := m.runtimeService.(dockershim.DockerLegacyService); ok {
return ds.PortForward(pod, port, stream)
}
return fmt.Errorf("not implemented")
}