[英]What is the difference between dockerService and DockerServer in the kubelet source code
When I read the k8s source code, I found that both dockerService located in pkg/kubelet/dockershim/docker_service.go
and DockerServer located in pkg/kubelet/dockershim/remote/docker_server.go
seem to implement the interface of the CRI shim server
.当我阅读k8s源代码时,我发现位于pkg/ kubelet
pkg/kubelet/dockershim/docker_service.go
的dockerService和位于pkg/kubelet/dockershim/remote/docker_server.go
CRI shim server
的接口。
But I don't understand the difference between the two, why do I need to distinguish between the two?但是我不明白这两者的区别,为什么我需要区分这两者呢?
k8s version is tag 1.23.1
k8s 版本是标签 1.23.1
// DockerServer is the grpc server of dockershim.
type DockerServer struct {
// endpoint is the endpoint to serve on.
endpoint string
// service is the docker service which implements runtime and image services.
service DockerService
// server is the grpc server.
server *grpc.Server
}
...
// Start starts the dockershim grpc server.
func (s *DockerServer) Start() error {
glog.V(2).Infof("Start dockershim grpc server")
l, err := util.CreateListener(s.endpoint)
if err != nil {
return fmt.Errorf("failed to listen on %q: %v", s.endpoint, err)
}
// Create the grpc server and register runtime and image services.
s.server = grpc.NewServer()
runtimeapi.RegisterRuntimeServiceServer(s.server, s.service)
runtimeapi.RegisterImageServiceServer(s.server, s.service)
go func() {
// Use interrupt handler to make sure the server to be stopped properly.
h := interrupt.New(nil, s.Stop)
err := h.Run(func() error { return s.server.Serve(l) })
if err != nil {
glog.Errorf("Failed to serve connections: %v", err)
}
}()
return nil
}
// DockerService is the interface implement CRI remote service server.
type DockerService interface {
runtimeapi.RuntimeServiceServer
runtimeapi.ImageServiceServer
}
// **dockerService uses dockershim service to implement DockerService**.
BTW, are you sure you will use in the future? BTW,你确定你以后会用吗? From the latest (5 days ago) news: Kubernetes is Moving on From Dockershim: Commitments and Next Steps :
来自最新(5 天前)新闻: Kubernetes 从 Dockershim 继续前进:承诺和后续步骤:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.