Skip to content

Commit

Permalink
[addons] Introduce NodeProblemDetector
Browse files Browse the repository at this point in the history
Node Problem Detector aims to make various node problems visible to
the upstream layers in the cluster management stack. It is a daemon
that runs on each node, detects node problems and reports them to apiserver
so to avoid scheduling new pods on bad nodes and also easily identify
which are the problems on underlying nodes.

Project Home: https://github.com/kubernetes/node-problem-detector

Signed-off-by: dntosas <ntosas@gmail.com>
  • Loading branch information
dntosas committed May 4, 2021
1 parent e3fbc2a commit 73899ee
Show file tree
Hide file tree
Showing 14 changed files with 463 additions and 0 deletions.
29 changes: 29 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3962,6 +3962,35 @@ spec:
items:
type: string
type: array
nodeProblemDetector:
description: NodeProblemDetector determines the node problem detector
configuration.
properties:
cpuRequest:
anyOf:
- type: integer
- type: string
description: 'CPURequest of NodeProblemDetector container. Default:
10m'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
enabled:
description: 'Enabled enables the NodeProblemDetector. Default:
false'
type: boolean
image:
description: 'Image is the NodeProblemDetector docker container
used Default: k8s.gcr.io/node-problem-detector/node-problem-detector:v0.8.7'
type: string
memoryRequest:
anyOf:
- type: integer
- type: string
description: 'MemoryRequest of NodeProblemDetector container.
Default: 32Mi'
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
nodeTerminationHandler:
description: NodeTerminationHandler determines the cluster autoscaler
configuration.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ type ClusterSpec struct {

// NodeTerminationHandler determines the node termination handler configuration.
NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"`
// NodeProblemDetector determines the node problem detector configuration.
NodeProblemDetector *NodeProblemDetectorConfig `json:"nodeProblemDetector,omitempty"`
// MetricsServer determines the metrics server configuration.
MetricsServer *MetricsServerConfig `json:"metricsServer,omitempty"`
// CertManager determines the metrics server configuration.
Expand Down
17 changes: 17 additions & 0 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,23 @@ type NodeTerminationHandlerConfig struct {
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
}

// NodeProblemDetector determines the node problem detector configuration.
type NodeProblemDetectorConfig struct {
// Enabled enables the NodeProblemDetector.
// Default: false
Enabled *bool `json:"enabled,omitempty"`
// Image is the NodeProblemDetector docker container used
// Default: k8s.gcr.io/node-problem-detector/node-problem-detector:v0.8.7
Image string `json:"image,omitempty"`

// MemoryRequest of NodeProblemDetector container.
// Default: 32Mi
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest of NodeProblemDetector container.
// Default: 10m
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
}

// ClusterAutoscalerConfig determines the cluster autoscaler configuration.
type ClusterAutoscalerConfig struct {
// Enabled enables the cluster autoscaler.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ type ClusterSpec struct {

// NodeTerminationHandler determines the cluster autoscaler configuration.
NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"`
// NodeProblemDetector determines the node problem detector configuration.
NodeProblemDetector *NodeProblemDetectorConfig `json:"nodeProblemDetector,omitempty"`
// MetricsServer determines the metrics server configuration.
MetricsServer *MetricsServerConfig `json:"metricsServer,omitempty"`
// CertManager determines the metrics server configuration.
Expand Down
17 changes: 17 additions & 0 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,23 @@ type NodeTerminationHandlerConfig struct {
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
}

// NodeProblemDetector determines the node problem detector configuration.
type NodeProblemDetectorConfig struct {
// Enabled enables the NodeProblemDetector.
// Default: false
Enabled *bool `json:"enabled,omitempty"`
// Image is the NodeProblemDetector docker container used
// Default: k8s.gcr.io/node-problem-detector/node-problem-detector:v0.8.7
Image string `json:"image,omitempty"`

// MemoryRequest of NodeProblemDetector container.
// Default: 32Mi
MemoryRequest *resource.Quantity `json:"memoryRequest,omitempty"`
// CPURequest of NodeProblemDetector container.
// Default: 10m
CPURequest *resource.Quantity `json:"cpuRequest,omitempty"`
}

// ClusterAutoscalerConfig determines the cluster autoscaler configuration.
type ClusterAutoscalerConfig struct {
// Enabled enables the cluster autoscaler.
Expand Down
54 changes: 54 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/model/components/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions pkg/model/components/nodeproblemdetector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package components

import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/loader"
)

// NodeProblemDetectorOptionsBuilder adds options for the node problem detector to the model.
type NodeProblemDetectorOptionsBuilder struct {
*OptionsContext
}

var _ loader.OptionsBuilder = &NodeProblemDetectorOptionsBuilder{}

func (b *NodeProblemDetectorOptionsBuilder) BuildOptions(o interface{}) error {
clusterSpec := o.(*kops.ClusterSpec)
if clusterSpec.NodeProblemDetector == nil {
return nil
}
npd := clusterSpec.NodeProblemDetector

if npd.Enabled == nil {
npd.Enabled = fi.Bool(false)
}

if npd.CPURequest == nil {
defaultCPURequest := resource.MustParse("10m")
npd.CPURequest = &defaultCPURequest
}

if npd.MemoryRequest == nil {
defaultMemoryRequest := resource.MustParse("32Mi")
npd.MemoryRequest = &defaultMemoryRequest
}

if npd.Enabled == nil {
npd.Enabled = fi.Bool(false)
}

if npd.Image == "" {
npd.Image = "k8s.gcr.io/node-problem-detector/node-problem-detector:v0.8.7"
}

return nil
}
1 change: 1 addition & 0 deletions upup/models/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 73899ee

Please sign in to comment.