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
a8dd10da
Commit
a8dd10da
authored
Mar 06, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4907 from ddysher/kubelet-client-interface
kubelet should take a client interface
parents
2d0743b1
50de1a80
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
11 deletions
+26
-11
server.go
cmd/kubelet/app/server.go
+10
-2
listwatch.go
pkg/client/cache/listwatch.go
+1
-1
kubelet.go
pkg/kubelet/kubelet.go
+15
-8
No files found.
cmd/kubelet/app/server.go
View file @
a8dd10da
...
@@ -389,12 +389,20 @@ type KubeletConfig struct {
...
@@ -389,12 +389,20 @@ type KubeletConfig struct {
func
createAndInitKubelet
(
kc
*
KubeletConfig
,
pc
*
config
.
PodConfig
)
(
*
kubelet
.
Kubelet
,
error
)
{
func
createAndInitKubelet
(
kc
*
KubeletConfig
,
pc
*
config
.
PodConfig
)
(
*
kubelet
.
Kubelet
,
error
)
{
// TODO: block until all sources have delivered at least one update to the channel, or break the sync loop
// TODO: block until all sources have delivered at least one update to the channel, or break the sync loop
// up into "per source" synchronizations
// up into "per source" synchronizations
// TODO: KubeletConfig.KubeClient should be a client interface, but client interface misses certain methods
// used by kubelet. Since NewMainKubelet expects a client interface, we need to make sure we are not passing
// a nil pointer to it when what we really want is a nil interface.
var
kubeClient
client
.
Interface
if
kc
.
KubeClient
==
nil
{
kubeClient
=
nil
}
else
{
kubeClient
=
kc
.
KubeClient
}
k
,
err
:=
kubelet
.
NewMainKubelet
(
k
,
err
:=
kubelet
.
NewMainKubelet
(
kc
.
Hostname
,
kc
.
Hostname
,
kc
.
DockerClient
,
kc
.
DockerClient
,
kc
.
EtcdClient
,
kc
.
EtcdClient
,
k
c
.
K
ubeClient
,
kubeClient
,
kc
.
RootDirectory
,
kc
.
RootDirectory
,
kc
.
PodInfraContainerImage
,
kc
.
PodInfraContainerImage
,
kc
.
SyncFrequency
,
kc
.
SyncFrequency
,
...
...
pkg/client/cache/listwatch.go
View file @
a8dd10da
...
@@ -37,7 +37,7 @@ type ListWatch struct {
...
@@ -37,7 +37,7 @@ type ListWatch struct {
WatchFunc
WatchFunc
WatchFunc
WatchFunc
}
}
//
ListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector
//
NewListWatchFromClient creates a new ListWatch from the specified client, resource, namespace and field selector.
func
NewListWatchFromClient
(
client
*
client
.
Client
,
resource
string
,
namespace
string
,
fieldSelector
labels
.
Selector
)
*
ListWatch
{
func
NewListWatchFromClient
(
client
*
client
.
Client
,
resource
string
,
namespace
string
,
fieldSelector
labels
.
Selector
)
*
ListWatch
{
listFunc
:=
func
()
(
runtime
.
Object
,
error
)
{
listFunc
:=
func
()
(
runtime
.
Object
,
error
)
{
return
client
.
Get
()
.
Namespace
(
namespace
)
.
Resource
(
resource
)
.
SelectorParam
(
"fields"
,
fieldSelector
)
.
Do
()
.
Get
()
return
client
.
Get
()
.
Namespace
(
namespace
)
.
Resource
(
resource
)
.
SelectorParam
(
"fields"
,
fieldSelector
)
.
Do
()
.
Get
()
...
...
pkg/kubelet/kubelet.go
View file @
a8dd10da
...
@@ -42,10 +42,12 @@ import (
...
@@ -42,10 +42,12 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/probe"
"github.com/GoogleCloudPlatform/kubernetes/pkg/probe"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
"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/util/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
"github.com/fsouza/go-dockerclient"
"github.com/fsouza/go-dockerclient"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -76,7 +78,7 @@ func NewMainKubelet(
...
@@ -76,7 +78,7 @@ func NewMainKubelet(
hostname
string
,
hostname
string
,
dockerClient
dockertools
.
DockerInterface
,
dockerClient
dockertools
.
DockerInterface
,
etcdClient
tools
.
EtcdClient
,
etcdClient
tools
.
EtcdClient
,
kubeClient
*
client
.
Client
,
kubeClient
client
.
Interface
,
rootDirectory
string
,
rootDirectory
string
,
podInfraContainerImage
string
,
podInfraContainerImage
string
,
resyncInterval
time
.
Duration
,
resyncInterval
time
.
Duration
,
...
@@ -103,12 +105,17 @@ func NewMainKubelet(
...
@@ -103,12 +105,17 @@ func NewMainKubelet(
serviceStore
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
serviceStore
:=
cache
.
NewStore
(
cache
.
MetaNamespaceKeyFunc
)
if
kubeClient
!=
nil
{
if
kubeClient
!=
nil
{
cache
.
NewReflector
(
// TODO: cache.NewListWatchFromClient is limited as it takes a client implementation rather
cache
.
NewListWatchFromClient
(
kubeClient
,
"services"
,
api
.
NamespaceAll
,
labels
.
Everything
()),
// than an interface. There is no way to construct a list+watcher using resource name.
&
api
.
Service
{},
listWatch
:=
&
cache
.
ListWatch
{
serviceStore
,
ListFunc
:
func
()
(
runtime
.
Object
,
error
)
{
0
,
return
kubeClient
.
Services
(
api
.
NamespaceAll
)
.
List
(
labels
.
Everything
())
)
.
Run
()
},
WatchFunc
:
func
(
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
return
kubeClient
.
Services
(
api
.
NamespaceAll
)
.
Watch
(
labels
.
Everything
(),
labels
.
Everything
(),
resourceVersion
)
},
}
cache
.
NewReflector
(
listWatch
,
&
api
.
Service
{},
serviceStore
,
0
)
.
Run
()
}
}
serviceLister
:=
&
cache
.
StoreToServiceLister
{
serviceStore
}
serviceLister
:=
&
cache
.
StoreToServiceLister
{
serviceStore
}
...
@@ -173,7 +180,7 @@ type Kubelet struct {
...
@@ -173,7 +180,7 @@ type Kubelet struct {
hostname
string
hostname
string
dockerClient
dockertools
.
DockerInterface
dockerClient
dockertools
.
DockerInterface
dockerCache
dockertools
.
DockerCache
dockerCache
dockertools
.
DockerCache
kubeClient
*
client
.
Client
kubeClient
client
.
Interface
rootDirectory
string
rootDirectory
string
podInfraContainerImage
string
podInfraContainerImage
string
podWorkers
*
podWorkers
podWorkers
*
podWorkers
...
...
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