mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-12-23 15:18:07 +00:00
search for the kubelet binary when it is not in the path
This commit is contained in:
parent
da09e6513a
commit
e93bfc1aac
@ -289,6 +289,12 @@ func getKubeVersion() (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
_, err = exec.LookPath("kubelet")
|
_, err = exec.LookPath("kubelet")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Search for the kubelet binary all over the filesystem and run the first match to get the kubernetes version
|
||||||
|
cmd := exec.Command("/bin/sh", "-c", "`find / -type f -executable -name kubelet 2>/dev/null | grep -m1 .` --version")
|
||||||
|
out, err := cmd.CombinedOutput()
|
||||||
|
if err == nil {
|
||||||
|
return getVersionFromKubeletOutput(string(out)), nil
|
||||||
|
}
|
||||||
return "", fmt.Errorf("need kubectl or kubelet binaries to get kubernetes version")
|
return "", fmt.Errorf("need kubectl or kubelet binaries to get kubernetes version")
|
||||||
}
|
}
|
||||||
return getKubeVersionFromKubelet(), nil
|
return getKubeVersionFromKubelet(), nil
|
||||||
|
Loading…
Reference in New Issue
Block a user