cmd/server: provide a flag to set ocid root dir
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
a16a4df967
commit
857aaa7816
3 changed files with 17 additions and 4 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/kubernetes-incubator/ocid/server"
|
"github.com/kubernetes-incubator/ocid/server"
|
||||||
|
@ -12,6 +13,10 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ocidRoot = "/var/lib/ocid"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "ocid"
|
app.Name = "ocid"
|
||||||
|
@ -19,14 +24,19 @@ func main() {
|
||||||
app.Version = "0.0.1"
|
app.Version = "0.0.1"
|
||||||
|
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "root",
|
||||||
|
Value: ocidRoot,
|
||||||
|
Usage: "ocid root dir",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "sandboxdir",
|
Name: "sandboxdir",
|
||||||
Value: "/var/lib/ocid/sandboxes",
|
Value: filepath.Join(ocidRoot, "sandboxes"),
|
||||||
Usage: "ocid pod sandbox dir",
|
Usage: "ocid pod sandbox dir",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "containerdir",
|
Name: "containerdir",
|
||||||
Value: "/var/lib/ocid/containers",
|
Value: filepath.Join(ocidRoot, "containers"),
|
||||||
Usage: "ocid container dir",
|
Usage: "ocid container dir",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
|
@ -94,7 +104,7 @@ func main() {
|
||||||
|
|
||||||
containerDir := c.String("containerdir")
|
containerDir := c.String("containerdir")
|
||||||
sandboxDir := c.String("sandboxdir")
|
sandboxDir := c.String("sandboxdir")
|
||||||
service, err := server.New(c.String("runtime"), sandboxDir, containerDir)
|
service, err := server.New(c.String("runtime"), c.String("root"), sandboxDir, containerDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ func (s *Server) CreatePodSandbox(ctx context.Context, req *pb.CreatePodSandboxR
|
||||||
// creates a spec Generator with the default spec.
|
// creates a spec Generator with the default spec.
|
||||||
g := generate.New()
|
g := generate.New()
|
||||||
|
|
||||||
|
podInfraRootfs := filepath.Join(s.root, "graph/vfs/pause")
|
||||||
// setup defaults for the pod sandbox
|
// setup defaults for the pod sandbox
|
||||||
g.SetRootPath(filepath.Join(podInfraRootfs, "rootfs"))
|
g.SetRootPath(filepath.Join(podInfraRootfs, "rootfs"))
|
||||||
g.SetRootReadonly(true)
|
g.SetRootReadonly(true)
|
||||||
|
|
|
@ -24,6 +24,7 @@ const (
|
||||||
|
|
||||||
// Server implements the RuntimeService and ImageService
|
// Server implements the RuntimeService and ImageService
|
||||||
type Server struct {
|
type Server struct {
|
||||||
|
root string
|
||||||
runtime *oci.Runtime
|
runtime *oci.Runtime
|
||||||
sandboxDir string
|
sandboxDir string
|
||||||
stateLock sync.Mutex
|
stateLock sync.Mutex
|
||||||
|
@ -102,7 +103,7 @@ func (s *Server) reservePodName(id, name string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Server with options provided
|
// New creates a new Server with options provided
|
||||||
func New(runtimePath, sandboxDir, containerDir string) (*Server, error) {
|
func New(runtimePath, root, sandboxDir, containerDir string) (*Server, error) {
|
||||||
// TODO: This will go away later when we have wrapper process or systemd acting as
|
// TODO: This will go away later when we have wrapper process or systemd acting as
|
||||||
// subreaper.
|
// subreaper.
|
||||||
if err := utils.SetSubreaper(1); err != nil {
|
if err := utils.SetSubreaper(1); err != nil {
|
||||||
|
@ -130,6 +131,7 @@ func New(runtimePath, sandboxDir, containerDir string) (*Server, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s := &Server{
|
s := &Server{
|
||||||
|
root: root,
|
||||||
runtime: r,
|
runtime: r,
|
||||||
netPlugin: netPlugin,
|
netPlugin: netPlugin,
|
||||||
sandboxDir: sandboxDir,
|
sandboxDir: sandboxDir,
|
||||||
|
|
Loading…
Reference in a new issue