Merge pull request #382 from miaoyq/return-config
"Status" function return cri-containerd config in json format
This commit is contained in:
commit
9f2de2cd02
@ -38,64 +38,64 @@ const (
|
|||||||
// ContainerdConfig contains config related to containerd
|
// ContainerdConfig contains config related to containerd
|
||||||
type ContainerdConfig struct {
|
type ContainerdConfig struct {
|
||||||
// RootDir is the root directory path for containerd.
|
// RootDir is the root directory path for containerd.
|
||||||
RootDir string `toml:"root_dir"`
|
RootDir string `toml:"root_dir" json:"rootDir,omitempty"`
|
||||||
// Snapshotter is the snapshotter used by containerd.
|
// Snapshotter is the snapshotter used by containerd.
|
||||||
Snapshotter string `toml:"snapshotter"`
|
Snapshotter string `toml:"snapshotter" json:"snapshotter,omitempty"`
|
||||||
// Endpoint is the containerd endpoint path.
|
// Endpoint is the containerd endpoint path.
|
||||||
Endpoint string `toml:"endpoint"`
|
Endpoint string `toml:"endpoint" json:"endpoint,omitempty"`
|
||||||
// Runtime is the runtime to use in containerd. We may support
|
// Runtime is the runtime to use in containerd. We may support
|
||||||
// other runtimes in the future.
|
// other runtimes in the future.
|
||||||
Runtime string `toml:"runtime"`
|
Runtime string `toml:"runtime" json:"runtime,omitempty"`
|
||||||
// RuntimeEngine is the name of the runtime engine used by containerd.
|
// RuntimeEngine is the name of the runtime engine used by containerd.
|
||||||
// Containerd default should be "runc"
|
// Containerd default should be "runc"
|
||||||
// We may support other runtime engines in the future.
|
// We may support other runtime engines in the future.
|
||||||
RuntimeEngine string `toml:"runtime_engine"`
|
RuntimeEngine string `toml:"runtime_engine" json:"runtimeEngine,omitempty"`
|
||||||
// RuntimeRoot is the directory used by containerd for runtime state.
|
// RuntimeRoot is the directory used by containerd for runtime state.
|
||||||
// Containerd default should be "/run/containerd/runc"
|
// Containerd default should be "/run/containerd/runc"
|
||||||
RuntimeRoot string `toml:"runtime_root"`
|
RuntimeRoot string `toml:"runtime_root" json:"runtimeRoot,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CniConfig contains config related to cni
|
// CniConfig contains config related to cni
|
||||||
type CniConfig struct {
|
type CniConfig struct {
|
||||||
// NetworkPluginBinDir is the directory in which the binaries for the plugin is kept.
|
// NetworkPluginBinDir is the directory in which the binaries for the plugin is kept.
|
||||||
NetworkPluginBinDir string `toml:"bin_dir"`
|
NetworkPluginBinDir string `toml:"bin_dir" json:"networkPluginBinDir,omitempty"`
|
||||||
// NetworkPluginConfDir is the directory in which the admin places a CNI conf.
|
// NetworkPluginConfDir is the directory in which the admin places a CNI conf.
|
||||||
NetworkPluginConfDir string `toml:"conf_dir"`
|
NetworkPluginConfDir string `toml:"conf_dir" json:"networkPluginConfDir,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config contains cri-containerd toml config
|
// Config contains cri-containerd toml config
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// ContainerdConfig contains config related to containerd
|
// ContainerdConfig contains config related to containerd
|
||||||
ContainerdConfig `toml:"containerd"`
|
ContainerdConfig `toml:"containerd" json:"containerd,omitempty"`
|
||||||
// CniConfig contains config related to cni
|
// CniConfig contains config related to cni
|
||||||
CniConfig `toml:"cni"`
|
CniConfig `toml:"cni" json:"cniConfig,omitempty"`
|
||||||
// SocketPath is the path to the socket which cri-containerd serves on.
|
// SocketPath is the path to the socket which cri-containerd serves on.
|
||||||
SocketPath string `toml:"socket_path"`
|
SocketPath string `toml:"socket_path" json:"socketPath,omitempty"`
|
||||||
// RootDir is the root directory path for managing cri-containerd files
|
// RootDir is the root directory path for managing cri-containerd files
|
||||||
// (metadata checkpoint etc.)
|
// (metadata checkpoint etc.)
|
||||||
RootDir string `toml:"root_dir"`
|
RootDir string `toml:"root_dir" json:"rootDir,omitempty"`
|
||||||
// StreamServerAddress is the ip address streaming server is listening on.
|
// StreamServerAddress is the ip address streaming server is listening on.
|
||||||
StreamServerAddress string `toml:"stream_server_address"`
|
StreamServerAddress string `toml:"stream_server_address" json:"streamServerAddress,omitempty"`
|
||||||
// StreamServerPort is the port streaming server is listening on.
|
// StreamServerPort is the port streaming server is listening on.
|
||||||
StreamServerPort string `toml:"stream_server_port"`
|
StreamServerPort string `toml:"stream_server_port" json:"streamServerPort,omitempty"`
|
||||||
// CgroupPath is the path for the cgroup that cri-containerd is placed in.
|
// CgroupPath is the path for the cgroup that cri-containerd is placed in.
|
||||||
CgroupPath string `toml:"cgroup_path"`
|
CgroupPath string `toml:"cgroup_path" json:"cgroupPath,omitempty"`
|
||||||
// EnableSelinux indicates to enable the selinux support.
|
// EnableSelinux indicates to enable the selinux support.
|
||||||
EnableSelinux bool `toml:"enable_selinux"`
|
EnableSelinux bool `toml:"enable_selinux" json:"enableSelinux,omitempty"`
|
||||||
// SandboxImage is the image used by sandbox container.
|
// SandboxImage is the image used by sandbox container.
|
||||||
SandboxImage string `toml:"sandbox_image"`
|
SandboxImage string `toml:"sandbox_image" json:"sandboxImage,omitempty"`
|
||||||
// StatsCollectPeriod is the period (in seconds) of snapshots stats collection.
|
// StatsCollectPeriod is the period (in seconds) of snapshots stats collection.
|
||||||
StatsCollectPeriod int `toml:"stats_collect_period"`
|
StatsCollectPeriod int `toml:"stats_collect_period" json:"statsCollectPeriod,omitempty"`
|
||||||
// SystemdCgroup enables systemd cgroup support.
|
// SystemdCgroup enables systemd cgroup support.
|
||||||
SystemdCgroup bool `toml:"systemd_cgroup"`
|
SystemdCgroup bool `toml:"systemd_cgroup" json:"systemdCgroup,omitempty"`
|
||||||
// OOMScore adjust the cri-containerd's oom score
|
// OOMScore adjust the cri-containerd's oom score
|
||||||
OOMScore int `toml:"oom_score"`
|
OOMScore int `toml:"oom_score" json:"oomScore,omitempty"`
|
||||||
// EnableProfiling is used for enable profiling via host:port/debug/pprof/
|
// EnableProfiling is used for enable profiling via host:port/debug/pprof/
|
||||||
EnableProfiling bool `toml:"profiling"`
|
EnableProfiling bool `toml:"profiling" json:"enableProfiling,omitempty"`
|
||||||
// ProfilingPort is the port for profiling via host:port/debug/pprof/
|
// ProfilingPort is the port for profiling via host:port/debug/pprof/
|
||||||
ProfilingPort string `toml:"profiling_port"`
|
ProfilingPort string `toml:"profiling_port" json:"profilingPort,omitempty"`
|
||||||
// ProfilingAddress is address for profiling via host:port/debug/pprof/
|
// ProfilingAddress is address for profiling via host:port/debug/pprof/
|
||||||
ProfilingAddress string `toml:"profiling_addr"`
|
ProfilingAddress string `toml:"profiling_addr" json:"profilingAddress,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CRIContainerdOptions contains cri-containerd command line and toml options.
|
// CRIContainerdOptions contains cri-containerd command line and toml options.
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
@ -55,10 +56,20 @@ func (c *criContainerdService) Status(ctx context.Context, r *runtime.StatusRequ
|
|||||||
networkCondition.Reason = networkNotReadyReason
|
networkCondition.Reason = networkNotReadyReason
|
||||||
networkCondition.Message = fmt.Sprintf("Network plugin returns error: %v", err)
|
networkCondition.Message = fmt.Sprintf("Network plugin returns error: %v", err)
|
||||||
}
|
}
|
||||||
return &runtime.StatusResponse{
|
|
||||||
|
resp := &runtime.StatusResponse{
|
||||||
Status: &runtime.RuntimeStatus{Conditions: []*runtime.RuntimeCondition{
|
Status: &runtime.RuntimeStatus{Conditions: []*runtime.RuntimeCondition{
|
||||||
runtimeCondition,
|
runtimeCondition,
|
||||||
networkCondition,
|
networkCondition,
|
||||||
}},
|
}},
|
||||||
}, nil
|
}
|
||||||
|
if r.Verbose {
|
||||||
|
configByt, err := json.Marshal(c.config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resp.Info = make(map[string]string)
|
||||||
|
resp.Info["config"] = string(configByt)
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
@ -68,5 +68,5 @@ k8s.io/apimachinery 4fd33e5925599d66528ef4f1a5c80f4aa2e27c98
|
|||||||
k8s.io/apiserver c1e53d745d0fe45bf7d5d44697e6eface25fceca
|
k8s.io/apiserver c1e53d745d0fe45bf7d5d44697e6eface25fceca
|
||||||
k8s.io/client-go 82aa063804cf055e16e8911250f888bc216e8b61
|
k8s.io/client-go 82aa063804cf055e16e8911250f888bc216e8b61
|
||||||
k8s.io/kube-openapi abfc5fbe1cf87ee697db107fdfd24c32fe4397a8
|
k8s.io/kube-openapi abfc5fbe1cf87ee697db107fdfd24c32fe4397a8
|
||||||
k8s.io/kubernetes d9bc7f0896091ba9879743fe4c9b27f352fe8289
|
k8s.io/kubernetes b958430ec2654bac10f74abbeab402c71cf5fa3b
|
||||||
k8s.io/utils 4fe312863be2155a7b68acd2aff1c9221b24e68c
|
k8s.io/utils 4fe312863be2155a7b68acd2aff1c9221b24e68c
|
||||||
|
1374
vendor/k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime/api.pb.go
generated
vendored
1374
vendor/k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime/api.pb.go
generated
vendored
File diff suppressed because it is too large
Load Diff
31
vendor/k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime/api.proto
generated
vendored
31
vendor/k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime/api.proto
generated
vendored
@ -331,6 +331,8 @@ message RemovePodSandboxResponse {}
|
|||||||
message PodSandboxStatusRequest {
|
message PodSandboxStatusRequest {
|
||||||
// ID of the PodSandbox for which to retrieve status.
|
// ID of the PodSandbox for which to retrieve status.
|
||||||
string pod_sandbox_id = 1;
|
string pod_sandbox_id = 1;
|
||||||
|
// Verbose indicates whether to return extra information about the pod sandbox.
|
||||||
|
bool verbose = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodSandboxNetworkStatus is the status of the network for a PodSandbox.
|
// PodSandboxNetworkStatus is the status of the network for a PodSandbox.
|
||||||
@ -382,6 +384,11 @@ message PodSandboxStatus {
|
|||||||
message PodSandboxStatusResponse {
|
message PodSandboxStatusResponse {
|
||||||
// Status of the PodSandbox.
|
// Status of the PodSandbox.
|
||||||
PodSandboxStatus status = 1;
|
PodSandboxStatus status = 1;
|
||||||
|
// Info is extra information of the PodSandbox. The key could be abitrary string, and
|
||||||
|
// value should be in json format. The information could include anything useful for
|
||||||
|
// debug, e.g. network namespace for linux container based container runtime.
|
||||||
|
// It should only be returned non-empty when Verbose is true.
|
||||||
|
map<string, string> info = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// PodSandboxStateValue is the wrapper of PodSandboxState.
|
// PodSandboxStateValue is the wrapper of PodSandboxState.
|
||||||
@ -747,6 +754,8 @@ message ListContainersResponse {
|
|||||||
message ContainerStatusRequest {
|
message ContainerStatusRequest {
|
||||||
// ID of the container for which to retrieve status.
|
// ID of the container for which to retrieve status.
|
||||||
string container_id = 1;
|
string container_id = 1;
|
||||||
|
// Verbose indicates whether to return extra information about the container.
|
||||||
|
bool verbose = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerStatus represents the status of a container.
|
// ContainerStatus represents the status of a container.
|
||||||
@ -791,6 +800,11 @@ message ContainerStatus {
|
|||||||
message ContainerStatusResponse {
|
message ContainerStatusResponse {
|
||||||
// Status of the container.
|
// Status of the container.
|
||||||
ContainerStatus status = 1;
|
ContainerStatus status = 1;
|
||||||
|
// Info is extra information of the Container. The key could be abitrary string, and
|
||||||
|
// value should be in json format. The information could include anything useful for
|
||||||
|
// debug, e.g. pid for linux container based container runtime.
|
||||||
|
// It should only be returned non-empty when Verbose is true.
|
||||||
|
map<string, string> info = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UpdateContainerResourcesRequest {
|
message UpdateContainerResourcesRequest {
|
||||||
@ -920,11 +934,18 @@ message ListImagesResponse {
|
|||||||
message ImageStatusRequest {
|
message ImageStatusRequest {
|
||||||
// Spec of the image.
|
// Spec of the image.
|
||||||
ImageSpec image = 1;
|
ImageSpec image = 1;
|
||||||
|
// Verbose indicates whether to return extra information about the image.
|
||||||
|
bool verbose = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ImageStatusResponse {
|
message ImageStatusResponse {
|
||||||
// Status of the image.
|
// Status of the image.
|
||||||
Image image = 1;
|
Image image = 1;
|
||||||
|
// Info is extra information of the Image. The key could be abitrary string, and
|
||||||
|
// value should be in json format. The information could include anything useful
|
||||||
|
// for debug, e.g. image config for oci image based container runtime.
|
||||||
|
// It should only be returned non-empty when Verbose is true.
|
||||||
|
map<string, string> info = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthConfig contains authorization information for connecting to a registry.
|
// AuthConfig contains authorization information for connecting to a registry.
|
||||||
@ -1007,11 +1028,19 @@ message RuntimeStatus {
|
|||||||
repeated RuntimeCondition conditions = 1;
|
repeated RuntimeCondition conditions = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message StatusRequest {}
|
message StatusRequest {
|
||||||
|
// Verbose indicates whether to return extra information about the runtime.
|
||||||
|
bool verbose = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message StatusResponse {
|
message StatusResponse {
|
||||||
// Status of the Runtime.
|
// Status of the Runtime.
|
||||||
RuntimeStatus status = 1;
|
RuntimeStatus status = 1;
|
||||||
|
// Info is extra information of the Runtime. The key could be abitrary string, and
|
||||||
|
// value should be in json format. The information could include anything useful for
|
||||||
|
// debug, e.g. plugins used by the container runtime.
|
||||||
|
// It should only be returned non-empty when Verbose is true.
|
||||||
|
map<string, string> info = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ImageFsInfoRequest {}
|
message ImageFsInfoRequest {}
|
||||||
|
Loading…
Reference in New Issue
Block a user