-
Notifications
You must be signed in to change notification settings - Fork 676
Add healthChecker functionality for kube-proxy service #552
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 |
---|---|---|
@@ -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": "KubeProxyUnhealthy", | ||
"reason": "KubeProxyIsHealthy", | ||
"message": "kube-proxy on the node is functioning properly" | ||
} | ||
], | ||
"rules": [ | ||
{ | ||
"type": "permanent", | ||
"condition": "KubeProxyUnhealthy", | ||
"reason": "KubeProxyUnhealthy", | ||
"path": "C:\\etc\\kubernetes\\node\\bin\\health-checker.exe", | ||
"args": [ | ||
"--component=kube-proxy", | ||
"--enable-repair=true", | ||
"--cooldown-time=1m", | ||
"--health-check-timeout=10s" | ||
], | ||
"timeout": "3m" | ||
} | ||
] | ||
} | ||
|
||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,14 +68,9 @@ func getRepairFunc(hco *options.HealthCheckerOptions) func() { | |
func getHealthCheckFunc(hco *options.HealthCheckerOptions) func() (bool, error) { | ||
switch hco.Component { | ||
case types.KubeletComponent: | ||
return func() (bool, error) { | ||
httpClient := http.Client{Timeout: hco.HealthCheckTimeout} | ||
response, err := httpClient.Get(types.KubeletHealthCheckEndpoint) | ||
if err != nil || response.StatusCode != http.StatusOK { | ||
return false, nil | ||
} | ||
return true, nil | ||
} | ||
return healthCheckEndpointOKFunc(types.KubeletHealthCheckEndpoint, hco.HealthCheckTimeout) | ||
case types.KubeProxyComponent: | ||
return healthCheckEndpointOKFunc(types.KubeProxyHealthCheckEndpoint, hco.HealthCheckTimeout) | ||
case types.DockerComponent: | ||
return func() (bool, error) { | ||
if _, err := execCommand("docker.exe", "ps"); err != nil { | ||
|
@@ -94,6 +89,18 @@ func getHealthCheckFunc(hco *options.HealthCheckerOptions) func() (bool, error) | |
return nil | ||
} | ||
|
||
// healthCheckEndpointOKFunc returns a function to check the status of an http endpoint | ||
func healthCheckEndpointOKFunc(endpoint string, timeout time.Duration) func() (bool, error) { | ||
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. Seems like a missed opportunity to not make this generic health check through config. IE remove the hardcoded addresses and pass that in as a json argument. /cc @Random-Liu what do you 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.
Yeah, we thought about introducing the Kubernetes like "healthiness probe": Exec probe + http probe. The only problem is that the health checker is already a plugin of NPD, and now we need another layer of plugin. :P Some design is needed here. Please feel free to suggest ideas or propose a design for this, but that doesn't necessarily need to block this change. |
||
return func() (bool, error) { | ||
httpClient := http.Client{Timeout: timeout} | ||
response, err := httpClient.Get(endpoint) | ||
if err != nil || response.StatusCode != http.StatusOK { | ||
return false, nil | ||
} | ||
return true, nil | ||
} | ||
} | ||
|
||
// execCommand creates a new process, executes the command, and returns the (output, error) from command. | ||
func execCommand(command string, args ...string) (string, error) { | ||
cmd := util.Exec(command, args...) | ||
|
Uh oh!
There was an error while loading. Please reload this page.