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
e0327046
Commit
e0327046
authored
Feb 14, 2022
by
Brad Davidson
Committed by
Brad Davidson
Mar 15, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bootstrap the executor even when the agent is disabled
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
(cherry picked from commit
f090bf2d
)
parent
e078a290
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
14 deletions
+49
-14
run.go
pkg/agent/run.go
+39
-5
server.go
pkg/cli/server/server.go
+10
-9
No files found.
pkg/agent/run.go
View file @
e0327046
...
@@ -218,6 +218,32 @@ func coreClient(cfg string) (kubernetes.Interface, error) {
...
@@ -218,6 +218,32 @@ func coreClient(cfg string) (kubernetes.Interface, error) {
return
kubernetes
.
NewForConfig
(
restConfig
)
return
kubernetes
.
NewForConfig
(
restConfig
)
}
}
// RunStandalone bootstraps the executor, but does not run the kubelet or containerd.
// This allows other bits of code that expect the executor to be set up properly to function
// even when the agent is disabled. It will only return in case of error or context
// cancellation.
func
RunStandalone
(
ctx
context
.
Context
,
cfg
cmds
.
Agent
)
error
{
proxy
,
err
:=
createProxyAndValidateToken
(
ctx
,
&
cfg
)
if
err
!=
nil
{
return
err
}
nodeConfig
:=
config
.
Get
(
ctx
,
cfg
,
proxy
)
if
err
:=
executor
.
Bootstrap
(
ctx
,
nodeConfig
,
cfg
);
err
!=
nil
{
return
err
}
if
cfg
.
AgentReady
!=
nil
{
close
(
cfg
.
AgentReady
)
}
<-
ctx
.
Done
()
return
ctx
.
Err
()
}
// Run sets up cgroups, configures the LB proxy, and triggers startup
// of containerd and kubelet. It will only return in case of error or context
// cancellation.
func
Run
(
ctx
context
.
Context
,
cfg
cmds
.
Agent
)
error
{
func
Run
(
ctx
context
.
Context
,
cfg
cmds
.
Agent
)
error
{
if
err
:=
validate
();
err
!=
nil
{
if
err
:=
validate
();
err
!=
nil
{
return
err
return
err
...
@@ -229,14 +255,23 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
...
@@ -229,14 +255,23 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
}
}
}
}
proxy
,
err
:=
createProxyAndValidateToken
(
ctx
,
&
cfg
)
if
err
!=
nil
{
return
err
}
return
run
(
ctx
,
cfg
,
proxy
)
}
func
createProxyAndValidateToken
(
ctx
context
.
Context
,
cfg
*
cmds
.
Agent
)
(
proxy
.
Proxy
,
error
)
{
agentDir
:=
filepath
.
Join
(
cfg
.
DataDir
,
"agent"
)
agentDir
:=
filepath
.
Join
(
cfg
.
DataDir
,
"agent"
)
if
err
:=
os
.
MkdirAll
(
agentDir
,
0700
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
agentDir
,
0700
);
err
!=
nil
{
return
err
return
nil
,
err
}
}
proxy
,
err
:=
proxy
.
NewSupervisorProxy
(
ctx
,
!
cfg
.
DisableLoadBalancer
,
agentDir
,
cfg
.
ServerURL
,
cfg
.
LBServerPort
)
proxy
,
err
:=
proxy
.
NewSupervisorProxy
(
ctx
,
!
cfg
.
DisableLoadBalancer
,
agentDir
,
cfg
.
ServerURL
,
cfg
.
LBServerPort
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
for
{
for
{
...
@@ -245,7 +280,7 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
...
@@ -245,7 +280,7 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
logrus
.
Error
(
err
)
logrus
.
Error
(
err
)
select
{
select
{
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
return
nil
,
ctx
.
Err
()
case
<-
time
.
After
(
2
*
time
.
Second
)
:
case
<-
time
.
After
(
2
*
time
.
Second
)
:
}
}
continue
continue
...
@@ -253,8 +288,7 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
...
@@ -253,8 +288,7 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
cfg
.
Token
=
newToken
.
String
()
cfg
.
Token
=
newToken
.
String
()
break
break
}
}
return
proxy
,
nil
return
run
(
ctx
,
cfg
,
proxy
)
}
}
func
validate
()
error
{
func
validate
()
error
{
...
...
pkg/cli/server/server.go
View file @
e0327046
...
@@ -80,8 +80,10 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
...
@@ -80,8 +80,10 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
return
err
return
err
}
}
cfg
.
DataDir
=
dataDir
cfg
.
DataDir
=
dataDir
if
err
:=
rootless
.
Rootless
(
dataDir
);
err
!=
nil
{
if
!
cfg
.
DisableAgent
{
return
err
if
err
:=
rootless
.
Rootless
(
dataDir
);
err
!=
nil
{
return
err
}
}
}
}
}
...
@@ -437,12 +439,6 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
...
@@ -437,12 +439,6 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
}
}
}()
}()
if
cfg
.
DisableAgent
{
close
(
agentReady
)
<-
ctx
.
Done
()
return
nil
}
ip
:=
serverConfig
.
ControlConfig
.
BindAddress
ip
:=
serverConfig
.
ControlConfig
.
BindAddress
if
ip
==
""
{
if
ip
==
""
{
ip
=
"127.0.0.1"
ip
=
"127.0.0.1"
...
@@ -464,7 +460,6 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
...
@@ -464,7 +460,6 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
agentConfig
.
DisableServiceLB
=
serverConfig
.
DisableServiceLB
agentConfig
.
DisableServiceLB
=
serverConfig
.
DisableServiceLB
agentConfig
.
ETCDAgent
=
serverConfig
.
ControlConfig
.
DisableAPIServer
agentConfig
.
ETCDAgent
=
serverConfig
.
ControlConfig
.
DisableAPIServer
agentConfig
.
ClusterReset
=
serverConfig
.
ControlConfig
.
ClusterReset
agentConfig
.
ClusterReset
=
serverConfig
.
ControlConfig
.
ClusterReset
agentConfig
.
Rootless
=
cfg
.
Rootless
agentConfig
.
Rootless
=
cfg
.
Rootless
if
agentConfig
.
Rootless
{
if
agentConfig
.
Rootless
{
...
@@ -480,6 +475,12 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
...
@@ -480,6 +475,12 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
agentConfig
.
APIAddressCh
=
make
(
chan
[]
string
)
agentConfig
.
APIAddressCh
=
make
(
chan
[]
string
)
go
getAPIAddressFromEtcd
(
ctx
,
serverConfig
,
agentConfig
)
go
getAPIAddressFromEtcd
(
ctx
,
serverConfig
,
agentConfig
)
}
}
if
cfg
.
DisableAgent
{
agentConfig
.
ContainerRuntimeEndpoint
=
"/dev/null"
return
agent
.
RunStandalone
(
ctx
,
agentConfig
)
}
return
agent
.
Run
(
ctx
,
agentConfig
)
return
agent
.
Run
(
ctx
,
agentConfig
)
}
}
...
...
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