[root@k8s-master1 kubernetes]#[root@k8s-master1 kubernetes]# dlv version
Delve Debugger
Version: 1.9.1
Build: $Id: d81b9fd12bfa603f3cf7a4bc842398bd61c42940 $
[root@k8s-master1 kubernetes]#[root@k8s-master1 kubernetes]# go version
go version go1.19.3 linux/amd64
[root@k8s-master1 kubernetes]#[root@k8s-master1 kubernetes]# kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.4", GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78", GitTreeState:"clean", BuildDate:"2022-11-09T13:36:36Z", GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.4", GitCommit:"872a965c6c6526caa949f0c6ac028ef7aff3fb78", GitTreeState:"clean", BuildDate:"2022-11-09T13:29:58Z", GoVersion:"go1.19.3", Compiler:"gc", Platform:"linux/amd64"}[root@k8s-master1 kubernetes]#[root@k8s-master1 kubernetes]#[root@k8s-master1 kubernetes]# kubectl get nodes -owide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-master1 Ready <none> 31h v1.25.4 192.168.11.71 <none> CentOS Linux 7(Core)3.10.0-1160.80.1.el7.x86_64 containerd://1.6.10
[root@k8s-master1 kubernetes]#[root@k8s-master1 kubernetes]#[root@k8s-master1 kubernetes]# kubectl get componentstatus
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME STATUS MESSAGE ERROR
etcd-0 Healthy {"health":"true","reason":""}
controller-manager Healthy ok
scheduler Healthy ok
[root@k8s-master1 kubernetes]#
// staging/src/k8s.io/cri-api/pkg/apis/services.go// RuntimeVersioner contains methods for runtime name, version and API version.type RuntimeVersioner interface{// Version returns the runtime name, runtime version and runtime API versionVersion(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.RemoveContainer(containerID string)error// ListContainers lists all containers by filters.ListContainers(filter *runtimeapi.ContainerFilter)([]*runtimeapi.Container,error)// ContainerStatus returns the status of the container.ContainerStatus(containerID string, verbose bool)(*runtimeapi.ContainerStatusResponse,error)// UpdateContainerResources updates ContainerConfig of the container synchronously.// If runtime fails to transactionally update the requested resources, an error is returned.UpdateContainerResources(containerID string, resources *runtimeapi.ContainerResources)error// ExecSync executes a command in the container, and returns the stdout output.// If command exits with a non-zero exit code, an error is returned.ExecSync(containerID string, cmd []string, timeout time.Duration)(stdout []byte, stderr []byte, err error)// Exec prepares a streaming endpoint to execute a command in the container, and returns the address.Exec(*runtimeapi.ExecRequest)(*runtimeapi.ExecResponse,error)// Attach prepares a streaming endpoint to attach to a running container, and returns the address.Attach(req *runtimeapi.AttachRequest)(*runtimeapi.AttachResponse,error)// ReopenContainerLog asks runtime to reopen the stdout/stderr log file// for the container. If it returns error, new container log file MUST NOT// be created.ReopenContainerLog(ContainerID string)error// CheckpointContainer checkpoints a containerCheckpointContainer(options *runtimeapi.CheckpointContainerRequest)error// GetContainerEvents gets container events from the CRI runtimeGetContainerEvents(containerEventsCh chan*runtimeapi.ContainerEventResponse)error}// PodSandboxManager contains methods for operating on PodSandboxes. The methods// are thread-safe.type PodSandboxManager interface{// RunPodSandbox creates and starts a pod-level sandbox. Runtimes should ensure// the sandbox is in ready state.RunPodSandbox(config *runtimeapi.PodSandboxConfig, runtimeHandler string)(string,error)// StopPodSandbox stops the sandbox. If there are any running containers in the// sandbox, they should be force terminated.StopPodSandbox(podSandboxID string)error// RemovePodSandbox removes the sandbox. If there are running containers in the// sandbox, they should be forcibly removed.RemovePodSandbox(podSandboxID string)error// PodSandboxStatus returns the Status of the PodSandbox.PodSandboxStatus(podSandboxID string, verbose bool)(*runtimeapi.PodSandboxStatusResponse,error)// ListPodSandbox returns a list of Sandbox.ListPodSandbox(filter *runtimeapi.PodSandboxFilter)([]*runtimeapi.PodSandbox,error)// PortForward prepares a streaming endpoint to forward ports from a PodSandbox, and returns the address.PortForward(*runtimeapi.PortForwardRequest)(*runtimeapi.PortForwardResponse,error)}// ContainerStatsManager contains methods for retrieving the container// statistics.type ContainerStatsManager interface{// ContainerStats returns stats of the container. If the container does not// exist, the call returns an error.ContainerStats(containerID string)(*runtimeapi.ContainerStats,error)// ListContainerStats returns stats of all running containers.ListContainerStats(filter *runtimeapi.ContainerStatsFilter)([]*runtimeapi.ContainerStats,error)// PodSandboxStats returns stats of the pod. If the pod does not// exist, the call returns an error.PodSandboxStats(podSandboxID string)(*runtimeapi.PodSandboxStats,error)// ListPodSandboxStats returns stats of all running pods.ListPodSandboxStats(filter *runtimeapi.PodSandboxStatsFilter)([]*runtimeapi.PodSandboxStats,error)}// RuntimeService interface should be implemented by a container runtime.// The methods should be thread-safe.type RuntimeService interface{
RuntimeVersioner
ContainerManager
PodSandboxManager
ContainerStatsManager
// UpdateRuntimeConfig updates runtime configuration if specifiedUpdateRuntimeConfig(runtimeConfig *runtimeapi.RuntimeConfig)error// Status returns the status of the runtime.Status(verbose bool)(*runtimeapi.StatusResponse,error)}// ImageManagerService interface should be implemented by a container image// manager.// The methods should be thread-safe.type ImageManagerService interface{// ListImages lists the existing images.ListImages(filter *runtimeapi.ImageFilter)([]*runtimeapi.Image,error)// ImageStatus returns the status of the image.ImageStatus(image *runtimeapi.ImageSpec, verbose bool)(*runtimeapi.ImageStatusResponse,error)// PullImage pulls an image with the authentication config.PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig)(string,error)// RemoveImage removes the image.RemoveImage(image *runtimeapi.ImageSpec)error// ImageFsInfo returns information of the filesystem that is used to store images.ImageFsInfo()([]*runtimeapi.FilesystemUsage,error)}
// ListContainerStats returns the list of ContainerStats given the filter.func(r *remoteRuntimeService)ListContainerStats(filter *runtimeapi.ContainerStatsFilter)([]*runtimeapi.ContainerStats,error){
klog.V(10).InfoS("[RemoteRuntimeService] ListContainerStats","filter", filter)// Do not set timeout, because writable layer stats collection takes time.// TODO(random-liu): Should we assume runtime should cache the result, and set timeout here?
ctx, cancel :=getContextWithCancel()defercancel()if r.useV1API(){return r.listContainerStatsV1(ctx, filter)}return r.listContainerStatsV1alpha2(ctx, filter)}func(r *remoteRuntimeService)listContainerStatsV1alpha2(ctx context.Context, filter *runtimeapi.ContainerStatsFilter)([]*runtimeapi.ContainerStats,error){
resp, err := r.runtimeClientV1alpha2.ListContainerStats(ctx,&runtimeapiV1alpha2.ListContainerStatsRequest{
Filter:v1alpha2ContainerStatsFilter(filter),})if err !=nil{
klog.ErrorS(err,"ListContainerStats with filter from runtime service failed","filter", filter)returnnil, err
}
klog.V(10).InfoS("[RemoteRuntimeService] ListContainerStats Response","filter", filter,"stats", resp.GetStats())returnfromV1alpha2ListContainerStatsResponse(resp).GetStats(),nil}func(r *remoteRuntimeService)listContainerStatsV1(ctx context.Context, filter *runtimeapi.ContainerStatsFilter)([]*runtimeapi.ContainerStats,error){
resp, err := r.runtimeClient.ListContainerStats(ctx,&runtimeapi.ListContainerStatsRequest{
Filter: filter,})if err !=nil{
klog.ErrorS(err,"ListContainerStats with filter from runtime service failed","filter", filter)returnnil, err
}
klog.V(10).InfoS("[RemoteRuntimeService] ListContainerStats Response","filter", filter,"stats", resp.GetStats())return resp.GetStats(),nil}
// ListPodSandboxStats returns the list of pod sandbox stats given the filterfunc(r *remoteRuntimeService)ListPodSandboxStats(filter *runtimeapi.PodSandboxStatsFilter)([]*runtimeapi.PodSandboxStats,error){
klog.V(10).InfoS("[RemoteRuntimeService] ListPodSandboxStats","filter", filter)// Set timeout, because runtimes are able to cache disk stats results
ctx, cancel :=getContextWithTimeout(r.timeout)defercancel()if r.useV1API(){return r.listPodSandboxStatsV1(ctx, filter)}return r.listPodSandboxStatsV1alpha2(ctx, filter)}func(r *remoteRuntimeService)listPodSandboxStatsV1alpha2(ctx context.Context, filter *runtimeapi.PodSandboxStatsFilter)([]*runtimeapi.PodSandboxStats,error){
resp, err := r.runtimeClientV1alpha2.ListPodSandboxStats(ctx,&runtimeapiV1alpha2.ListPodSandboxStatsRequest{
Filter:v1alpha2PodSandboxStatsFilter(filter),})if err !=nil{
klog.ErrorS(err,"ListPodSandboxStats with filter from runtime service failed","filter", filter)returnnil, err
}
klog.V(10).InfoS("[RemoteRuntimeService] ListPodSandboxStats Response","filter", filter,"stats", resp.GetStats())returnfromV1alpha2ListPodSandboxStatsResponse(resp).GetStats(),nil}func(r *remoteRuntimeService)listPodSandboxStatsV1(ctx context.Context, filter *runtimeapi.PodSandboxStatsFilter)([]*runtimeapi.PodSandboxStats,error){
resp, err := r.runtimeClient.ListPodSandboxStats(ctx,&runtimeapi.ListPodSandboxStatsRequest{
Filter: filter,})if err !=nil{
klog.ErrorS(err,"ListPodSandboxStats with filter from runtime service failed","filter", filter)returnnil, err
}
klog.V(10).InfoS("[RemoteRuntimeService] ListPodSandboxStats Response","filter", filter,"stats", resp.GetStats())return resp.GetStats(),nil}
// CheckpointContainer triggers a checkpoint of the given CheckpointContainerRequestfunc(r *remoteRuntimeService)CheckpointContainer(options *runtimeapi.CheckpointContainerRequest)error{
klog.V(10).InfoS("[RemoteRuntimeService] CheckpointContainer","options",
options,)if options ==nil{return errors.New("CheckpointContainer requires non-nil CheckpointRestoreOptions parameter")}if!r.useV1API(){return errors.New("CheckpointContainer is only supported in the CRI v1 runtime API")}if options.Timeout <0{return errors.New("CheckpointContainer requires the timeout value to be > 0")}
ctx, cancel :=func()(context.Context, context.CancelFunc){
defaultTimeout :=int64(r.timeout / time.Second)if options.Timeout > defaultTimeout {// The user requested a specific timeout, let's use that if it// is larger than the CRI default.returngetContextWithTimeout(time.Duration(options.Timeout)* time.Second)}// If the user requested a timeout less than the// CRI default, let's use the CRI default.
options.Timeout = defaultTimeout
returngetContextWithTimeout(r.timeout)}()defercancel()_, err := r.runtimeClient.CheckpointContainer(
ctx,
options,)if err !=nil{
klog.ErrorS(
err,"CheckpointContainer from runtime service failed","containerID",
options.ContainerId,)return err
}
klog.V(10).InfoS("[RemoteRuntimeService] CheckpointContainer Response","containerID",
options.ContainerId,)returnnil}
// ImageFsInfo returns information of the filesystem that is used to store images.func(r *remoteImageService)ImageFsInfo()([]*runtimeapi.FilesystemUsage,error){// Do not set timeout, because `ImageFsInfo` takes time.// TODO(random-liu): Should we assume runtime should cache the result, and set timeout here?
ctx, cancel :=getContextWithCancel()defercancel()if r.useV1API(){return r.imageFsInfoV1(ctx)}return r.imageFsInfoV1alpha2(ctx)}func(r *remoteImageService)imageFsInfoV1alpha2(ctx context.Context)([]*runtimeapi.FilesystemUsage,error){
resp, err := r.imageClientV1alpha2.ImageFsInfo(ctx,&runtimeapiV1alpha2.ImageFsInfoRequest{})if err !=nil{
klog.ErrorS(err,"ImageFsInfo from image service failed")returnnil, err
}returnfromV1alpha2ImageFsInfoResponse(resp).GetImageFilesystems(),nil}func(r *remoteImageService)imageFsInfoV1(ctx context.Context)([]*runtimeapi.FilesystemUsage,error){
resp, err := r.imageClient.ImageFsInfo(ctx,&runtimeapi.ImageFsInfoRequest{})if err !=nil{
klog.ErrorS(err,"ImageFsInfo from image service failed")returnnil, err
}return resp.GetImageFilesystems(),nil}