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
3da59859
Commit
3da59859
authored
Nov 21, 2017
by
Angus Lees
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only check Readiness of masters, not every node
parent
68ea48bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
BUILD
cmd/kubeadm/app/phases/upgrade/BUILD
+1
-0
health.go
cmd/kubeadm/app/phases/upgrade/health.go
+20
-10
No files found.
cmd/kubeadm/app/phases/upgrade/BUILD
View file @
3da59859
...
@@ -43,6 +43,7 @@ go_library(
...
@@ -43,6 +43,7 @@ go_library(
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
...
...
cmd/kubeadm/app/phases/upgrade/health.go
View file @
3da59859
...
@@ -24,6 +24,7 @@ import (
...
@@ -24,6 +24,7 @@ import (
apps
"k8s.io/api/apps/v1beta2"
apps
"k8s.io/api/apps/v1beta2"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
clientset
"k8s.io/client-go/kubernetes"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
...
@@ -53,7 +54,7 @@ func (c *healthCheck) Name() string {
...
@@ -53,7 +54,7 @@ func (c *healthCheck) Name() string {
// CheckClusterHealth makes sure:
// CheckClusterHealth makes sure:
// - the API /healthz endpoint is healthy
// - the API /healthz endpoint is healthy
// - all Nodes are Ready
// - all
master
Nodes are Ready
// - (if self-hosted) that there are DaemonSets with at least one Pod for all control plane components
// - (if self-hosted) that there are DaemonSets with at least one Pod for all control plane components
// - (if static pod-hosted) that all required Static Pod manifests exist on disk
// - (if static pod-hosted) that all required Static Pod manifests exist on disk
func
CheckClusterHealth
(
client
clientset
.
Interface
,
ignoreChecksErrors
sets
.
String
)
error
{
func
CheckClusterHealth
(
client
clientset
.
Interface
,
ignoreChecksErrors
sets
.
String
)
error
{
...
@@ -66,9 +67,9 @@ func CheckClusterHealth(client clientset.Interface, ignoreChecksErrors sets.Stri
...
@@ -66,9 +67,9 @@ func CheckClusterHealth(client clientset.Interface, ignoreChecksErrors sets.Stri
f
:
apiServerHealthy
,
f
:
apiServerHealthy
,
},
},
&
healthCheck
{
&
healthCheck
{
name
:
"
NodeHealth
"
,
name
:
"
MasterNodesReady
"
,
client
:
client
,
client
:
client
,
f
:
nodesHealth
y
,
f
:
masterNodesRead
y
,
},
},
// TODO: Add a check for ComponentStatuses here?
// TODO: Add a check for ComponentStatuses here?
}
}
...
@@ -106,16 +107,25 @@ func apiServerHealthy(client clientset.Interface) error {
...
@@ -106,16 +107,25 @@ func apiServerHealthy(client clientset.Interface) error {
return
nil
return
nil
}
}
// nodesHealthy checks whether all Nodes in the cluster are in the Running state
// masterNodesReady checks whether all master Nodes in the cluster are in the Running state
func
nodesHealthy
(
client
clientset
.
Interface
)
error
{
func
masterNodesReady
(
client
clientset
.
Interface
)
error
{
nodes
,
err
:=
client
.
CoreV1
()
.
Nodes
()
.
List
(
metav1
.
ListOptions
{})
selector
:=
labels
.
SelectorFromSet
(
labels
.
Set
(
map
[
string
]
string
{
constants
.
LabelNodeRoleMaster
:
""
,
}))
masters
,
err
:=
client
.
CoreV1
()
.
Nodes
()
.
List
(
metav1
.
ListOptions
{
LabelSelector
:
selector
.
String
(),
})
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"couldn't list
all node
s in cluster: %v"
,
err
)
return
fmt
.
Errorf
(
"couldn't list
master
s in cluster: %v"
,
err
)
}
}
notReadyNodes
:=
getNotReadyNodes
(
nodes
.
Items
)
if
len
(
masters
.
Items
)
==
0
{
if
len
(
notReadyNodes
)
!=
0
{
return
fmt
.
Errorf
(
"failed to find any nodes with master role"
)
return
fmt
.
Errorf
(
"there are NotReady Nodes in the cluster: %v"
,
notReadyNodes
)
}
notReadyMasters
:=
getNotReadyNodes
(
masters
.
Items
)
if
len
(
notReadyMasters
)
!=
0
{
return
fmt
.
Errorf
(
"there are NotReady masters in the cluster: %v"
,
notReadyMasters
)
}
}
return
nil
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