mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
kubelet: enable CRI container metrics
This commit is contained in:
parent
cd343fd806
commit
2c415cc506
@ -40,6 +40,9 @@ func (i *imageFsInfoProvider) ImageFsInfoLabel() (string, error) {
|
|||||||
case "rkt":
|
case "rkt":
|
||||||
return cadvisorfs.LabelRktImages, nil
|
return cadvisorfs.LabelRktImages, nil
|
||||||
case "remote":
|
case "remote":
|
||||||
|
// This is a temporary workaround to get stats for cri-o from cadvisor
|
||||||
|
// and should be removed.
|
||||||
|
// Related to https://github.com/kubernetes/kubernetes/issues/51798
|
||||||
if i.runtimeEndpoint == "/var/run/crio.sock" {
|
if i.runtimeEndpoint == "/var/run/crio.sock" {
|
||||||
return cadvisorfs.LabelCrioImages, nil
|
return cadvisorfs.LabelCrioImages, nil
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
goruntime "runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -649,12 +650,30 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
|||||||
}
|
}
|
||||||
klet.containerRuntime = runtime
|
klet.containerRuntime = runtime
|
||||||
klet.runner = runtime
|
klet.runner = runtime
|
||||||
klet.StatsProvider = stats.NewCadvisorStatsProvider(
|
|
||||||
klet.cadvisor,
|
// CRI integrations should get container metrics via CRI. Docker
|
||||||
klet.resourceAnalyzer,
|
// uses the built-in cadvisor to gather such metrics on Linux for
|
||||||
klet.podManager,
|
// historical reasons.
|
||||||
klet.runtimeCache,
|
// cri-o relies on cadvisor as a temporary workaround. The code should
|
||||||
klet.containerRuntime)
|
// be removed. Related issue:
|
||||||
|
// https://github.com/kubernetes/kubernetes/issues/51798
|
||||||
|
if (kubeCfg.ContainerRuntime == kubetypes.DockerContainerRuntime &&
|
||||||
|
goruntime.GOOS == "linux") || kubeCfg.RemoteRuntimeEndpoint == "/var/run/crio.sock" {
|
||||||
|
klet.StatsProvider = stats.NewCadvisorStatsProvider(
|
||||||
|
klet.cadvisor,
|
||||||
|
klet.resourceAnalyzer,
|
||||||
|
klet.podManager,
|
||||||
|
klet.runtimeCache,
|
||||||
|
klet.containerRuntime)
|
||||||
|
} else {
|
||||||
|
klet.StatsProvider = stats.NewCRIStatsProvider(
|
||||||
|
klet.cadvisor,
|
||||||
|
klet.resourceAnalyzer,
|
||||||
|
klet.podManager,
|
||||||
|
klet.runtimeCache,
|
||||||
|
runtimeService,
|
||||||
|
imageService)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// rkt uses the legacy, non-CRI, integration. Configure it the old way.
|
// rkt uses the legacy, non-CRI, integration. Configure it the old way.
|
||||||
// TODO: Include hairpin mode settings in rkt?
|
// TODO: Include hairpin mode settings in rkt?
|
||||||
|
Loading…
Reference in New Issue
Block a user