Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
220edbc6
Commit
220edbc6
authored
Nov 14, 2017
by
David Ashpole
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable container disk metrics when using the CRI stats integration
parent
d2153dff
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
14 deletions
+27
-14
server.go
cmd/kubelet/app/server.go
+1
-1
BUILD
pkg/kubelet/cadvisor/BUILD
+1
-1
cadvisor_linux.go
pkg/kubelet/cadvisor/cadvisor_linux.go
+7
-2
util.go
pkg/kubelet/cadvisor/util.go
+16
-0
kubelet.go
pkg/kubelet/kubelet.go
+1
-9
conformance.go
test/e2e_node/environment/conformance.go
+1
-1
No files found.
cmd/kubelet/app/server.go
View file @
220edbc6
...
@@ -414,7 +414,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
...
@@ -414,7 +414,7 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
if
kubeDeps
.
CAdvisorInterface
==
nil
{
if
kubeDeps
.
CAdvisorInterface
==
nil
{
imageFsInfoProvider
:=
cadvisor
.
NewImageFsInfoProvider
(
s
.
ContainerRuntime
,
s
.
RemoteRuntimeEndpoint
)
imageFsInfoProvider
:=
cadvisor
.
NewImageFsInfoProvider
(
s
.
ContainerRuntime
,
s
.
RemoteRuntimeEndpoint
)
kubeDeps
.
CAdvisorInterface
,
err
=
cadvisor
.
New
(
s
.
Address
,
uint
(
s
.
CAdvisorPort
),
imageFsInfoProvider
,
s
.
RootDirectory
)
kubeDeps
.
CAdvisorInterface
,
err
=
cadvisor
.
New
(
s
.
Address
,
uint
(
s
.
CAdvisorPort
),
imageFsInfoProvider
,
s
.
RootDirectory
,
cadvisor
.
UsingLegacyCadvisorStats
(
s
.
ContainerRuntime
,
s
.
RemoteRuntimeEndpoint
)
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubelet/cadvisor/BUILD
View file @
220edbc6
...
@@ -28,6 +28,7 @@ go_library(
...
@@ -28,6 +28,7 @@ go_library(
deps = [
deps = [
"//pkg/apis/core/v1/helper:go_default_library",
"//pkg/apis/core/v1/helper:go_default_library",
"//pkg/features:go_default_library",
"//pkg/features:go_default_library",
"//pkg/kubelet/types:go_default_library",
"//vendor/github.com/google/cadvisor/events:go_default_library",
"//vendor/github.com/google/cadvisor/events:go_default_library",
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
...
@@ -36,7 +37,6 @@ go_library(
...
@@ -36,7 +37,6 @@ go_library(
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
] + select({
] + select({
"@io_bazel_rules_go//go/platform:linux_amd64": [
"@io_bazel_rules_go//go/platform:linux_amd64": [
"//pkg/kubelet/types:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/google/cadvisor/cache/memory:go_default_library",
"//vendor/github.com/google/cadvisor/cache/memory:go_default_library",
"//vendor/github.com/google/cadvisor/container:go_default_library",
"//vendor/github.com/google/cadvisor/container:go_default_library",
...
...
pkg/kubelet/cadvisor/cadvisor_linux.go
View file @
220edbc6
...
@@ -105,11 +105,16 @@ func containerLabels(c *cadvisorapi.ContainerInfo) map[string]string {
...
@@ -105,11 +105,16 @@ func containerLabels(c *cadvisorapi.ContainerInfo) map[string]string {
}
}
// New creates a cAdvisor and exports its API on the specified port if port > 0.
// New creates a cAdvisor and exports its API on the specified port if port > 0.
func
New
(
address
string
,
port
uint
,
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
)
(
Interface
,
error
)
{
func
New
(
address
string
,
port
uint
,
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
,
usingLegacyStats
bool
)
(
Interface
,
error
)
{
sysFs
:=
sysfs
.
NewRealSysFs
()
sysFs
:=
sysfs
.
NewRealSysFs
()
ignoreMetrics
:=
cadvisormetrics
.
MetricSet
{
cadvisormetrics
.
NetworkTcpUsageMetrics
:
struct
{}{},
cadvisormetrics
.
NetworkUdpUsageMetrics
:
struct
{}{}}
if
!
usingLegacyStats
{
ignoreMetrics
[
cadvisormetrics
.
DiskUsageMetrics
]
=
struct
{}{}
}
// Create and start the cAdvisor container manager.
// Create and start the cAdvisor container manager.
m
,
err
:=
manager
.
New
(
memory
.
New
(
statsCacheDuration
,
nil
),
sysFs
,
maxHousekeepingInterval
,
allowDynamicHousekeeping
,
cadvisormetrics
.
MetricSet
{
cadvisormetrics
.
NetworkTcpUsageMetrics
:
struct
{}{},
cadvisormetrics
.
NetworkUdpUsageMetrics
:
struct
{}{}}
,
http
.
DefaultClient
)
m
,
err
:=
manager
.
New
(
memory
.
New
(
statsCacheDuration
,
nil
),
sysFs
,
maxHousekeepingInterval
,
allowDynamicHousekeeping
,
ignoreMetrics
,
http
.
DefaultClient
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/kubelet/cadvisor/util.go
View file @
220edbc6
...
@@ -17,6 +17,8 @@ limitations under the License.
...
@@ -17,6 +17,8 @@ limitations under the License.
package
cadvisor
package
cadvisor
import
(
import
(
goruntime
"runtime"
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapi2
"github.com/google/cadvisor/info/v2"
cadvisorapi2
"github.com/google/cadvisor/info/v2"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
...
@@ -24,6 +26,7 @@ import (
...
@@ -24,6 +26,7 @@ import (
utilfeature
"k8s.io/apiserver/pkg/util/feature"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
v1helper
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
v1helper
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/pkg/features"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
)
)
func
CapacityFromMachineInfo
(
info
*
cadvisorapi
.
MachineInfo
)
v1
.
ResourceList
{
func
CapacityFromMachineInfo
(
info
*
cadvisorapi
.
MachineInfo
)
v1
.
ResourceList
{
...
@@ -57,3 +60,16 @@ func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceLis
...
@@ -57,3 +60,16 @@ func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceLis
}
}
return
c
return
c
}
}
// CRI integrations should get container metrics via CRI. Docker
// uses the built-in cadvisor to gather such metrics on Linux for
// historical reasons.
// cri-o relies on cadvisor as a temporary workaround. The code should
// be removed. Related issue:
// https://github.com/kubernetes/kubernetes/issues/51798
// UsingLegacyCadvisorStats returns true if container stats are provided by cadvisor instead of through the CRI
func
UsingLegacyCadvisorStats
(
runtime
,
runtimeEndpoint
string
)
bool
{
return
runtime
==
kubetypes
.
RktContainerRuntime
||
(
runtime
==
kubetypes
.
DockerContainerRuntime
&&
goruntime
.
GOOS
==
"linux"
)
||
runtimeEndpoint
==
"/var/run/crio.sock"
}
pkg/kubelet/kubelet.go
View file @
220edbc6
...
@@ -24,7 +24,6 @@ import (
...
@@ -24,7 +24,6 @@ import (
"net/url"
"net/url"
"os"
"os"
"path"
"path"
goruntime
"runtime"
"sort"
"sort"
"strings"
"strings"
"sync"
"sync"
...
@@ -676,14 +675,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
...
@@ -676,14 +675,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
klet
.
containerRuntime
=
runtime
klet
.
containerRuntime
=
runtime
klet
.
runner
=
runtime
klet
.
runner
=
runtime
// CRI integrations should get container metrics via CRI. Docker
if
cadvisor
.
UsingLegacyCadvisorStats
(
containerRuntime
,
remoteRuntimeEndpoint
)
{
// uses the built-in cadvisor to gather such metrics on Linux for
// historical reasons.
// cri-o relies on cadvisor as a temporary workaround. The code should
// be removed. Related issue:
// https://github.com/kubernetes/kubernetes/issues/51798
if
(
containerRuntime
==
kubetypes
.
DockerContainerRuntime
&&
goruntime
.
GOOS
==
"linux"
)
||
remoteRuntimeEndpoint
==
"/var/run/crio.sock"
{
klet
.
StatsProvider
=
stats
.
NewCadvisorStatsProvider
(
klet
.
StatsProvider
=
stats
.
NewCadvisorStatsProvider
(
klet
.
cadvisor
,
klet
.
cadvisor
,
klet
.
resourceAnalyzer
,
klet
.
resourceAnalyzer
,
...
...
test/e2e_node/environment/conformance.go
View file @
220edbc6
...
@@ -99,7 +99,7 @@ func containerRuntime() error {
...
@@ -99,7 +99,7 @@ func containerRuntime() error {
}
}
// Setup cadvisor to check the container environment
// Setup cadvisor to check the container environment
c
,
err
:=
cadvisor
.
New
(
""
,
0
/*don't start the http server*/
,
cadvisor
.
NewImageFsInfoProvider
(
"docker"
,
""
),
"/var/lib/kubelet"
)
c
,
err
:=
cadvisor
.
New
(
""
,
0
/*don't start the http server*/
,
cadvisor
.
NewImageFsInfoProvider
(
"docker"
,
""
),
"/var/lib/kubelet"
,
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
printError
(
"Container Runtime Check: %s Could not start cadvisor %v"
,
failed
,
err
)
return
printError
(
"Container Runtime Check: %s Could not start cadvisor %v"
,
failed
,
err
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment