Automate the creation of the pod sandbox rootfs
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
e2f60be880
commit
0ba5dfc15a
1 changed files with 17 additions and 1 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/kubernetes-incubator/ocid/oci"
|
||||
"github.com/kubernetes-incubator/ocid/utils"
|
||||
pb "github.com/kubernetes/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
"github.com/opencontainers/ocitools/generate"
|
||||
"golang.org/x/net/context"
|
||||
|
@ -27,6 +28,10 @@ type metadata struct {
|
|||
Labels map[string]string `json:"labels"`
|
||||
}
|
||||
|
||||
const (
|
||||
podInfraRootfs = "/var/lib/ocid/graph/vfs/pause"
|
||||
)
|
||||
|
||||
func (s *sandbox) addContainer(c *oci.Container) {
|
||||
s.containers.Add(c.Name(), c)
|
||||
}
|
||||
|
@ -70,7 +75,7 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR
|
|||
g := generate.New()
|
||||
|
||||
// setup defaults for the pod sandbox
|
||||
g.SetRootPath("/var/lib/ocid/graph/vfs/pause")
|
||||
g.SetRootPath(filepath.Join(podInfraRootfs, "rootfs"))
|
||||
g.SetRootReadonly(true)
|
||||
g.SetProcessArgs([]string{"/pause"})
|
||||
|
||||
|
@ -146,6 +151,17 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if _, err = os.Stat(podInfraRootfs); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// TODO: Replace by rootfs creation API when it is ready
|
||||
if err := utils.CreateFakeRootfs(podInfraRootfs, "docker://kubernetes/pause"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
containerName := name + "-infra"
|
||||
container, err := oci.NewContainer(containerName, podSandboxDir, podSandboxDir, labels, name, false)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue