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
566f411b
Commit
566f411b
authored
Aug 31, 2017
by
Derek Carr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support remote runtimes with native cAdvisor support
parent
72192392
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
23 deletions
+54
-23
server.go
cmd/kubelet/app/server.go
+2
-1
BUILD
pkg/kubelet/cadvisor/BUILD
+1
-1
cadvisor_linux.go
pkg/kubelet/cadvisor/cadvisor_linux.go
+9
-17
cadvisor_unsupported.go
pkg/kubelet/cadvisor/cadvisor_unsupported.go
+1
-1
cadvisor_windows.go
pkg/kubelet/cadvisor/cadvisor_windows.go
+1
-1
types.go
pkg/kubelet/cadvisor/types.go
+7
-1
util.go
pkg/kubelet/cadvisor/util.go
+32
-0
conformance.go
test/e2e_node/environment/conformance.go
+1
-1
No files found.
cmd/kubelet/app/server.go
View file @
566f411b
...
@@ -392,7 +392,8 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
...
@@ -392,7 +392,8 @@ func run(s *options.KubeletServer, kubeDeps *kubelet.Dependencies) (err error) {
}
}
if
kubeDeps
.
CAdvisorInterface
==
nil
{
if
kubeDeps
.
CAdvisorInterface
==
nil
{
kubeDeps
.
CAdvisorInterface
,
err
=
cadvisor
.
New
(
s
.
Address
,
uint
(
s
.
CAdvisorPort
),
s
.
ContainerRuntime
,
s
.
RootDirectory
)
imageFsInfoProvider
:=
cadvisor
.
NewImageFsInfoProvider
(
s
.
ContainerRuntime
,
s
.
RemoteRuntimeEndpoint
)
kubeDeps
.
CAdvisorInterface
,
err
=
cadvisor
.
New
(
s
.
Address
,
uint
(
s
.
CAdvisorPort
),
imageFsInfoProvider
,
s
.
RootDirectory
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
pkg/kubelet/cadvisor/BUILD
View file @
566f411b
...
@@ -24,6 +24,7 @@ go_library(
...
@@ -24,6 +24,7 @@ go_library(
}),
}),
deps = [
deps = [
"//vendor/github.com/google/cadvisor/events:go_default_library",
"//vendor/github.com/google/cadvisor/events:go_default_library",
"//vendor/github.com/google/cadvisor/fs: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",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
...
@@ -34,7 +35,6 @@ go_library(
...
@@ -34,7 +35,6 @@ go_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",
"//vendor/github.com/google/cadvisor/fs:go_default_library",
"//vendor/github.com/google/cadvisor/http:go_default_library",
"//vendor/github.com/google/cadvisor/http:go_default_library",
"//vendor/github.com/google/cadvisor/manager:go_default_library",
"//vendor/github.com/google/cadvisor/manager:go_default_library",
"//vendor/github.com/google/cadvisor/metrics:go_default_library",
"//vendor/github.com/google/cadvisor/metrics:go_default_library",
...
...
pkg/kubelet/cadvisor/cadvisor_linux.go
View file @
566f411b
...
@@ -32,7 +32,6 @@ import (
...
@@ -32,7 +32,6 @@ import (
"github.com/google/cadvisor/cache/memory"
"github.com/google/cadvisor/cache/memory"
cadvisormetrics
"github.com/google/cadvisor/container"
cadvisormetrics
"github.com/google/cadvisor/container"
"github.com/google/cadvisor/events"
"github.com/google/cadvisor/events"
cadvisorfs
"github.com/google/cadvisor/fs"
cadvisorhttp
"github.com/google/cadvisor/http"
cadvisorhttp
"github.com/google/cadvisor/http"
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapi
"github.com/google/cadvisor/info/v1"
cadvisorapiv2
"github.com/google/cadvisor/info/v2"
cadvisorapiv2
"github.com/google/cadvisor/info/v2"
...
@@ -44,8 +43,8 @@ import (
...
@@ -44,8 +43,8 @@ import (
)
)
type
cadvisorClient
struct
{
type
cadvisorClient
struct
{
runtime
string
imageFsInfoProvider
ImageFsInfoProvider
rootPath
string
rootPath
string
manager
.
Manager
manager
.
Manager
}
}
...
@@ -106,7 +105,7 @@ func containerLabels(c *cadvisorapi.ContainerInfo) map[string]string {
...
@@ -106,7 +105,7 @@ 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
,
runtime
string
,
rootPath
string
)
(
Interface
,
error
)
{
func
New
(
address
string
,
port
uint
,
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
)
(
Interface
,
error
)
{
sysFs
:=
sysfs
.
NewRealSysFs
()
sysFs
:=
sysfs
.
NewRealSysFs
()
// Create and start the cAdvisor container manager.
// Create and start the cAdvisor container manager.
...
@@ -126,9 +125,9 @@ func New(address string, port uint, runtime string, rootPath string) (Interface,
...
@@ -126,9 +125,9 @@ func New(address string, port uint, runtime string, rootPath string) (Interface,
}
}
cadvisorClient
:=
&
cadvisorClient
{
cadvisorClient
:=
&
cadvisorClient
{
runtime
:
runtime
,
imageFsInfoProvider
:
imageFsInfoProvider
,
rootPath
:
rootPath
,
rootPath
:
rootPath
,
Manager
:
m
,
Manager
:
m
,
}
}
err
=
cadvisorClient
.
exportHTTP
(
address
,
port
)
err
=
cadvisorClient
.
exportHTTP
(
address
,
port
)
...
@@ -208,17 +207,10 @@ func (cc *cadvisorClient) MachineInfo() (*cadvisorapi.MachineInfo, error) {
...
@@ -208,17 +207,10 @@ func (cc *cadvisorClient) MachineInfo() (*cadvisorapi.MachineInfo, error) {
}
}
func
(
cc
*
cadvisorClient
)
ImagesFsInfo
()
(
cadvisorapiv2
.
FsInfo
,
error
)
{
func
(
cc
*
cadvisorClient
)
ImagesFsInfo
()
(
cadvisorapiv2
.
FsInfo
,
error
)
{
var
label
string
label
,
err
:=
cc
.
imageFsInfoProvider
.
ImageFsInfoLabel
()
if
err
!=
nil
{
switch
cc
.
runtime
{
return
cadvisorapiv2
.
FsInfo
{},
err
case
"docker"
:
label
=
cadvisorfs
.
LabelDockerImages
case
"rkt"
:
label
=
cadvisorfs
.
LabelRktImages
default
:
return
cadvisorapiv2
.
FsInfo
{},
fmt
.
Errorf
(
"ImagesFsInfo: unknown runtime: %v"
,
cc
.
runtime
)
}
}
return
cc
.
getFsInfo
(
label
)
return
cc
.
getFsInfo
(
label
)
}
}
...
...
pkg/kubelet/cadvisor/cadvisor_unsupported.go
View file @
566f411b
...
@@ -31,7 +31,7 @@ type cadvisorUnsupported struct {
...
@@ -31,7 +31,7 @@ type cadvisorUnsupported struct {
var
_
Interface
=
new
(
cadvisorUnsupported
)
var
_
Interface
=
new
(
cadvisorUnsupported
)
func
New
(
address
string
,
port
uint
,
runtime
string
,
rootPath
string
)
(
Interface
,
error
)
{
func
New
(
address
string
,
port
uint
,
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
)
(
Interface
,
error
)
{
return
&
cadvisorUnsupported
{},
nil
return
&
cadvisorUnsupported
{},
nil
}
}
...
...
pkg/kubelet/cadvisor/cadvisor_windows.go
View file @
566f411b
...
@@ -30,7 +30,7 @@ type cadvisorClient struct {
...
@@ -30,7 +30,7 @@ type cadvisorClient struct {
var
_
Interface
=
new
(
cadvisorClient
)
var
_
Interface
=
new
(
cadvisorClient
)
// 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
,
runtime
string
,
rootPath
string
)
(
Interface
,
error
)
{
func
New
(
address
string
,
port
uint
,
imageFsInfoProvider
ImageFsInfoProvider
,
rootPath
string
)
(
Interface
,
error
)
{
return
&
cadvisorClient
{},
nil
return
&
cadvisorClient
{},
nil
}
}
...
...
pkg/kubelet/cadvisor/types.go
View file @
566f411b
...
@@ -33,7 +33,7 @@ type Interface interface {
...
@@ -33,7 +33,7 @@ type Interface interface {
VersionInfo
()
(
*
cadvisorapi
.
VersionInfo
,
error
)
VersionInfo
()
(
*
cadvisorapi
.
VersionInfo
,
error
)
// Returns usage information about the filesystem holding
Dock
er images.
// Returns usage information about the filesystem holding
contain
er images.
ImagesFsInfo
()
(
cadvisorapiv2
.
FsInfo
,
error
)
ImagesFsInfo
()
(
cadvisorapiv2
.
FsInfo
,
error
)
// Returns usage information about the root filesystem.
// Returns usage information about the root filesystem.
...
@@ -45,3 +45,9 @@ type Interface interface {
...
@@ -45,3 +45,9 @@ type Interface interface {
// HasDedicatedImageFs returns true iff a dedicated image filesystem exists for storing images.
// HasDedicatedImageFs returns true iff a dedicated image filesystem exists for storing images.
HasDedicatedImageFs
()
(
bool
,
error
)
HasDedicatedImageFs
()
(
bool
,
error
)
}
}
// ImageFsInfoProvider informs cAdvisor how to find imagefs for container images.
type
ImageFsInfoProvider
interface
{
// ImageFsInfoLabel returns the label cAdvisor should use to find the filesystem holding container images.
ImageFsInfoLabel
()
(
string
,
error
)
}
pkg/kubelet/cadvisor/util.go
View file @
566f411b
...
@@ -17,12 +17,44 @@ limitations under the License.
...
@@ -17,12 +17,44 @@ limitations under the License.
package
cadvisor
package
cadvisor
import
(
import
(
"fmt"
cadvisorfs
"github.com/google/cadvisor/fs"
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"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
)
)
// imageFsInfoProvider knows how to translate the configured runtime
// to its file system label for images.
type
imageFsInfoProvider
struct
{
runtime
string
runtimeEndpoint
string
}
// ImageFsInfoLabel returns the image fs label for the configured runtime.
// For remote runtimes, it handles additional runtimes natively understood by cAdvisor.
func
(
i
*
imageFsInfoProvider
)
ImageFsInfoLabel
()
(
string
,
error
)
{
switch
i
.
runtime
{
case
"docker"
:
return
cadvisorfs
.
LabelDockerImages
,
nil
case
"rkt"
:
return
cadvisorfs
.
LabelRktImages
,
nil
case
"remote"
:
// TODO: pending rebase including https://github.com/google/cadvisor/pull/1741
if
i
.
runtimeEndpoint
==
"/var/run/crio.sock"
{
return
"crio-images"
,
nil
}
}
return
""
,
fmt
.
Errorf
(
"no imagefs label for configured runtime"
)
}
// NewImageFsInfoProvider returns a provider for the specified runtime configuration.
func
NewImageFsInfoProvider
(
runtime
,
runtimeEndpoint
string
)
ImageFsInfoProvider
{
return
&
imageFsInfoProvider
{
runtime
:
runtime
,
runtimeEndpoint
:
runtimeEndpoint
}
}
func
CapacityFromMachineInfo
(
info
*
cadvisorapi
.
MachineInfo
)
v1
.
ResourceList
{
func
CapacityFromMachineInfo
(
info
*
cadvisorapi
.
MachineInfo
)
v1
.
ResourceList
{
c
:=
v1
.
ResourceList
{
c
:=
v1
.
ResourceList
{
v1
.
ResourceCPU
:
*
resource
.
NewMilliQuantity
(
v1
.
ResourceCPU
:
*
resource
.
NewMilliQuantity
(
...
...
test/e2e_node/environment/conformance.go
View file @
566f411b
...
@@ -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*/
,
"docker"
,
"/var/lib/kubelet"
)
c
,
err
:=
cadvisor
.
New
(
""
,
0
/*don't start the http server*/
,
cadvisor
.
NewImageFsInfoProvider
(
"docker"
,
""
)
,
"/var/lib/kubelet"
)
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