containerd架构
containerd架构基础
containerd基础数据结构及初始化
数据结构
初始化
containerd命令组件
config 用于生成containerd默认配置文件
publish 向containerd发布事件
oci-hooks 提供oci运行时钩子的基础组件
app.Action 主流程
containerd plugin
ctr plugins ls
Content Plugin io.containerd.content.v1
1.建立信号处理机制
2. 加载并解析配置文件
3. 初始化服务组件,注册无init函数的插件,依次调用各个Plugin的InitFn进行初始化
Content Plugin、Metadata Plugin、Snapshot Plugin和Proxy Plugin
4. 初始化grpc server, 将各个Plugin的service(若存在)注册到grpc server中
Metadata Plugin io.containerd.metadata.v1
Snapshot Plugin io.containerd.snapshotter.v1
config
type Config struct {
、 Root string `toml:"root"`
State string `toml:"state"`
GRPC GRPCConfig `toml:"grpc"`
Debug Debug `toml:"debug"`
Metrics MetricsConfig `toml:"metrics"`
DisabledPlugins []string `toml:"disabled_plugins"`
Plugins map[string]toml.Primitive `toml:"plugins"`
OOMScore int `toml:"oom_score"`
Cgroup CgroupConfig `toml:"cgroup"`
ProxyPlugins map[string]ProxyPlugin `toml:"proxy_plugins"`
md toml.MetaData
}
type GRPCConfig struct {
Address string `toml:"address"`
UID int `toml:"uid"`
GID int `toml:"gid"`
MaxRecvMsgSize int `toml:"max_recv_message_size"`
MaxSendMsgSize int `toml:"max_send_message_size"`
}
type Debug struct {
Address string `toml:"address"`
UID int `toml:"uid"`
GID int `toml:"gid"`
Level string `toml:"level"`
}
type MetricsConfig struct {
Address string `toml:"address"`
GRPCHistogram bool `toml:"grpc_histogram"`
}
content
bolt
btrfs
aufs
native
overlayfs
zfs
differ plugin io.containerd.differ.v1
walking
service plugin io.containerd.service.v1
containers-service
content-service
diff-service
images-service
leases-service
namespaces-service
snapshots-service
task-service
Internal Plugin io.containerd.internal.v1
restart
GRPC Plugin io.containerd.grpc.v1
containers
content
diff
healthcheck
images
namespaces
opts
snapshots
tasks
version
cri
Runtime Plugin
io.containerd.runtime.v1
linux
io.containerd.runtime.v2
tasks
containerd架构图
Proxy Plugin 用于自定义外部插件,比如说snapshot plugin等等
cri
oci open container initiative
cni
Runtime Service
Image Service
rpc Version(VersionRequest) returns (VersionResponse) {}
rpc RunPodSandbox(RunPodSandboxRequest) returns (RunPodSandboxResponse) {}
StopPodSandbox(StopPodSandboxRequest) returns (StopPodSandboxResponse) {}
rpc RemovePodSandbox(RemovePodSandboxRequest)
returns(RemovePodSandboxResponse) {}
rpc PodSandboxStatus(PodSandboxStatusRequest) returns
(PodSandboxStatusResponse) {}
rpc ListPodSandbox(ListPodSandboxRequest) returns (ListPodSandboxResponse) {}
rpc CreateContainer(CreateContainerRequest) returns (CreateContainerResponse) {}
rpc StartContainer(StartContainerRequest) returns (StartContainerResponse) {}
rpc StopContainer(StopContainerRequest) returns (StopContainerResponse) {}
rpc RemoveContainer(RemoveContainerRequest)
returns (RemoveContainerResponse) {}
rpc ListContainers(ListContainersRequest) returns (ListContainersResponse) {}
rpc ContainerStatus(ContainerStatusRequest) returns (ContainerStatusResponse) {}
rpc UpdateContainerResources(UpdateContainerResourcesRequest)
returns (UpdateContainerResourcesResponse) {}
rpc ExecSync(ExecSyncRequest) returns (ExecSyncResponse) {}
rpc Exec(ExecRequest) returns (ExecResponse) {}
rpc Attach(AttachRequest) returns (AttachResponse) {}
rpc PortForward(PortForwardRequest) returns (PortForwardResponse) {}
rpc ContainerStats(ContainerStatsRequest) returns (ContainerStatsResponse) {}
rpc ListContainerStats(ListContainerStatsRequest)
returns (ListContainerStatsResponse) {}
rpc UpdateRuntimeConfig(UpdateRuntimeConfigRequest)
returns (UpdateRuntimeConfigResponse) {}
rpc Status(StatusRequest) returns (StatusResponse) {}
rpc ListImages(ListImagesRequest) returns (ListImagesResponse) {}
rpc ImageStatus(ImageStatusRequest) returns (ImageStatusResponse) {}
rpc PullImage(PullImageRequest) returns (PullImageResponse) {}
rpc RemoveImage(RemoveImageRequest) returns (RemoveImageResponse) {}
rpc ImageFsInfo(ImageFsInfoRequest) returns (ImageFsInfoResponse) {}
AddNetworkList(net *NetworkConfigList, rt *RuntimeConf) (types.Result, error)
DelNetworkList(net *NetworkConfigList, rt *RuntimeConf) error
AddNetwork(net *NetworkConfig, rt *RuntimeConf) (types.Result, error)
DelNetwork(net *NetworkConfig, rt *RuntimeConf) error
runtime spec
image spec
文件系统
config 文件
manifest文件
index文件
公共模块plugin中register Registeration数组,plugin Register
函数将各个Plugin注册到该数组中,LoadPlugin将该数组中注册的
Plugin转换为map形式,便于应用
每个plugin的InitFn都会返回Interface{}类型的plugin
registratioon中的Init函数会将plugin赋值到Plugin的instance中
Created With
MindMaster