mirror of
https://github.com/kubernetes/node-problem-detector.git
synced 2026-02-14 18:09:57 +00:00
Allow compilation time disabling for each type of Problem Daemon.
This commit is contained in:
@@ -21,3 +21,9 @@ install:
|
||||
script:
|
||||
- make
|
||||
- make test
|
||||
- make clean && BUILD_TAGS="disable_custom_plugin_monitor" make
|
||||
- BUILD_TAGS="disable_custom_plugin_monitor" make test
|
||||
- make clean && BUILD_TAGS="disable_system_log_monitor" make
|
||||
- BUILD_TAGS="disable_system_log_monitor" make test
|
||||
- make clean && BUILD_TAGS="disable_system_stats_monitor" make
|
||||
- BUILD_TAGS="disable_system_stats_monitor" make test
|
||||
|
||||
10
Makefile
10
Makefile
@@ -59,9 +59,11 @@ BASEIMAGE:=k8s.gcr.io/debian-base-amd64:0.4.0
|
||||
# Disable cgo by default to make the binary statically linked.
|
||||
CGO_ENABLED:=0
|
||||
|
||||
# Construct the "-tags" parameter used by "go build".
|
||||
BUILD_TAGS?=""
|
||||
ifeq ($(ENABLE_JOURNALD), 1)
|
||||
# Enable journald build tag.
|
||||
BUILD_TAGS:=-tags journald
|
||||
BUILD_TAGS:=$(BUILD_TAGS) journald
|
||||
# Enable cgo because sdjournal needs cgo to compile. The binary will be
|
||||
# dynamically linked if CGO_ENABLED is enabled. This is fine because fedora
|
||||
# already has necessary dynamic library. We can not use `-extldflags "-static"`
|
||||
@@ -69,6 +71,10 @@ ifeq ($(ENABLE_JOURNALD), 1)
|
||||
# statically linked application.
|
||||
CGO_ENABLED:=1
|
||||
endif
|
||||
ifneq ($(BUILD_TAGS), "")
|
||||
BUILD_TAGS:=-tags "$(BUILD_TAGS)"
|
||||
endif
|
||||
|
||||
|
||||
vet:
|
||||
GO111MODULE=on go list -mod vendor $(BUILD_TAGS) ./... | \
|
||||
@@ -95,7 +101,7 @@ version:
|
||||
-o bin/node-problem-detector \
|
||||
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
|
||||
$(BUILD_TAGS) \
|
||||
./cmd/node-problem-detector
|
||||
./cmd/nodeproblemdetector
|
||||
|
||||
Dockerfile: Dockerfile.in
|
||||
sed -e 's|@BASEIMAGE@|$(BASEIMAGE)|g' $< >$@
|
||||
|
||||
29
README.md
29
README.md
@@ -52,14 +52,19 @@ Currently, a problem daemon is running as a goroutine in the node-problem-detect
|
||||
binary. In the future, we'll separate node-problem-detector and problem daemons into
|
||||
different containers, and compose them with pod specification.
|
||||
|
||||
Each catagory of problem daemon can be disabled at compilation time by setting
|
||||
corresponding build tags. If they are disabled at compilation time, then all their
|
||||
build dependencies, global variables and background goroutines will be trimmed out
|
||||
of the compiled executable.
|
||||
|
||||
List of supported problem daemons:
|
||||
|
||||
| Problem Daemon | NodeCondition | Description |
|
||||
|----------------|:---------------:|:------------|
|
||||
| [KernelMonitor](https://github.com/kubernetes/node-problem-detector/blob/master/config/kernel-monitor.json) | KernelDeadlock | A system log monitor monitors kernel log and reports problem according to predefined rules. |
|
||||
| [AbrtAdaptor](https://github.com/kubernetes/node-problem-detector/blob/master/config/abrt-adaptor.json) | None | Monitor ABRT log messages and report them further. ABRT (Automatic Bug Report Tool) is health monitoring daemon able to catch kernel problems as well as application crashes of various kinds occurred on the host. For more information visit the [link](https://github.com/abrt). |
|
||||
| [CustomPluginMonitor](https://github.com/kubernetes/node-problem-detector/blob/master/config/custom-plugin-monitor.json) | On-demand(According to users configuration) | A custom plugin monitor for node-problem-detector to invoke and check various node problems with user defined check scripts. See proposal [here](https://docs.google.com/document/d/1jK_5YloSYtboj-DtfjmYKxfNnUxCAvohLnsH5aGCAYQ/edit#). |
|
||||
| [SystemStatsMonitor](https://github.com/kubernetes/node-problem-detector/blob/master/config/system-stats-monitor.json) | None(Could be added in the future) | A system stats monitor for node-problem-detector to collect various health-related system stats as metrics. See proposal [here](https://docs.google.com/document/d/1SeaUz6kBavI283Dq8GBpoEUDrHA2a795xtw0OvjM568/edit). |
|
||||
| Problem Daemon | NodeCondition | Description | Disabling Build Tag |
|
||||
|----------------|:---------------:|:------------|:--------------------|
|
||||
| [KernelMonitor](https://github.com/kubernetes/node-problem-detector/blob/master/config/kernel-monitor.json) | KernelDeadlock | A system log monitor monitors kernel log and reports problem according to predefined rules. | disable_system_log_monitor
|
||||
| [AbrtAdaptor](https://github.com/kubernetes/node-problem-detector/blob/master/config/abrt-adaptor.json) | None | Monitor ABRT log messages and report them further. ABRT (Automatic Bug Report Tool) is health monitoring daemon able to catch kernel problems as well as application crashes of various kinds occurred on the host. For more information visit the [link](https://github.com/abrt). | disable_system_log_monitor
|
||||
| [CustomPluginMonitor](https://github.com/kubernetes/node-problem-detector/blob/master/config/custom-plugin-monitor.json) | On-demand(According to users configuration) | A custom plugin monitor for node-problem-detector to invoke and check various node problems with user defined check scripts. See proposal [here](https://docs.google.com/document/d/1jK_5YloSYtboj-DtfjmYKxfNnUxCAvohLnsH5aGCAYQ/edit#). | disable_custom_plugin_monitor
|
||||
| [SystemStatsMonitor](https://github.com/kubernetes/node-problem-detector/blob/master/config/system-stats-monitor.json) | None(Could be added in the future) | A system stats monitor for node-problem-detector to collect various health-related system stats as metrics. See proposal [here](https://docs.google.com/document/d/1SeaUz6kBavI283Dq8GBpoEUDrHA2a795xtw0OvjM568/edit). | disable_system_stats_monitor
|
||||
|
||||
# Exporter
|
||||
|
||||
@@ -117,6 +122,18 @@ with one of the below directions:
|
||||
* Build the binary.
|
||||
* Build the docker image. The binary and `config/` are copied into the docker image.
|
||||
|
||||
If you do not need certain categories of problem daemons, you could choose to disable them at compilation time. This is the
|
||||
best way of keeping your node-problem-detector runtime compact without unnecessary code (e.g. global
|
||||
variables, goroutines, etc). You can do so via setting the `BUILD_TAGS` environment variable
|
||||
before running `make`. For example:
|
||||
|
||||
`BUILD_TAGS="disable_custom_plugin_monitor disable_system_stats_monitor" make`
|
||||
|
||||
Above command will compile the node-problem-detector without [Custom Plugin Monitor](https://github.com/kubernetes/node-problem-detector/tree/master/pkg/custompluginmonitor)
|
||||
and [System Stats Monitor](https://github.com/kubernetes/node-problem-detector/tree/master/pkg/systemstatsmonitor).
|
||||
Check out the [Problem Daemon](https://github.com/kubernetes/node-problem-detector#problem-daemon) section
|
||||
to see how to disable each problem daemon during compilation time.
|
||||
|
||||
**Note**:
|
||||
By default node-problem-detector will be built with systemd support with `make` command. This requires systemd develop files.
|
||||
You should download the systemd develop files first. For Ubuntu, `libsystemd-journal-dev` package should
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"k8s.io/node-problem-detector/cmd/options"
|
||||
_ "k8s.io/node-problem-detector/cmd/nodeproblemdetector/problemdaemonplugins"
|
||||
"k8s.io/node-problem-detector/pkg/exporters/k8sexporter"
|
||||
"k8s.io/node-problem-detector/pkg/exporters/prometheusexporter"
|
||||
"k8s.io/node-problem-detector/pkg/problemdaemon"
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build !disable_custom_plugin_monitor
|
||||
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors All rights reserved.
|
||||
|
||||
@@ -14,11 +16,8 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
package problemdaemonplugins
|
||||
|
||||
// register problem daemons here
|
||||
import (
|
||||
_ "k8s.io/node-problem-detector/pkg/custompluginmonitor"
|
||||
_ "k8s.io/node-problem-detector/pkg/systemlogmonitor"
|
||||
_ "k8s.io/node-problem-detector/pkg/systemstatsmonitor"
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
// +build !disable_system_log_monitor
|
||||
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors All rights reserved.
|
||||
|
||||
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 problemdaemonplugins
|
||||
|
||||
import (
|
||||
_ "k8s.io/node-problem-detector/pkg/systemlogmonitor"
|
||||
)
|
||||
@@ -0,0 +1,23 @@
|
||||
// +build !disable_system_stats_monitor
|
||||
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors All rights reserved.
|
||||
|
||||
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 problemdaemonplugins
|
||||
|
||||
import (
|
||||
_ "k8s.io/node-problem-detector/pkg/systemstatsmonitor"
|
||||
)
|
||||
Reference in New Issue
Block a user