1
0
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:
nshauli 2019-02-19 16:38:10 +02:00
parent da09e6513a
commit e93bfc1aac

View File

@ -289,6 +289,12 @@ func getKubeVersion() (string, error) {
if err != nil {
_, err = exec.LookPath("kubelet")
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 getKubeVersionFromKubelet(), nil