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
940f5d44
Commit
940f5d44
authored
Dec 10, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18434 from mesosphere/sur-680-kubelet-events
Auto commit by PR queue bot
parents
f326c4d7
9176e93b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
66 deletions
+87
-66
service.go
contrib/mesos/pkg/executor/service/service.go
+87
-66
No files found.
contrib/mesos/pkg/executor/service/service.go
View file @
940f5d44
...
@@ -147,83 +147,104 @@ func (s *KubeletExecutorServer) runKubelet(
...
@@ -147,83 +147,104 @@ func (s *KubeletExecutorServer) runKubelet(
staticPodsConfigPath
string
,
staticPodsConfigPath
string
,
apiclient
*
client
.
Client
,
apiclient
*
client
.
Client
,
podLW
*
cache
.
ListWatch
,
podLW
*
cache
.
ListWatch
,
)
error
{
)
(
err
error
)
{
defer
func
()
{
if
err
!=
nil
{
// close the channel here. When Run returns without error, the executorKubelet is
// responsible to do this. If it returns with an error, we are responsible here.
close
(
kubeletDone
)
}
}()
kcfg
,
err
:=
s
.
UnsecuredKubeletConfig
()
kcfg
,
err
:=
s
.
UnsecuredKubeletConfig
()
if
err
==
nil
{
if
err
!=
nil
{
// apply Mesos specific settings
return
err
executorDone
:=
make
(
chan
struct
{})
}
kcfg
.
Builder
=
func
(
kc
*
kubeletapp
.
KubeletConfig
)
(
kubeletapp
.
KubeletBootstrap
,
*
kconfig
.
PodConfig
,
error
)
{
k
,
pc
,
err
:=
kubeletapp
.
CreateAndInitKubelet
(
kc
)
if
err
!=
nil
{
return
k
,
pc
,
err
}
s
.
klet
=
k
.
(
*
kubelet
.
Kubelet
)
// apply Mesos specific settings
close
(
s
.
kletReady
)
// intentionally crash if this is called more than once
executorDone
:=
make
(
chan
struct
{})
kcfg
.
Builder
=
func
(
kc
*
kubeletapp
.
KubeletConfig
)
(
kubeletapp
.
KubeletBootstrap
,
*
kconfig
.
PodConfig
,
error
)
{
k
,
pc
,
err
:=
kubeletapp
.
CreateAndInitKubelet
(
kc
)
if
err
!=
nil
{
return
k
,
pc
,
err
}
// decorate kubelet such that it shuts down when the executor is
s
.
klet
=
k
.
(
*
kubelet
.
Kubelet
)
decorated
:=
&
executorKubelet
{
close
(
s
.
kletReady
)
// intentionally crash if this is called more than once
Kubelet
:
s
.
klet
,
kubeletDone
:
kubeletDone
,
executorDone
:
executorDone
,
}
return
decorated
,
pc
,
nil
// decorate kubelet such that it shuts down when the executor is
}
decorated
:=
&
executorKubelet
{
kcfg
.
DockerDaemonContainer
=
""
// don't move the docker daemon into a cgroup
Kubelet
:
s
.
klet
,
kcfg
.
Hostname
=
kcfg
.
HostnameOverride
kubeletDone
:
kubeletDone
,
kcfg
.
KubeClient
=
apiclient
executorDone
:
executorDone
,
kcfg
.
NodeName
=
kcfg
.
HostnameOverride
kcfg
.
PodConfig
=
kconfig
.
NewPodConfig
(
kconfig
.
PodConfigNotificationIncremental
,
kcfg
.
Recorder
)
// override the default pod source
kcfg
.
StandaloneMode
=
false
kcfg
.
SystemContainer
=
""
// don't take control over other system processes.
if
kcfg
.
Cloud
!=
nil
{
// fail early and hard because having the cloud provider loaded would go unnoticed,
// but break bigger cluster because accessing the state.json from every slave kills the master.
panic
(
"cloud provider must not be set"
)
}
}
// create custom cAdvisor interface which return the resource values that Mesos reports
return
decorated
,
pc
,
nil
ni
:=
<-
nodeInfos
}
cAdvisorInterface
,
err
:=
NewMesosCadvisor
(
ni
.
Cores
,
ni
.
Mem
,
s
.
CAdvisorPort
)
kcfg
.
DockerDaemonContainer
=
""
// don't move the docker daemon into a cgroup
if
err
!=
nil
{
kcfg
.
Hostname
=
kcfg
.
HostnameOverride
return
err
kcfg
.
KubeClient
=
apiclient
}
kcfg
.
CAdvisorInterface
=
cAdvisorInterface
kcfg
.
ContainerManager
,
err
=
cm
.
NewContainerManager
(
kcfg
.
Mounter
,
cAdvisorInterface
)
if
err
!=
nil
{
return
err
}
go
func
()
{
// taken from KubeletServer#Run(*KubeletConfig)
for
ni
:=
range
nodeInfos
{
eventClientConfig
,
err
:=
s
.
CreateAPIServerClientConfig
()
// TODO(sttts): implement with MachineAllocable mechanism when https://github.com/kubernetes/kubernetes/issues/13984 is finished
if
err
!=
nil
{
log
.
V
(
3
)
.
Infof
(
"ignoring updated node resources: %v"
,
ni
)
return
err
}
}()
// create main pod source, it will close executorDone when the executor updates stop flowing
newSourceMesos
(
executorDone
,
execUpdates
,
kcfg
.
PodConfig
.
Channel
(
mesosSource
),
podLW
)
// create static-pods directory file source
log
.
V
(
2
)
.
Infof
(
"initializing static pods source factory, configured at path %q"
,
staticPodsConfigPath
)
fileSourceUpdates
:=
kcfg
.
PodConfig
.
Channel
(
kubetypes
.
FileSource
)
kconfig
.
NewSourceFile
(
staticPodsConfigPath
,
kcfg
.
HostnameOverride
,
kcfg
.
FileCheckFrequency
,
fileSourceUpdates
)
// run the kubelet, until execUpdates is closed
// NOTE: because kcfg != nil holds, the upstream Run function will not
// initialize the cloud provider. We explicitly wouldn't want
// that because then every kubelet instance would query the master
// state.json which does not scale.
err
=
s
.
KubeletServer
.
Run
(
kcfg
)
}
}
// make a separate client for events
eventClientConfig
.
QPS
=
s
.
EventRecordQPS
eventClientConfig
.
Burst
=
s
.
EventBurst
kcfg
.
EventClient
,
err
=
client
.
New
(
eventClientConfig
)
if
err
!=
nil
{
if
err
!=
nil
{
// close the channel here. When Run returns without error, the executorKubelet is
return
err
// responsible to do this. If it returns with an error, we are responsible here.
close
(
kubeletDone
)
}
}
return
err
kcfg
.
NodeName
=
kcfg
.
HostnameOverride
kcfg
.
PodConfig
=
kconfig
.
NewPodConfig
(
kconfig
.
PodConfigNotificationIncremental
,
kcfg
.
Recorder
)
// override the default pod source
kcfg
.
StandaloneMode
=
false
kcfg
.
SystemContainer
=
""
// don't take control over other system processes.
if
kcfg
.
Cloud
!=
nil
{
// fail early and hard because having the cloud provider loaded would go unnoticed,
// but break bigger cluster because accessing the state.json from every slave kills the master.
panic
(
"cloud provider must not be set"
)
}
// create custom cAdvisor interface which return the resource values that Mesos reports
ni
:=
<-
nodeInfos
cAdvisorInterface
,
err
:=
NewMesosCadvisor
(
ni
.
Cores
,
ni
.
Mem
,
s
.
CAdvisorPort
)
if
err
!=
nil
{
return
err
}
kcfg
.
CAdvisorInterface
=
cAdvisorInterface
kcfg
.
ContainerManager
,
err
=
cm
.
NewContainerManager
(
kcfg
.
Mounter
,
cAdvisorInterface
)
if
err
!=
nil
{
return
err
}
go
func
()
{
for
ni
:=
range
nodeInfos
{
// TODO(sttts): implement with MachineAllocable mechanism when https://github.com/kubernetes/kubernetes/issues/13984 is finished
log
.
V
(
3
)
.
Infof
(
"ignoring updated node resources: %v"
,
ni
)
}
}()
// create main pod source, it will close executorDone when the executor updates stop flowing
newSourceMesos
(
executorDone
,
execUpdates
,
kcfg
.
PodConfig
.
Channel
(
mesosSource
),
podLW
)
// create static-pods directory file source
log
.
V
(
2
)
.
Infof
(
"initializing static pods source factory, configured at path %q"
,
staticPodsConfigPath
)
fileSourceUpdates
:=
kcfg
.
PodConfig
.
Channel
(
kubetypes
.
FileSource
)
kconfig
.
NewSourceFile
(
staticPodsConfigPath
,
kcfg
.
HostnameOverride
,
kcfg
.
FileCheckFrequency
,
fileSourceUpdates
)
// run the kubelet, until execUpdates is closed
// NOTE: because kcfg != nil holds, the upstream Run function will not
// initialize the cloud provider. We explicitly wouldn't want
// that because then every kubelet instance would query the master
// state.json which does not scale.
err
=
s
.
KubeletServer
.
Run
(
kcfg
)
return
}
}
// Run runs the specified KubeletExecutorServer.
// Run runs the specified KubeletExecutorServer.
...
...
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