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
fc30b380
Unverified
Commit
fc30b380
authored
Mar 01, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Mar 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #74756 from fabriziopandini/cleanup-join-phases
Cleanup join data struct
parents
646145f5
4c27d6a2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
41 deletions
+31
-41
join.go
cmd/kubeadm/app/cmd/join.go
+8
-12
checketcd.go
cmd/kubeadm/app/cmd/phases/join/checketcd.go
+1
-2
controlplanejoin.go
cmd/kubeadm/app/cmd/phases/join/controlplanejoin.go
+6
-9
data.go
cmd/kubeadm/app/cmd/phases/join/data.go
+1
-2
data_test.go
cmd/kubeadm/app/cmd/phases/join/data_test.go
+7
-8
kubelet.go
cmd/kubeadm/app/cmd/phases/join/kubelet.go
+8
-8
No files found.
cmd/kubeadm/app/cmd/join.go
View file @
fc30b380
...
...
@@ -140,7 +140,7 @@ type joinData struct {
skipTokenPrint
bool
initCfg
*
kubeadmapi
.
InitConfiguration
tlsBootstrapCfg
*
clientcmdapi
.
Config
clientSet
s
map
[
string
]
*
clientset
.
Clientset
clientSet
*
clientset
.
Clientset
ignorePreflightErrors
sets
.
String
outputWriter
io
.
Writer
certificateKey
string
...
...
@@ -178,7 +178,7 @@ func NewCmdJoin(out io.Writer, joinOptions *joinOptions) *cobra.Command {
}
ctx
:=
map
[
string
]
string
{
"KubeConfigPath"
:
data
.
KubeConfigPath
(),
"KubeConfigPath"
:
kubeadmconstants
.
GetAdmin
KubeConfigPath
(),
"etcdMessage"
:
etcdMessage
,
}
joinControPlaneDoneTemp
.
Execute
(
data
.
outputWriter
,
ctx
)
...
...
@@ -385,7 +385,6 @@ func newJoinData(cmd *cobra.Command, args []string, options *joinOptions, out io
return
&
joinData
{
cfg
:
cfg
,
clientSets
:
map
[
string
]
*
clientset
.
Clientset
{},
ignorePreflightErrors
:
ignorePreflightErrorsSet
,
outputWriter
:
out
,
certificateKey
:
options
.
certificateKey
,
...
...
@@ -402,11 +401,6 @@ func (j *joinData) Cfg() *kubeadmapi.JoinConfiguration {
return
j
.
cfg
}
// KubeConfigPath returns the default kubeconfig path.
func
(
j
*
joinData
)
KubeConfigPath
()
string
{
return
kubeadmconstants
.
GetAdminKubeConfigPath
()
}
// TLSBootstrapCfg returns the cluster-info (kubeconfig).
func
(
j
*
joinData
)
TLSBootstrapCfg
()
(
*
clientcmdapi
.
Config
,
error
)
{
if
j
.
tlsBootstrapCfg
!=
nil
{
...
...
@@ -432,15 +426,17 @@ func (j *joinData) InitCfg() (*kubeadmapi.InitConfiguration, error) {
return
initCfg
,
err
}
func
(
j
*
joinData
)
ClientSetFromFile
(
path
string
)
(
*
clientset
.
Clientset
,
error
)
{
if
client
,
ok
:=
j
.
clientSets
[
path
];
ok
{
return
client
,
nil
// ClientSet returns the ClientSet for accessing the cluster with the identity defined in admin.conf.
func
(
j
*
joinData
)
ClientSet
()
(
*
clientset
.
Clientset
,
error
)
{
if
j
.
clientSet
!=
nil
{
return
j
.
clientSet
,
nil
}
path
:=
kubeadmconstants
.
GetAdminKubeConfigPath
()
client
,
err
:=
kubeconfigutil
.
ClientSetFromFile
(
path
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"[join] couldn't create Kubernetes client"
)
}
j
.
clientSet
s
[
path
]
=
client
j
.
clientSet
=
client
return
client
,
nil
}
...
...
cmd/kubeadm/app/cmd/phases/join/checketcd.go
View file @
fc30b380
...
...
@@ -21,7 +21,6 @@ import (
"github.com/pkg/errors"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
kubeadmconstants
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
etcdphase
"k8s.io/kubernetes/cmd/kubeadm/app/phases/etcd"
)
...
...
@@ -61,7 +60,7 @@ func runCheckEtcdPhase(c workflow.RunData) error {
// Checks that the etcd cluster is healthy
// NB. this check cannot be implemented before because it requires the admin.conf and all the certificates
// for connecting to etcd already in place
client
,
err
:=
data
.
ClientSet
FromFile
(
kubeadmconstants
.
GetAdminKubeConfigPath
()
)
client
,
err
:=
data
.
ClientSet
(
)
if
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/cmd/phases/join/controlplanejoin.go
View file @
fc30b380
...
...
@@ -111,9 +111,8 @@ func runEtcdPhase(c workflow.RunData) error {
return
nil
}
kubeConfigFile
:=
data
.
KubeConfigPath
()
client
,
err
:=
data
.
ClientSetFromFile
(
kubeConfigFile
)
// gets access to the cluster using the identity defined in admin.conf
client
,
err
:=
data
.
ClientSet
()
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"couldn't create Kubernetes client"
)
}
...
...
@@ -153,9 +152,8 @@ func runUploadConfigPhase(c workflow.RunData) error {
return
nil
}
kubeConfigFile
:=
data
.
KubeConfigPath
()
client
,
err
:=
data
.
ClientSetFromFile
(
kubeConfigFile
)
// gets access to the cluster using the identity defined in admin.conf
client
,
err
:=
data
.
ClientSet
()
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"couldn't create Kubernetes client"
)
}
...
...
@@ -181,9 +179,8 @@ func runMarkControlPlanePhase(c workflow.RunData) error {
return
nil
}
kubeConfigFile
:=
data
.
KubeConfigPath
()
client
,
err
:=
data
.
ClientSetFromFile
(
kubeConfigFile
)
// gets access to the cluster using the identity defined in admin.conf
client
,
err
:=
data
.
ClientSet
()
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"couldn't create Kubernetes client"
)
}
...
...
cmd/kubeadm/app/cmd/phases/join/data.go
View file @
fc30b380
...
...
@@ -30,10 +30,9 @@ import (
type
JoinData
interface
{
CertificateKey
()
string
Cfg
()
*
kubeadmapi
.
JoinConfiguration
KubeConfigPath
()
string
TLSBootstrapCfg
()
(
*
clientcmdapi
.
Config
,
error
)
InitCfg
()
(
*
kubeadmapi
.
InitConfiguration
,
error
)
ClientSet
FromFile
(
path
string
)
(
*
clientset
.
Clientset
,
error
)
ClientSet
(
)
(
*
clientset
.
Clientset
,
error
)
IgnorePreflightErrors
()
sets
.
String
OutputWriter
()
io
.
Writer
}
cmd/kubeadm/app/cmd/phases/join/data_test.go
View file @
fc30b380
...
...
@@ -31,11 +31,10 @@ type testJoinData struct{}
// testJoinData must satisfy JoinData.
var
_
JoinData
=
&
testJoinData
{}
func
(
j
*
testJoinData
)
CertificateKey
()
string
{
return
""
}
func
(
j
*
testJoinData
)
Cfg
()
*
kubeadmapi
.
JoinConfiguration
{
return
nil
}
func
(
j
*
testJoinData
)
KubeConfigPath
()
string
{
return
""
}
func
(
j
*
testJoinData
)
TLSBootstrapCfg
()
(
*
clientcmdapi
.
Config
,
error
)
{
return
nil
,
nil
}
func
(
j
*
testJoinData
)
InitCfg
()
(
*
kubeadmapi
.
InitConfiguration
,
error
)
{
return
nil
,
nil
}
func
(
j
*
testJoinData
)
ClientSetFromFile
(
path
string
)
(
*
clientset
.
Clientset
,
error
)
{
return
nil
,
nil
}
func
(
j
*
testJoinData
)
IgnorePreflightErrors
()
sets
.
String
{
return
nil
}
func
(
j
*
testJoinData
)
OutputWriter
()
io
.
Writer
{
return
nil
}
func
(
j
*
testJoinData
)
CertificateKey
()
string
{
return
""
}
func
(
j
*
testJoinData
)
Cfg
()
*
kubeadmapi
.
JoinConfiguration
{
return
nil
}
func
(
j
*
testJoinData
)
TLSBootstrapCfg
()
(
*
clientcmdapi
.
Config
,
error
)
{
return
nil
,
nil
}
func
(
j
*
testJoinData
)
InitCfg
()
(
*
kubeadmapi
.
InitConfiguration
,
error
)
{
return
nil
,
nil
}
func
(
j
*
testJoinData
)
ClientSet
()
(
*
clientset
.
Clientset
,
error
)
{
return
nil
,
nil
}
func
(
j
*
testJoinData
)
IgnorePreflightErrors
()
sets
.
String
{
return
nil
}
func
(
j
*
testJoinData
)
OutputWriter
()
io
.
Writer
{
return
nil
}
cmd/kubeadm/app/cmd/phases/join/kubelet.go
View file @
fc30b380
...
...
@@ -74,28 +74,28 @@ func NewKubeletStartPhase() workflow.Phase {
}
}
func
getKubeletStartJoinData
(
c
workflow
.
RunData
)
(
JoinData
,
*
kubeadmapi
.
JoinConfiguration
,
*
kubeadmapi
.
InitConfiguration
,
*
clientcmdapi
.
Config
,
error
)
{
func
getKubeletStartJoinData
(
c
workflow
.
RunData
)
(
*
kubeadmapi
.
JoinConfiguration
,
*
kubeadmapi
.
InitConfiguration
,
*
clientcmdapi
.
Config
,
error
)
{
data
,
ok
:=
c
.
(
JoinData
)
if
!
ok
{
return
nil
,
nil
,
nil
,
nil
,
errors
.
New
(
"kubelet-start phase invoked with an invalid data struct"
)
return
nil
,
nil
,
nil
,
errors
.
New
(
"kubelet-start phase invoked with an invalid data struct"
)
}
cfg
:=
data
.
Cfg
()
initCfg
,
err
:=
data
.
InitCfg
()
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
nil
,
err
return
nil
,
nil
,
nil
,
err
}
tlsBootstrapCfg
,
err
:=
data
.
TLSBootstrapCfg
()
if
err
!=
nil
{
return
nil
,
nil
,
nil
,
nil
,
err
return
nil
,
nil
,
nil
,
err
}
return
data
,
cfg
,
initCfg
,
tlsBootstrapCfg
,
nil
return
cfg
,
initCfg
,
tlsBootstrapCfg
,
nil
}
// runKubeletStartJoinPhase executes the kubelet TLS bootstrap process.
// This process is executed by the kubelet and completes with the node joining the cluster
// with a dedicates set of credentials as required by the node authorizer
func
runKubeletStartJoinPhase
(
c
workflow
.
RunData
)
error
{
data
,
cfg
,
initCfg
,
tlsBootstrapCfg
,
err
:=
getKubeletStartJoinData
(
c
)
cfg
,
initCfg
,
tlsBootstrapCfg
,
err
:=
getKubeletStartJoinData
(
c
)
if
err
!=
nil
{
return
err
}
...
...
@@ -120,7 +120,7 @@ func runKubeletStartJoinPhase(c workflow.RunData) error {
return
err
}
bootstrapClient
,
err
:=
data
.
ClientSetFromFile
(
bootstrapKubeConfigFile
)
bootstrapClient
,
err
:=
kubeconfigutil
.
ClientSetFromFile
(
bootstrapKubeConfigFile
)
if
err
!=
nil
{
return
errors
.
Errorf
(
"couldn't create client from kubeconfig file %q"
,
bootstrapKubeConfigFile
)
}
...
...
@@ -157,7 +157,7 @@ func runKubeletStartJoinPhase(c workflow.RunData) error {
}
// When we know the /etc/kubernetes/kubelet.conf file is available, get the client
client
,
err
:=
data
.
ClientSetFromFile
(
kubeadmconstants
.
GetKubeletKubeConfigPath
())
client
,
err
:=
kubeconfigutil
.
ClientSetFromFile
(
kubeadmconstants
.
GetKubeletKubeConfigPath
())
if
err
!=
nil
{
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