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
bfb95290
Unverified
Commit
bfb95290
authored
Nov 13, 2018
by
k8s-ci-robot
Committed by
GitHub
Nov 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70795 from yuexiao-wang/print-join-command
kubeadm: print the join command
parents
9199025b
5851fd55
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
10 deletions
+21
-10
init.go
cmd/kubeadm/app/cmd/init.go
+21
-10
No files found.
cmd/kubeadm/app/cmd/init.go
View file @
bfb95290
...
...
@@ -150,6 +150,9 @@ func NewCmdInit(out io.Writer) *cobra.Command {
// via the subcommands automatically created by initRunner.BindToCommand
err
=
runInit
(
&
data
,
out
)
kubeadmutil
.
CheckErr
(
err
)
err
=
showJoinCommand
(
&
data
,
out
)
kubeadmutil
.
CheckErr
(
err
)
},
}
...
...
@@ -395,6 +398,9 @@ func (d initData) KubeConfigDir() string {
// KubeConfigPath returns the path to the kubeconfig file to use for connecting to Kubernetes
func
(
d
initData
)
KubeConfigPath
()
string
{
if
d
.
dryRun
{
d
.
kubeconfigPath
=
filepath
.
Join
(
d
.
dryRunDir
,
kubeadmconstants
.
AdminKubeConfigFileName
)
}
return
d
.
kubeconfigPath
}
...
...
@@ -456,10 +462,9 @@ func (d initData) Tokens() []string {
// runInit executes master node provisioning
func
runInit
(
i
*
initData
,
out
io
.
Writer
)
error
{
// Get directories to write files to; can be faked if we're dry-running
klog
.
V
(
1
)
.
Infof
(
"[init] Getting certificates directory from configuration"
)
certsDirToWriteTo
,
kubeConfigDir
,
_
,
_
,
err
:=
getDirectoriesToUse
(
i
.
dryRun
,
i
.
dryRunDir
,
i
.
cfg
.
CertificatesDir
)
certsDirToWriteTo
,
_
,
_
,
_
,
err
:=
getDirectoriesToUse
(
i
.
dryRun
,
i
.
dryRunDir
,
i
.
cfg
.
CertificatesDir
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"error getting directories to use"
)
}
...
...
@@ -467,8 +472,6 @@ func runInit(i *initData, out io.Writer) error {
// certsDirToWriteTo is gonna equal cfg.CertificatesDir in the normal case, but gonna be a temp directory if dryrunning
i
.
cfg
.
CertificatesDir
=
certsDirToWriteTo
adminKubeConfigPath
:=
filepath
.
Join
(
kubeConfigDir
,
kubeadmconstants
.
AdminKubeConfigFileName
)
// TODO: client and waiter are temporary until the rest of the phases that use them
// are removed from this function.
client
,
err
:=
i
.
Client
()
...
...
@@ -505,12 +508,6 @@ func runInit(i *initData, out io.Writer) error {
return
nil
}
// Prints the join command, multiple times in case the user has multiple tokens
for
_
,
token
:=
range
i
.
Tokens
()
{
if
err
:=
printJoinCommand
(
out
,
adminKubeConfigPath
,
token
,
i
.
skipTokenPrint
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to print join command"
)
}
}
return
nil
}
...
...
@@ -538,3 +535,17 @@ func getDirectoriesToUse(dryRun bool, dryRunDir string, defaultPkiDir string) (s
return
defaultPkiDir
,
kubeadmconstants
.
KubernetesDir
,
kubeadmconstants
.
GetStaticPodDirectory
(),
kubeadmconstants
.
KubeletRunDirectory
,
nil
}
// showJoinCommand prints the join command after all the phases in init have finished
func
showJoinCommand
(
i
*
initData
,
out
io
.
Writer
)
error
{
adminKubeConfigPath
:=
i
.
KubeConfigPath
()
// Prints the join command, multiple times in case the user has multiple tokens
for
_
,
token
:=
range
i
.
Tokens
()
{
if
err
:=
printJoinCommand
(
out
,
adminKubeConfigPath
,
token
,
i
.
skipTokenPrint
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to print join command"
)
}
}
return
nil
}
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