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
58aae57e
Commit
58aae57e
authored
Jun 24, 2020
by
Brian Downs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set environment variable and create config for crictl
Signed-off-by:
Brian Downs
<
brian.downs@gmail.com
>
parent
63dbf806
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
main.go
cmd/k3s/main.go
+3
-0
run.go
pkg/agent/run.go
+32
-4
No files found.
cmd/k3s/main.go
View file @
58aae57e
...
@@ -40,6 +40,9 @@ func main() {
...
@@ -40,6 +40,9 @@ func main() {
}
}
func
runCLIs
()
bool
{
func
runCLIs
()
bool
{
if
os
.
Getenv
(
"CRI_CONFIG_FILE"
)
==
""
{
os
.
Setenv
(
"CRI_CONFIG_FILE"
,
datadir
.
DefaultDataDir
+
"/agent/etc/crictl.yaml"
)
}
for
_
,
cmd
:=
range
[]
string
{
"kubectl"
,
"ctr"
,
"crictl"
}
{
for
_
,
cmd
:=
range
[]
string
{
"kubectl"
,
"ctr"
,
"crictl"
}
{
if
filepath
.
Base
(
os
.
Args
[
0
])
==
cmd
{
if
filepath
.
Base
(
os
.
Args
[
0
])
==
cmd
{
if
err
:=
externalCLI
(
cmd
,
""
,
os
.
Args
[
1
:
]);
err
!=
nil
{
if
err
:=
externalCLI
(
cmd
,
""
,
os
.
Args
[
1
:
]);
err
!=
nil
{
...
...
pkg/agent/run.go
View file @
58aae57e
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/agent"
"github.com/rancher/k3s/pkg/daemons/agent"
daemonconfig
"github.com/rancher/k3s/pkg/daemons/config"
daemonconfig
"github.com/rancher/k3s/pkg/daemons/config"
"github.com/rancher/k3s/pkg/datadir"
"github.com/rancher/k3s/pkg/nodeconfig"
"github.com/rancher/k3s/pkg/nodeconfig"
"github.com/rancher/k3s/pkg/rootless"
"github.com/rancher/k3s/pkg/rootless"
"github.com/rancher/k3s/pkg/version"
"github.com/rancher/k3s/pkg/version"
...
@@ -39,15 +40,42 @@ var (
...
@@ -39,15 +40,42 @@ var (
HostnameLabel
=
version
.
Program
+
".io/hostname"
HostnameLabel
=
version
.
Program
+
".io/hostname"
)
)
func
run
(
ctx
context
.
Context
,
cfg
cmds
.
Agent
,
proxy
proxy
.
Proxy
)
error
{
const
(
nodeConfig
:=
config
.
Get
(
ctx
,
cfg
,
proxy
)
dockershimSock
=
"unix:///var/run/dockershim.sock"
containerdSock
=
"unix:///run/k3s/containerd/containerd.sock"
)
if
cfg
.
Docker
{
// setupCriCtlConfig creates the crictl config file and populates it
if
err
:=
os
.
Symlink
(
"/var/run/dockershim.sock"
,
"/run/k3s/containerd/containerd.sock"
);
err
!=
nil
{
// with the given data from config.
func
setupCriCtlConfig
(
cfg
cmds
.
Agent
,
nodeConfig
*
daemonconfig
.
Node
)
error
{
cre
:=
nodeConfig
.
ContainerRuntimeEndpoint
if
cre
==
""
{
switch
{
case
cfg
.
Docker
:
cre
=
dockershimSock
default
:
cre
=
containerdSock
}
}
agentConfDir
:=
datadir
.
DefaultDataDir
+
"/agent/etc"
if
_
,
err
:=
os
.
Stat
(
agentConfDir
);
os
.
IsNotExist
(
err
)
{
if
err
:=
os
.
MkdirAll
(
agentConfDir
,
0755
);
err
!=
nil
{
return
err
return
err
}
}
}
}
crp
:=
"runtime-endpoint: "
+
cre
+
"
\n
"
return
ioutil
.
WriteFile
(
agentConfDir
+
"/crictl.yaml"
,
[]
byte
(
crp
),
0600
)
}
func
run
(
ctx
context
.
Context
,
cfg
cmds
.
Agent
,
proxy
proxy
.
Proxy
)
error
{
nodeConfig
:=
config
.
Get
(
ctx
,
cfg
,
proxy
)
if
err
:=
setupCriCtlConfig
(
cfg
,
nodeConfig
);
err
!=
nil
{
return
err
}
if
!
nodeConfig
.
NoFlannel
{
if
!
nodeConfig
.
NoFlannel
{
if
err
:=
flannel
.
Prepare
(
ctx
,
nodeConfig
);
err
!=
nil
{
if
err
:=
flannel
.
Prepare
(
ctx
,
nodeConfig
);
err
!=
nil
{
return
err
return
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