Skip to content

Commit dd22a19

Browse files
committed
Add csi-proxy monitoring to health checker
1 parent 228f0f5 commit dd22a19

File tree

7 files changed

+104
-9
lines changed

7 files changed

+104
-9
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ $(NPD_NAME_VERSION)-%.tar.gz: $(ALL_BINARIES) test/e2e-install.sh
214214
(cd output/$*/ && tar -zcvf ../../$@ *)
215215
sha512sum $@ > $@.sha512
216216

217+
windows-binaries: ENABLE_JOURNALD=0
218+
windows-binaries: $(foreach binary, $(BINARIES), output/windows_amd64/$(binary).exe)
219+
217220
build-binaries: $(ALL_BINARIES)
218221

219222
build-container: build-binaries Dockerfile

cmd/healthchecker/options/options.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ type HealthCheckerOptions struct {
4646

4747
// AddFlags adds health checker command line options to pflag.
4848
func (hco *HealthCheckerOptions) AddFlags(fs *pflag.FlagSet) {
49-
fs.StringVar(&hco.Component, "component", types.KubeletComponent,
50-
"The component to check health for. Supports kubelet, docker, kube-proxy, and cri")
49+
fs.StringVar(&hco.Component, "component", types.KubeletComponent, supportedComponentsFlagMessage)
5150
// Deprecated: For backward compatibility on linux environment. Going forward "service" will be used instead of systemd-service
5251
if runtime.GOOS == "linux" {
5352
fs.MarkDeprecated("systemd-service", "please use --service flag instead")
54-
fs.StringVar(&hco.Service, "systemd-service", "",
55-
"The underlying service responsible for the component. Set to the corresponding component for docker and kubelet, containerd for cri.")
53+
fs.StringVar(&hco.Service, "systemd-service", "", supportedServicesFlagMessage)
5654
}
57-
fs.StringVar(&hco.Service, "service", "",
58-
"The underlying service responsible for the component. Set to the corresponding component for docker and kubelet, containerd for cri.")
55+
fs.StringVar(&hco.Service, "service", "", supportedServicesFlagMessage)
5956
fs.BoolVar(&hco.EnableRepair, "enable-repair", true, "Flag to enable/disable repair attempt for the component.")
6057
fs.StringVar(&hco.CriCtlPath, "crictl-path", types.DefaultCriCtl,
6158
"The path to the crictl binary. This is used to check health of cri component.")
@@ -73,9 +70,16 @@ func (hco *HealthCheckerOptions) AddFlags(fs *pflag.FlagSet) {
7370
// Returns error if invalid, nil otherwise.
7471
func (hco *HealthCheckerOptions) IsValid() error {
7572
// Make sure the component specified is valid.
76-
if hco.Component != types.KubeletComponent && hco.Component != types.DockerComponent &&
77-
hco.Component != types.CRIComponent && hco.Component != types.KubeProxyComponent {
78-
return fmt.Errorf("the component specified is not supported. Supported components are : <kubelet/docker/cri/kube-proxy>")
73+
isSupportedComponents := hco.Component != types.KubeletComponent && hco.Component != types.DockerComponent &&
74+
hco.Component != types.CRIComponent && hco.Component != types.KubeProxyComponent
75+
if runtime.GOOS == "windows" {
76+
if isSupportedComponents && hco.Component != types.CsiProxyComponent {
77+
return fmt.Errorf(validComponentMessage)
78+
}
79+
} else {
80+
if isSupportedComponents {
81+
return fmt.Errorf(validComponentMessage)
82+
}
7983
}
8084
// Make sure the service is specified if repair is enabled.
8185
if hco.EnableRepair && hco.Service == "" {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package options
18+
19+
const (
20+
supportedComponentsFlagMessage = "The component to check health for. Supports kubelet, docker, kube-proxy, and cri"
21+
supportedServicesFlagMessage = "The underlying service responsible for the component. Set to the corresponding component for docker and kubelet, containerd for cri."
22+
validComponentMessage = "the component specified is not supported. Supported components are: <kubelet/docker/cri/kube-proxy>"
23+
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package options
18+
19+
const (
20+
supportedComponentsFlagMessage = "The component to check health for. Supports csiproxy, kubelet, docker, kube-proxy, and cri"
21+
supportedServicesFlagMessage = "The underlying service responsible for the component. Set to the corresponding component for csiproxy, docker, kubelet, containerd for cri."
22+
validComponentMessage = "the component specified is not supported. Supported components are: <kubelet/docker/cri/kube-proxy/csiproxy>"
23+
)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"plugin": "custom",
3+
"pluginConfig": {
4+
"invoke_interval": "10s",
5+
"timeout": "3m",
6+
"max_output_length": 80,
7+
"concurrency": 1
8+
},
9+
"source": "health-checker",
10+
"metricsReporting": true,
11+
"conditions": [
12+
{
13+
"type": "CsiProxyUnhealthy",
14+
"reason": "CsiProxyIsHealthy",
15+
"message": "Csi-Proxy on the node is functioning properly"
16+
}
17+
],
18+
"rules": [
19+
{
20+
"type": "permanent",
21+
"condition": "CsiProxyUnhealthy",
22+
"reason": "CsiProxyUnhealthy",
23+
"path": "C:\\etc\\kubernetes\\node\\bin\\health-checker.exe",
24+
"args": [
25+
"--component=csiproxy",
26+
"--enable-repair=true",
27+
"--cooldown-time=2m",
28+
"--health-check-timeout=60s"
29+
],
30+
"timeout": "3m"
31+
}
32+
]
33+
}
34+

pkg/healthchecker/health_checker_windows.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ func getHealthCheckFunc(hco *options.HealthCheckerOptions) func() (bool, error)
8585
}
8686
return true, nil
8787
}
88+
case types.CsiProxyComponent:
89+
return func() (bool, error) {
90+
if _, err := powershell("Get-Process csi-proxy"); err != nil {
91+
return false, nil
92+
}
93+
return true, nil
94+
}
8895
}
8996
return nil
9097
}

pkg/healthchecker/types/types_windows.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ const (
2121
DefaultCriSocketPath = "npipe:////./pipe/containerd-containerd"
2222
UptimeTimeLayout = "Mon 02 Jan 2006 15:04:05 MST"
2323
LogParsingTimeFormat = "yyyy-MM-dd HH:mm:ss"
24+
CsiProxyComponent = "csiproxy"
2425
)

0 commit comments

Comments
 (0)