mirror of
https://github.com/aquasecurity/kube-bench.git
synced 2024-12-20 05:38:13 +00:00
Merge pull request #222 from nshauli/search_for_kubelet_binary_when_not_in_path
search for the kubelet binary when it is not in the path
This commit is contained in:
commit
c824daeb15
@ -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