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
d047dfbc
Commit
d047dfbc
authored
Apr 17, 2017
by
derek mcquay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubeadm: add flag to skip token print out
parent
73fb9781
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
init.go
cmd/kubeadm/app/cmd/init.go
+16
-5
known-flags.txt
hack/verify-flags/known-flags.txt
+1
-0
No files found.
cmd/kubeadm/app/cmd/init.go
View file @
d047dfbc
...
@@ -72,6 +72,7 @@ func NewCmdInit(out io.Writer) *cobra.Command {
...
@@ -72,6 +72,7 @@ func NewCmdInit(out io.Writer) *cobra.Command {
var
cfgPath
string
var
cfgPath
string
var
skipPreFlight
bool
var
skipPreFlight
bool
var
skipTokenPrint
bool
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"init"
,
Use
:
"init"
,
Short
:
"Run this in order to set up the Kubernetes master"
,
Short
:
"Run this in order to set up the Kubernetes master"
,
...
@@ -80,7 +81,7 @@ func NewCmdInit(out io.Writer) *cobra.Command {
...
@@ -80,7 +81,7 @@ func NewCmdInit(out io.Writer) *cobra.Command {
internalcfg
:=
&
kubeadmapi
.
MasterConfiguration
{}
internalcfg
:=
&
kubeadmapi
.
MasterConfiguration
{}
api
.
Scheme
.
Convert
(
cfg
,
internalcfg
,
nil
)
api
.
Scheme
.
Convert
(
cfg
,
internalcfg
,
nil
)
i
,
err
:=
NewInit
(
cfgPath
,
internalcfg
,
skipPreFlight
)
i
,
err
:=
NewInit
(
cfgPath
,
internalcfg
,
skipPreFlight
,
skipTokenPrint
)
kubeadmutil
.
CheckErr
(
err
)
kubeadmutil
.
CheckErr
(
err
)
kubeadmutil
.
CheckErr
(
i
.
Validate
())
kubeadmutil
.
CheckErr
(
i
.
Validate
())
kubeadmutil
.
CheckErr
(
i
.
Run
(
out
))
kubeadmutil
.
CheckErr
(
i
.
Run
(
out
))
...
@@ -126,6 +127,10 @@ func NewCmdInit(out io.Writer) *cobra.Command {
...
@@ -126,6 +127,10 @@ func NewCmdInit(out io.Writer) *cobra.Command {
&
skipPreFlight
,
"skip-preflight-checks"
,
skipPreFlight
,
&
skipPreFlight
,
"skip-preflight-checks"
,
skipPreFlight
,
"Skip preflight checks normally run before modifying the system"
,
"Skip preflight checks normally run before modifying the system"
,
)
)
cmd
.
PersistentFlags
()
.
BoolVar
(
&
skipTokenPrint
,
"skip-token-print"
,
skipTokenPrint
,
"Skip printing of the default bootstrap token generated by 'kubeadm init'"
,
)
cmd
.
PersistentFlags
()
.
StringVar
(
cmd
.
PersistentFlags
()
.
StringVar
(
&
cfg
.
Token
,
"token"
,
cfg
.
Token
,
&
cfg
.
Token
,
"token"
,
cfg
.
Token
,
...
@@ -138,7 +143,7 @@ func NewCmdInit(out io.Writer) *cobra.Command {
...
@@ -138,7 +143,7 @@ func NewCmdInit(out io.Writer) *cobra.Command {
return
cmd
return
cmd
}
}
func
NewInit
(
cfgPath
string
,
cfg
*
kubeadmapi
.
MasterConfiguration
,
skipPreFlight
bool
)
(
*
Init
,
error
)
{
func
NewInit
(
cfgPath
string
,
cfg
*
kubeadmapi
.
MasterConfiguration
,
skipPreFlight
,
skipTokenPrint
bool
)
(
*
Init
,
error
)
{
fmt
.
Println
(
"[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters."
)
fmt
.
Println
(
"[kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters."
)
...
@@ -177,11 +182,12 @@ func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, skipPreFlight
...
@@ -177,11 +182,12 @@ func NewInit(cfgPath string, cfg *kubeadmapi.MasterConfiguration, skipPreFlight
// Try to start the kubelet service in case it's inactive
// Try to start the kubelet service in case it's inactive
preflight
.
TryStartKubelet
()
preflight
.
TryStartKubelet
()
return
&
Init
{
cfg
:
cfg
},
nil
return
&
Init
{
cfg
:
cfg
,
skipTokenPrint
:
skipTokenPrint
},
nil
}
}
type
Init
struct
{
type
Init
struct
{
cfg
*
kubeadmapi
.
MasterConfiguration
cfg
*
kubeadmapi
.
MasterConfiguration
skipTokenPrint
bool
}
}
// Validate validates configuration passed to "kubeadm init"
// Validate validates configuration passed to "kubeadm init"
...
@@ -232,7 +238,9 @@ func (i *Init) Run(out io.Writer) error {
...
@@ -232,7 +238,9 @@ func (i *Init) Run(out io.Writer) error {
}
}
// PHASE 4: Set up the bootstrap tokens
// PHASE 4: Set up the bootstrap tokens
fmt
.
Printf
(
"[token] Using token: %s
\n
"
,
i
.
cfg
.
Token
)
if
!
i
.
skipTokenPrint
{
fmt
.
Printf
(
"[token] Using token: %s
\n
"
,
i
.
cfg
.
Token
)
}
tokenDescription
:=
"The default bootstrap token generated by 'kubeadm init'."
tokenDescription
:=
"The default bootstrap token generated by 'kubeadm init'."
if
err
:=
tokenphase
.
UpdateOrCreateToken
(
client
,
i
.
cfg
.
Token
,
false
,
i
.
cfg
.
TokenTTL
,
kubeadmconstants
.
DefaultTokenUsages
,
tokenDescription
);
err
!=
nil
{
if
err
:=
tokenphase
.
UpdateOrCreateToken
(
client
,
i
.
cfg
.
Token
,
false
,
i
.
cfg
.
TokenTTL
,
kubeadmconstants
.
DefaultTokenUsages
,
tokenDescription
);
err
!=
nil
{
...
@@ -267,6 +275,9 @@ func (i *Init) Run(out io.Writer) error {
...
@@ -267,6 +275,9 @@ func (i *Init) Run(out io.Writer) error {
"MasterIP"
:
i
.
cfg
.
API
.
AdvertiseAddress
,
"MasterIP"
:
i
.
cfg
.
API
.
AdvertiseAddress
,
"MasterPort"
:
strconv
.
Itoa
(
int
(
i
.
cfg
.
API
.
BindPort
)),
"MasterPort"
:
strconv
.
Itoa
(
int
(
i
.
cfg
.
API
.
BindPort
)),
}
}
if
i
.
skipTokenPrint
{
ctx
[
"Token"
]
=
"<value withheld>"
}
return
initDoneTempl
.
Execute
(
out
,
ctx
)
return
initDoneTempl
.
Execute
(
out
,
ctx
)
}
}
hack/verify-flags/known-flags.txt
View file @
d047dfbc
...
@@ -645,6 +645,7 @@ since-time
...
@@ -645,6 +645,7 @@ since-time
skip-generated-rewrite
skip-generated-rewrite
skip-munges
skip-munges
skip-preflight-checks
skip-preflight-checks
skip-token-print
skip-unsafe
skip-unsafe
sort-by
sort-by
source-file
source-file
...
...
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