-
Notifications
You must be signed in to change notification settings - Fork 655
Separate linux/windows health checker files. Build health checker plugin for Windows #544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ package options | |
import ( | ||
"flag" | ||
"fmt" | ||
"runtime" | ||
"time" | ||
|
||
"github.com/spf13/pflag" | ||
|
@@ -34,7 +35,7 @@ func NewHealthCheckerOptions() *HealthCheckerOptions { | |
// HealthCheckerOptions are the options used to configure the health checker. | ||
type HealthCheckerOptions struct { | ||
Component string | ||
SystemdService string | ||
Service string | ||
EnableRepair bool | ||
CriCtlPath string | ||
CriSocketPath string | ||
|
@@ -47,8 +48,14 @@ type HealthCheckerOptions struct { | |
func (hco *HealthCheckerOptions) AddFlags(fs *pflag.FlagSet) { | ||
fs.StringVar(&hco.Component, "component", types.KubeletComponent, | ||
"The component to check health for. Supports kubelet, docker and cri") | ||
fs.StringVar(&hco.SystemdService, "systemd-service", "", | ||
"The underlying systemd service responsible for the component. Set to the corresponding component for docker and kubelet, containerd for cri.") | ||
// Deprecated: For backward compatibility on linux environment. Going forward "service" will be used instead of systemd-service | ||
if runtime.GOOS == "linux" { | ||
fs.MarkDeprecated("systemd-service", "please use --service flag instead") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, so need both like the following?
|
||
fs.StringVar(&hco.Service, "systemd-service", "", | ||
"The underlying service responsible for the component. Set to the corresponding component for docker and kubelet, containerd for cri.") | ||
} | ||
fs.StringVar(&hco.Service, "service", "", | ||
mcshooter marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"The underlying service responsible for the component. Set to the corresponding component for docker and kubelet, containerd for cri.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should explain what the service means on linux and windows. And I don't think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean cri is not a valid option? I think the message says to use containerd for cri? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh nvm. I misread the flag description. |
||
fs.BoolVar(&hco.EnableRepair, "enable-repair", true, "Flag to enable/disable repair attempt for the component.") | ||
fs.StringVar(&hco.CriCtlPath, "crictl-path", types.DefaultCriCtl, | ||
"The path to the crictl binary. This is used to check health of cri component.") | ||
|
@@ -69,9 +76,9 @@ func (hco *HealthCheckerOptions) IsValid() error { | |
if hco.Component != types.KubeletComponent && hco.Component != types.DockerComponent && hco.Component != types.CRIComponent { | ||
return fmt.Errorf("the component specified is not supported. Supported components are : <kubelet/docker/cri>") | ||
} | ||
// Make sure the systemd service is specified if repair is enabled. | ||
if hco.EnableRepair && hco.SystemdService == "" { | ||
return fmt.Errorf("systemd-service cannot be empty when repair is enabled") | ||
// Make sure the service is specified if repair is enabled. | ||
if hco.EnableRepair && hco.Service == "" { | ||
return fmt.Errorf("service cannot be empty when repair is enabled") | ||
} | ||
// Skip checking further if the component is not cri. | ||
if hco.Component != types.CRIComponent { | ||
|
@@ -90,14 +97,14 @@ func (hco *HealthCheckerOptions) IsValid() error { | |
|
||
// SetDefaults sets the defaults values for the dependent flags. | ||
func (hco *HealthCheckerOptions) SetDefaults() { | ||
if hco.SystemdService != "" { | ||
if hco.Service != "" { | ||
return | ||
} | ||
if hco.Component != types.CRIComponent { | ||
hco.SystemdService = hco.Component | ||
hco.Service = hco.Component | ||
return | ||
} | ||
hco.SystemdService = types.ContainerdService | ||
hco.Service = types.ContainerdService | ||
} | ||
|
||
func init() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build !disable_system_log_monitor | ||
|
||
/* | ||
Copyright 2021 The Kubernetes Authors All rights reserved. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build !disable_system_log_monitor | ||
|
||
/* | ||
Copyright 2021 The Kubernetes Authors All rights reserved. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"plugin": "custom", | ||
"pluginConfig": { | ||
"invoke_interval": "10s", | ||
"timeout": "3m", | ||
"max_output_length": 80, | ||
"concurrency": 1 | ||
}, | ||
"source": "health-checker", | ||
"metricsReporting": true, | ||
"conditions": [ | ||
{ | ||
"type": "ContainerRuntimeUnhealthy", | ||
"reason": "ContainerRuntimeIsHealthy", | ||
"message": "Container runtime on the node is functioning properly" | ||
} | ||
], | ||
"rules": [ | ||
{ | ||
"type": "permanent", | ||
"condition": "ContainerRuntimeUnhealthy", | ||
"reason": "ContainerdUnhealthy", | ||
"path": "C:\\etc\\kubernetes\\node\\bin\\health-checker.exe", | ||
"args": [ | ||
"--component=cri", | ||
"--enable-repair=true", | ||
"--cooldown-time=2m", | ||
"--health-check-timeout=60s" | ||
], | ||
"timeout": "3m" | ||
} | ||
] | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"plugin": "custom", | ||
"pluginConfig": { | ||
"invoke_interval": "10s", | ||
"timeout": "3m", | ||
"max_output_length": 80, | ||
"concurrency": 1 | ||
}, | ||
"source": "health-checker", | ||
"metricsReporting": true, | ||
"conditions": [ | ||
{ | ||
"type": "ContainerRuntimeUnhealthy", | ||
"reason": "ContainerRuntimeIsHealthy", | ||
"message": "Container runtime on the node is functioning properly" | ||
} | ||
], | ||
"rules": [ | ||
{ | ||
"type": "permanent", | ||
"condition": "ContainerRuntimeUnhealthy", | ||
"reason": "DockerUnhealthy", | ||
"path": "C:\\etc\\kubernetes\\node\\bin\\health-checker.exe", | ||
"args": [ | ||
"--component=docker", | ||
"--enable-repair=true", | ||
"--cooldown-time=2m", | ||
"--health-check-timeout=60s" | ||
], | ||
"timeout": "3m" | ||
} | ||
] | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"plugin": "custom", | ||
"pluginConfig": { | ||
"invoke_interval": "10s", | ||
"timeout": "3m", | ||
"max_output_length": 80, | ||
"concurrency": 1 | ||
}, | ||
"source": "health-checker", | ||
"metricsReporting": true, | ||
"conditions": [ | ||
{ | ||
"type": "KubeletUnhealthy", | ||
"reason": "KubeletIsHealthy", | ||
"message": "kubelet on the node is functioning properly" | ||
} | ||
], | ||
"rules": [ | ||
{ | ||
"type": "permanent", | ||
"condition": "KubeletUnhealthy", | ||
"reason": "KubeletUnhealthy", | ||
"path": "C:\\etc\\kubernetes\\node\\bin\\health-checker.exe", | ||
"args": [ | ||
"--component=kubelet", | ||
"--enable-repair=true", | ||
"--cooldown-time=1m", | ||
"--health-check-timeout=10s" | ||
], | ||
"timeout": "3m" | ||
} | ||
] | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.