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
590ef489
Commit
590ef489
authored
Oct 30, 2016
by
bulletRush
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[kubeadm] pre-flight check hostname to ensure kubelet can launch static pods
parent
34d6df68
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
BUILD
cmd/kubeadm/app/preflight/BUILD
+2
-0
checks.go
cmd/kubeadm/app/preflight/checks.go
+17
-0
No files found.
cmd/kubeadm/app/preflight/BUILD
View file @
590ef489
...
@@ -16,6 +16,8 @@ go_library(
...
@@ -16,6 +16,8 @@ go_library(
tags = ["automanaged"],
tags = ["automanaged"],
deps = [
deps = [
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
"//pkg/api/validation:go_default_library",
"//pkg/util/initsystem:go_default_library",
"//pkg/util/initsystem:go_default_library",
"//pkg/util/node:go_default_library",
],
],
)
)
cmd/kubeadm/app/preflight/checks.go
View file @
590ef489
...
@@ -25,7 +25,9 @@ import (
...
@@ -25,7 +25,9 @@ import (
"os/exec"
"os/exec"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmapi
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/util/initsystem"
"k8s.io/kubernetes/pkg/util/initsystem"
"k8s.io/kubernetes/pkg/util/node"
)
)
type
PreFlightError
struct
{
type
PreFlightError
struct
{
...
@@ -170,10 +172,24 @@ func (ipc InPathCheck) Check() (warnings, errors []error) {
...
@@ -170,10 +172,24 @@ func (ipc InPathCheck) Check() (warnings, errors []error) {
return
nil
,
nil
return
nil
,
nil
}
}
// HostnameCheck checks if hostname match dns sub domain regex.
// If hostname doesn't match this regex, kubelet will not launch static pods like kube-apiserver/kube-controller-manager and so on.
type
HostnameCheck
struct
{}
func
(
hc
HostnameCheck
)
Check
()
(
warnings
,
errors
[]
error
)
{
errors
=
[]
error
{}
hostname
:=
node
.
GetHostname
(
""
)
for
_
,
msg
:=
range
validation
.
ValidateNodeName
(
hostname
,
false
)
{
errors
=
append
(
errors
,
fmt
.
Errorf
(
"hostname
\"
%s
\"
%s"
,
hostname
,
msg
))
}
return
nil
,
errors
}
func
RunInitMasterChecks
(
cfg
*
kubeadmapi
.
MasterConfiguration
)
error
{
func
RunInitMasterChecks
(
cfg
*
kubeadmapi
.
MasterConfiguration
)
error
{
// TODO: Some of these ports should come from kubeadm config eventually:
// TODO: Some of these ports should come from kubeadm config eventually:
checks
:=
[]
PreFlightCheck
{
checks
:=
[]
PreFlightCheck
{
IsRootCheck
{
root
:
true
},
IsRootCheck
{
root
:
true
},
HostnameCheck
{},
ServiceCheck
{
Service
:
"kubelet"
},
ServiceCheck
{
Service
:
"kubelet"
},
ServiceCheck
{
Service
:
"docker"
},
ServiceCheck
{
Service
:
"docker"
},
PortOpenCheck
{
port
:
int
(
cfg
.
API
.
BindPort
)},
PortOpenCheck
{
port
:
int
(
cfg
.
API
.
BindPort
)},
...
@@ -207,6 +223,7 @@ func RunJoinNodeChecks() error {
...
@@ -207,6 +223,7 @@ func RunJoinNodeChecks() error {
// TODO: Some of these ports should come from kubeadm config eventually:
// TODO: Some of these ports should come from kubeadm config eventually:
checks
:=
[]
PreFlightCheck
{
checks
:=
[]
PreFlightCheck
{
IsRootCheck
{
root
:
true
},
IsRootCheck
{
root
:
true
},
HostnameCheck
{},
ServiceCheck
{
Service
:
"docker"
},
ServiceCheck
{
Service
:
"docker"
},
ServiceCheck
{
Service
:
"kubelet"
},
ServiceCheck
{
Service
:
"kubelet"
},
PortOpenCheck
{
port
:
10250
},
PortOpenCheck
{
port
:
10250
},
...
...
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