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)
|
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 {
|
if err != nil {
|
||||||
glog.Exitf("Failed to create CRI containerd service %+v: %v", o, err)
|
glog.Exitf("Failed to create CRI containerd service %+v: %v", o, err)
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/api/services/containers"
|
"github.com/containerd/containerd/api/services/containers"
|
||||||
contentapi "github.com/containerd/containerd/api/services/content"
|
contentapi "github.com/containerd/containerd/api/services/content"
|
||||||
diffapi "github.com/containerd/containerd/api/services/diff"
|
diffapi "github.com/containerd/containerd/api/services/diff"
|
||||||
@ -99,11 +100,19 @@ type criContainerdService struct {
|
|||||||
netPlugin ocicni.CNIPlugin
|
netPlugin ocicni.CNIPlugin
|
||||||
// agentFactory is the factory to create agent used in the cri containerd service.
|
// agentFactory is the factory to create agent used in the cri containerd service.
|
||||||
agentFactory agents.AgentFactory
|
agentFactory agents.AgentFactory
|
||||||
|
// client is an instance of the containerd client
|
||||||
|
client *containerd.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCRIContainerdService returns a new instance of CRIContainerdService
|
// 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.
|
// 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{
|
c := &criContainerdService{
|
||||||
os: osinterface.RealOS{},
|
os: osinterface.RealOS{},
|
||||||
rootDir: rootDir,
|
rootDir: rootDir,
|
||||||
@ -126,6 +135,7 @@ func NewCRIContainerdService(conn *grpc.ClientConn, rootDir, networkPluginBinDir
|
|||||||
versionService: versionapi.NewVersionClient(conn),
|
versionService: versionapi.NewVersionClient(conn),
|
||||||
healthService: healthapi.NewHealthClient(conn),
|
healthService: healthapi.NewHealthClient(conn),
|
||||||
agentFactory: agents.NewAgentFactory(),
|
agentFactory: agents.NewAgentFactory(),
|
||||||
|
client: client,
|
||||||
}
|
}
|
||||||
|
|
||||||
netPlugin, err := ocicni.InitCNI(networkPluginBinDir, networkPluginConfDir)
|
netPlugin, err := ocicni.InitCNI(networkPluginBinDir, networkPluginConfDir)
|
||||||
|
Loading…
Reference in New Issue
Block a user