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
9e2d66a1
Unverified
Commit
9e2d66a1
authored
Apr 03, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Apr 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75851 from neolit123/automated-cherry-pick-of-#75847-origin-release-1.14
Automated cherry pick of #75847: fix-external-etcd
parents
67f26571
90cf8be1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
14 deletions
+34
-14
preflight.go
cmd/kubeadm/app/cmd/phases/init/preflight.go
+1
-1
preflight.go
cmd/kubeadm/app/cmd/phases/join/preflight.go
+2
-1
checks.go
cmd/kubeadm/app/preflight/checks.go
+11
-5
checks_test.go
cmd/kubeadm/app/preflight/checks_test.go
+20
-7
No files found.
cmd/kubeadm/app/cmd/phases/init/preflight.go
View file @
9e2d66a1
...
...
@@ -57,7 +57,7 @@ func runPreflight(c workflow.RunData) error {
}
fmt
.
Println
(
"[preflight] Running pre-flight checks"
)
if
err
:=
preflight
.
RunInitNodeChecks
(
utilsexec
.
New
(),
data
.
Cfg
(),
data
.
IgnorePreflightErrors
(),
false
);
err
!=
nil
{
if
err
:=
preflight
.
RunInitNodeChecks
(
utilsexec
.
New
(),
data
.
Cfg
(),
data
.
IgnorePreflightErrors
(),
false
,
false
);
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/cmd/phases/join/preflight.go
View file @
9e2d66a1
...
...
@@ -120,7 +120,8 @@ func runPreflight(c workflow.RunData) error {
// run kubeadm init preflight checks for checking all the prequisites
fmt
.
Println
(
"[preflight] Running pre-flight checks before initializing the new control plane instance"
)
if
err
:=
preflight
.
RunInitNodeChecks
(
utilsexec
.
New
(),
initCfg
,
j
.
IgnorePreflightErrors
(),
true
);
err
!=
nil
{
if
err
:=
preflight
.
RunInitNodeChecks
(
utilsexec
.
New
(),
initCfg
,
j
.
IgnorePreflightErrors
(),
true
,
hasCertificateKey
);
err
!=
nil
{
return
err
}
...
...
cmd/kubeadm/app/preflight/checks.go
View file @
9e2d66a1
...
...
@@ -874,8 +874,9 @@ func (ncc NumCPUCheck) Check() (warnings, errorList []error) {
// RunInitNodeChecks executes all individual, applicable to control-plane node checks.
// The boolean flag 'isSecondaryControlPlane' controls whether we are running checks in a --join-control-plane scenario.
// The boolean flag 'downloadCerts' controls whether we should skip checks on certificates because we are downloading them.
// If the flag is set to true we should skip checks already executed by RunJoinNodeChecks and RunOptionalJoinNodeChecks.
func
RunInitNodeChecks
(
execer
utilsexec
.
Interface
,
cfg
*
kubeadmapi
.
InitConfiguration
,
ignorePreflightErrors
sets
.
String
,
isSecondaryControlPlane
bool
)
error
{
func
RunInitNodeChecks
(
execer
utilsexec
.
Interface
,
cfg
*
kubeadmapi
.
InitConfiguration
,
ignorePreflightErrors
sets
.
String
,
isSecondaryControlPlane
bool
,
downloadCerts
bool
)
error
{
if
!
isSecondaryControlPlane
{
// First, check if we're root separately from the other preflight checks and fail fast
if
err
:=
RunRootCheckOnly
(
ignorePreflightErrors
);
err
!=
nil
{
...
...
@@ -919,10 +920,16 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
)
}
}
// if using an external etcd
if
cfg
.
Etcd
.
External
!=
nil
{
// Check external etcd version before creating the cluster
checks
=
append
(
checks
,
ExternalEtcdVersionCheck
{
Etcd
:
cfg
.
Etcd
})
}
}
if
cfg
.
Etcd
.
Local
!=
nil
{
// Only do etcd related checks when
no external endpoints were specifie
d
// Only do etcd related checks when
required to install a local etc
d
checks
=
append
(
checks
,
PortOpenCheck
{
port
:
kubeadmconstants
.
EtcdListenClientPort
},
PortOpenCheck
{
port
:
kubeadmconstants
.
EtcdListenPeerPort
},
...
...
@@ -930,8 +937,8 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
)
}
if
cfg
.
Etcd
.
External
!=
nil
{
// Only check etcd
version when external endpoints are specified
if
cfg
.
Etcd
.
External
!=
nil
&&
!
(
isSecondaryControlPlane
&&
downloadCerts
)
{
// Only check etcd
certificates when using an external etcd and not joining with automatic download of certs
if
cfg
.
Etcd
.
External
.
CAFile
!=
""
{
checks
=
append
(
checks
,
FileExistingCheck
{
Path
:
cfg
.
Etcd
.
External
.
CAFile
,
Label
:
"ExternalEtcdClientCertificates"
})
}
...
...
@@ -941,7 +948,6 @@ func RunInitNodeChecks(execer utilsexec.Interface, cfg *kubeadmapi.InitConfigura
if
cfg
.
Etcd
.
External
.
KeyFile
!=
""
{
checks
=
append
(
checks
,
FileExistingCheck
{
Path
:
cfg
.
Etcd
.
External
.
KeyFile
,
Label
:
"ExternalEtcdClientCertificates"
})
}
checks
=
append
(
checks
,
ExternalEtcdVersionCheck
{
Etcd
:
cfg
.
Etcd
})
}
return
RunChecks
(
checks
,
os
.
Stderr
,
ignorePreflightErrors
)
...
...
cmd/kubeadm/app/preflight/checks_test.go
View file @
9e2d66a1
...
...
@@ -186,9 +186,11 @@ func (pfct preflightCheckTest) Check() (warning, errorList []error) {
func
TestRunInitNodeChecks
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
name
string
cfg
*
kubeadmapi
.
InitConfiguration
expected
bool
name
string
cfg
*
kubeadmapi
.
InitConfiguration
expected
bool
isSecondaryControlPlane
bool
downloadCerts
bool
}{
{
name
:
"Test valid advertised address"
,
cfg
:
&
kubeadmapi
.
InitConfiguration
{
...
...
@@ -197,7 +199,7 @@ func TestRunInitNodeChecks(t *testing.T) {
expected
:
false
,
},
{
name
:
"Test CA file exists if specfied"
,
name
:
"Test CA file exists if spec
i
fied"
,
cfg
:
&
kubeadmapi
.
InitConfiguration
{
ClusterConfiguration
:
kubeadmapi
.
ClusterConfiguration
{
Etcd
:
kubeadmapi
.
Etcd
{
External
:
&
kubeadmapi
.
ExternalEtcd
{
CAFile
:
"/foo"
}},
...
...
@@ -206,7 +208,18 @@ func TestRunInitNodeChecks(t *testing.T) {
expected
:
false
,
},
{
name
:
"Test Cert file exists if specfied"
,
name
:
"Skip test CA file exists if specified/download certs"
,
cfg
:
&
kubeadmapi
.
InitConfiguration
{
ClusterConfiguration
:
kubeadmapi
.
ClusterConfiguration
{
Etcd
:
kubeadmapi
.
Etcd
{
External
:
&
kubeadmapi
.
ExternalEtcd
{
CAFile
:
"/foo"
}},
},
},
expected
:
true
,
isSecondaryControlPlane
:
true
,
downloadCerts
:
true
,
},
{
name
:
"Test Cert file exists if specified"
,
cfg
:
&
kubeadmapi
.
InitConfiguration
{
ClusterConfiguration
:
kubeadmapi
.
ClusterConfiguration
{
Etcd
:
kubeadmapi
.
Etcd
{
External
:
&
kubeadmapi
.
ExternalEtcd
{
CertFile
:
"/foo"
}},
...
...
@@ -215,7 +228,7 @@ func TestRunInitNodeChecks(t *testing.T) {
expected
:
false
,
},
{
name
:
"Test Key file exists if specfied"
,
name
:
"Test Key file exists if spec
i
fied"
,
cfg
:
&
kubeadmapi
.
InitConfiguration
{
ClusterConfiguration
:
kubeadmapi
.
ClusterConfiguration
{
Etcd
:
kubeadmapi
.
Etcd
{
External
:
&
kubeadmapi
.
ExternalEtcd
{
CertFile
:
"/foo"
}},
...
...
@@ -232,7 +245,7 @@ func TestRunInitNodeChecks(t *testing.T) {
}
for
_
,
rt
:=
range
tests
{
// TODO: Make RunInitNodeChecks accept a ClusterConfiguration object instead of InitConfiguration
actual
:=
RunInitNodeChecks
(
exec
.
New
(),
rt
.
cfg
,
sets
.
NewString
(),
false
)
actual
:=
RunInitNodeChecks
(
exec
.
New
(),
rt
.
cfg
,
sets
.
NewString
(),
rt
.
isSecondaryControlPlane
,
rt
.
downloadCerts
)
if
(
actual
==
nil
)
!=
rt
.
expected
{
t
.
Errorf
(
"failed RunInitNodeChecks:
\n\t
expected: %t
\n\t
actual: %t
\n\t
error: %v"
,
...
...
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