use containerd client library
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
This commit is contained in:
parent
1a9d95244a
commit
20fc0227ae
@ -44,7 +44,7 @@ func main() {
|
||||
}
|
||||
|
||||
glog.V(2).Infof("Run cri-containerd grpc server on socket %q", o.SocketPath)
|
||||
service, err := server.NewCRIContainerdService(conn, o.RootDir, o.NetworkPluginBinDir, o.NetworkPluginConfDir)
|
||||
service, err := server.NewCRIContainerdService(conn, o.ContainerdEndpoint, o.RootDir, o.NetworkPluginBinDir, o.NetworkPluginConfDir)
|
||||
if err != nil {
|
||||
glog.Exitf("Failed to create CRI containerd service %+v: %v", o, err)
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package server
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/api/services/containers"
|
||||
contentapi "github.com/containerd/containerd/api/services/content"
|
||||
diffapi "github.com/containerd/containerd/api/services/diff"
|
||||
@ -99,11 +100,19 @@ type criContainerdService struct {
|
||||
netPlugin ocicni.CNIPlugin
|
||||
// agentFactory is the factory to create agent used in the cri containerd service.
|
||||
agentFactory agents.AgentFactory
|
||||
// client is an instance of the containerd client
|
||||
client *containerd.Client
|
||||
}
|
||||
|
||||
// NewCRIContainerdService returns a new instance of CRIContainerdService
|
||||
func NewCRIContainerdService(conn *grpc.ClientConn, rootDir, networkPluginBinDir, networkPluginConfDir string) (CRIContainerdService, error) {
|
||||
func NewCRIContainerdService(conn *grpc.ClientConn, containerdEndpoint, rootDir, networkPluginBinDir, networkPluginConfDir string) (CRIContainerdService, error) {
|
||||
// TODO(random-liu): [P2] Recover from runtime state and metadata store.
|
||||
|
||||
client, err := containerd.New(containerdEndpoint)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to initialize client: %v", err)
|
||||
}
|
||||
|
||||
c := &criContainerdService{
|
||||
os: osinterface.RealOS{},
|
||||
rootDir: rootDir,
|
||||
@ -126,6 +135,7 @@ func NewCRIContainerdService(conn *grpc.ClientConn, rootDir, networkPluginBinDir
|
||||
versionService: versionapi.NewVersionClient(conn),
|
||||
healthService: healthapi.NewHealthClient(conn),
|
||||
agentFactory: agents.NewAgentFactory(),
|
||||
client: client,
|
||||
}
|
||||
|
||||
netPlugin, err := ocicni.InitCNI(networkPluginBinDir, networkPluginConfDir)
|
||||
|
Loading…
Reference in New Issue
Block a user