CRI 是一个插件接口,它使 kubelet 能够使用各种容器运行时,无需重新编译集群组件。
你需要在集群中的每个节点上都有一个可以正常工作的容器运行时, 这样 kubelet 能启动 Pod 及其容器。
容器运行时接口(CRI)是 kubelet 和容器运行时之间通信的主要协议。
Kubernetes 容器运行时接口(Container Runtime Interface;CRI)定义了主要 gRPC 协议, 用于集群组件 kubelet 和 容器运行时。
为什么要有这个接口
说到这个,就得说说已有容器化技术的实现,目前最为大家熟知的的容器技术应该是Docker,但是容器化技术并不只有Docker,还有一些其他的实现,比如Linux的LXC、各大云厂商的不开源的容器技术,K8S要想成为业界的主流,那么就必须对这些不容的容器进行适配,适配最简单的方式就是制定规则,然后各个容器厂商去实现这个规则,而后操作自家的容器即可
k8s中容器接口的代码
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cri
import (
"time"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
)
// RuntimeVersioner contains methods for runtime name, version and API version.
type RuntimeVersioner interface {
// Version returns the runtime name, runtime version and runtime API version
Version(apiVersion string) (*runtimeapi.VersionResponse, error)
}
// ContainerManager contains methods to manipulate containers managed by a
// container runtime. The methods are thread-safe.
type ContainerManager interface {
// CreateContainer creates a new container in specified PodSandbox.
CreateContainer(podSandboxID string, config *runtimeapi.ContainerConfig, sandboxConfig *runtimeapi.PodSandboxConfig) (string, error)
// StartContainer starts the container.
StartContainer(containerID string) error
// StopContainer stops a running container with a grace period (i.e., timeout).
StopContainer(containerID string, timeout int64) error
// RemoveContainer removes the container.
RemoveContai

Kubernetes的CRI(容器运行时接口)定义了kubelet与容器运行时之间的通信协议,允许使用不同容器技术而无需重构集群组件。CRI包括创建、启动、停止和管理容器及Pod Sandbox的接口,支持跨语言的protobuf协议,确保多容器环境的兼容性。此接口旨在促进Docker等不同容器化技术的集成,简化Kubernetes对各种容器运行时的支持。
的学习与理解&spm=1001.2101.3001.5002&articleId=127102402&d=1&t=3&u=f21b9d1455aa444cb6454233a063a080)
2144

被折叠的 条评论
为什么被折叠?



