1
0
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:
Liz Rice 2019-02-19 16:07:20 +00:00 committed by GitHub
commit c824daeb15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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