Join the namespaces of pod infra container

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2016-08-29 11:49:26 -07:00
parent 6852c44130
commit 3e1bb97053

View file

@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"github.com/Sirupsen/logrus"
pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
"github.com/mrunalp/ocid/oci"
"github.com/mrunalp/ocid/utils"
@ -153,6 +154,10 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR
s.addContainer(container)
if err := s.runtime.UpdateStatus(container); err != nil {
return nil, err
}
return &pb.CreatePodSandboxResponse{PodSandboxId: &name}, nil
}
@ -430,6 +435,21 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
sandboxConfig := req.GetSandboxConfig()
fmt.Printf("sandboxConfig: %v\n", sandboxConfig)
// Get the namespace paths for the pod sandbox container.
podContainerName := podSandboxId + "-infra"
podInfraContainer := s.state.containers[podContainerName]
podInfraState := s.runtime.ContainerStatus(podInfraContainer)
logrus.Infof("pod container state %v", podInfraState)
netNsPath := fmt.Sprintf("/proc/%d/ns/%s", podInfraState.Pid, "net")
specgen.AddOrReplaceLinuxNamespace("network", netNsPath)
for _, ns := range []string{"ipc", "uts"} {
nsPath := fmt.Sprintf("/proc/%d/ns/%s", podInfraState.Pid, ns)
specgen.AddOrReplaceLinuxNamespace(ns, nsPath)
}
if err := specgen.SaveToFile(filepath.Join(containerDir, "config.json")); err != nil {
return nil, err
}