mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
publish node components version information
This commit is contained in:
parent
3e0cdff97c
commit
5b9a6d47e8
@ -39,6 +39,10 @@ func (c *Fake) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
|||||||
return new(cadvisorApi.MachineInfo), nil
|
return new(cadvisorApi.MachineInfo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Fake) VersionInfo() (*cadvisorApi.VersionInfo, error) {
|
||||||
|
return new(cadvisorApi.VersionInfo), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Fake) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (c *Fake) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
||||||
return cadvisorApiV2.FsInfo{}, nil
|
return cadvisorApiV2.FsInfo{}, nil
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,10 @@ func (self *cadvisorClient) ContainerInfo(name string, req *cadvisorApi.Containe
|
|||||||
return self.GetContainerInfo(name, req)
|
return self.GetContainerInfo(name, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *cadvisorClient) VersionInfo() (*cadvisorApi.VersionInfo, error) {
|
||||||
|
return self.GetVersionInfo()
|
||||||
|
}
|
||||||
|
|
||||||
func (self *cadvisorClient) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
func (self *cadvisorClient) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
||||||
return self.GetMachineInfo()
|
return self.GetMachineInfo()
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,11 @@ func (c *Mock) MachineInfo() (*cadvisorApi.MachineInfo, error) {
|
|||||||
return args.Get(0).(*cadvisorApi.MachineInfo), args.Error(1)
|
return args.Get(0).(*cadvisorApi.MachineInfo), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Mock) VersionInfo() (*cadvisorApi.VersionInfo, error) {
|
||||||
|
args := c.Called()
|
||||||
|
return args.Get(0).(*cadvisorApi.VersionInfo), args.Error(1)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Mock) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (c *Mock) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
||||||
args := c.Called()
|
args := c.Called()
|
||||||
return args.Get(0).(cadvisorApiV2.FsInfo), args.Error(1)
|
return args.Get(0).(cadvisorApiV2.FsInfo), args.Error(1)
|
||||||
|
@ -48,6 +48,10 @@ func (self *cadvisorUnsupported) MachineInfo() (*cadvisorApi.MachineInfo, error)
|
|||||||
return nil, unsupportedErr
|
return nil, unsupportedErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *cadvisorUnsupported) VersionInfo() (*cadvisorApi.VersionInfo, error) {
|
||||||
|
return nil, unsupportedErr
|
||||||
|
}
|
||||||
|
|
||||||
func (self *cadvisorUnsupported) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
func (self *cadvisorUnsupported) DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error) {
|
||||||
return cadvisorApiV2.FsInfo{}, unsupportedErr
|
return cadvisorApiV2.FsInfo{}, unsupportedErr
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ type Interface interface {
|
|||||||
ContainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
|
ContainerInfo(name string, req *cadvisorApi.ContainerInfoRequest) (*cadvisorApi.ContainerInfo, error)
|
||||||
MachineInfo() (*cadvisorApi.MachineInfo, error)
|
MachineInfo() (*cadvisorApi.MachineInfo, error)
|
||||||
|
|
||||||
|
VersionInfo() (*cadvisorApi.VersionInfo, error)
|
||||||
|
|
||||||
// Returns usage information about the filesystem holding Docker images.
|
// Returns usage information about the filesystem holding Docker images.
|
||||||
DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error)
|
DockerImagesFsInfo() (cadvisorApiV2.FsInfo, error)
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
utilErrors "github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors"
|
utilErrors "github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
@ -1769,6 +1770,19 @@ func (kl *Kubelet) tryUpdateNodeStatus() error {
|
|||||||
node.Status.NodeInfo.BootID = info.BootID
|
node.Status.NodeInfo.BootID = info.BootID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verinfo, err := kl.cadvisor.VersionInfo()
|
||||||
|
if err != nil {
|
||||||
|
glog.Error("error getting version info: %v", err)
|
||||||
|
} else {
|
||||||
|
node.Status.NodeInfo.KernelVersion = verinfo.KernelVersion
|
||||||
|
node.Status.NodeInfo.OsImage = verinfo.ContainerOsVersion
|
||||||
|
// TODO: Determine the runtime is docker or rocket
|
||||||
|
node.Status.NodeInfo.ContainerRuntimeVersion = "docker://" + verinfo.DockerVersion
|
||||||
|
node.Status.NodeInfo.KubeletVersion = version.Get().String()
|
||||||
|
// TODO: kube-proxy might be different version from kubelet in the future
|
||||||
|
node.Status.NodeInfo.KubeProxyVersion = version.Get().String()
|
||||||
|
}
|
||||||
|
|
||||||
currentTime := util.Now()
|
currentTime := util.Now()
|
||||||
newCondition := api.NodeCondition{
|
newCondition := api.NodeCondition{
|
||||||
Type: api.NodeReady,
|
Type: api.NodeReady,
|
||||||
|
@ -47,6 +47,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/network"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/version"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
|
||||||
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/volume/host_path"
|
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/volume/host_path"
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
@ -3062,6 +3063,12 @@ func TestUpdateNewNodeStatus(t *testing.T) {
|
|||||||
MemoryCapacity: 1024,
|
MemoryCapacity: 1024,
|
||||||
}
|
}
|
||||||
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
||||||
|
versionInfo := &cadvisorApi.VersionInfo{
|
||||||
|
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
||||||
|
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
||||||
|
DockerVersion: "1.5.0",
|
||||||
|
}
|
||||||
|
mockCadvisor.On("VersionInfo").Return(versionInfo, nil)
|
||||||
expectedNode := &api.Node{
|
expectedNode := &api.Node{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "testnode"},
|
ObjectMeta: api.ObjectMeta{Name: "testnode"},
|
||||||
Spec: api.NodeSpec{},
|
Spec: api.NodeSpec{},
|
||||||
@ -3076,9 +3083,14 @@ func TestUpdateNewNodeStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
NodeInfo: api.NodeSystemInfo{
|
NodeInfo: api.NodeSystemInfo{
|
||||||
MachineID: "123",
|
MachineID: "123",
|
||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
|
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
||||||
|
OsImage: "Debian GNU/Linux 7 (wheezy)",
|
||||||
|
ContainerRuntimeVersion: "docker://1.5.0",
|
||||||
|
KubeletVersion: version.Get().String(),
|
||||||
|
KubeProxyVersion: version.Get().String(),
|
||||||
},
|
},
|
||||||
Capacity: api.ResourceList{
|
Capacity: api.ResourceList{
|
||||||
api.ResourceCPU: *resource.NewMilliQuantity(2000, resource.DecimalSI),
|
api.ResourceCPU: *resource.NewMilliQuantity(2000, resource.DecimalSI),
|
||||||
@ -3144,6 +3156,12 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
|
|||||||
MemoryCapacity: 1024,
|
MemoryCapacity: 1024,
|
||||||
}
|
}
|
||||||
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
mockCadvisor.On("MachineInfo").Return(machineInfo, nil)
|
||||||
|
versionInfo := &cadvisorApi.VersionInfo{
|
||||||
|
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
||||||
|
ContainerOsVersion: "Debian GNU/Linux 7 (wheezy)",
|
||||||
|
DockerVersion: "1.5.0",
|
||||||
|
}
|
||||||
|
mockCadvisor.On("VersionInfo").Return(versionInfo, nil)
|
||||||
expectedNode := &api.Node{
|
expectedNode := &api.Node{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "testnode"},
|
ObjectMeta: api.ObjectMeta{Name: "testnode"},
|
||||||
Spec: api.NodeSpec{},
|
Spec: api.NodeSpec{},
|
||||||
@ -3158,9 +3176,14 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
NodeInfo: api.NodeSystemInfo{
|
NodeInfo: api.NodeSystemInfo{
|
||||||
MachineID: "123",
|
MachineID: "123",
|
||||||
SystemUUID: "abc",
|
SystemUUID: "abc",
|
||||||
BootID: "1b3",
|
BootID: "1b3",
|
||||||
|
KernelVersion: "3.16.0-0.bpo.4-amd64",
|
||||||
|
OsImage: "Debian GNU/Linux 7 (wheezy)",
|
||||||
|
ContainerRuntimeVersion: "docker://1.5.0",
|
||||||
|
KubeletVersion: version.Get().String(),
|
||||||
|
KubeProxyVersion: version.Get().String(),
|
||||||
},
|
},
|
||||||
Capacity: api.ResourceList{
|
Capacity: api.ResourceList{
|
||||||
api.ResourceCPU: *resource.NewMilliQuantity(2000, resource.DecimalSI),
|
api.ResourceCPU: *resource.NewMilliQuantity(2000, resource.DecimalSI),
|
||||||
|
Loading…
Reference in New Issue
Block a user