Join the namespaces of pod infra container
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
6852c44130
commit
3e1bb97053
1 changed files with 20 additions and 0 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
"github.com/mrunalp/ocid/oci"
|
"github.com/mrunalp/ocid/oci"
|
||||||
"github.com/mrunalp/ocid/utils"
|
"github.com/mrunalp/ocid/utils"
|
||||||
|
@ -153,6 +154,10 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR
|
||||||
|
|
||||||
s.addContainer(container)
|
s.addContainer(container)
|
||||||
|
|
||||||
|
if err := s.runtime.UpdateStatus(container); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &pb.CreatePodSandboxResponse{PodSandboxId: &name}, nil
|
return &pb.CreatePodSandboxResponse{PodSandboxId: &name}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,6 +435,21 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
|
||||||
sandboxConfig := req.GetSandboxConfig()
|
sandboxConfig := req.GetSandboxConfig()
|
||||||
fmt.Printf("sandboxConfig: %v\n", sandboxConfig)
|
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 {
|
if err := specgen.SaveToFile(filepath.Join(containerDir, "config.json")); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue