0

尝试使用 inspec 开始测试 kubernetes:https ://github.com/bgeesaman/inspec-k8s

我从这里找到的图像运行它makedockerhttps: //github.com/bgeesaman/inspec-k8s-sample

我有多个eks集群和一个本地docker-desktop集群。当我尝试通过以下方式连接到它们中的任何一个时:(inspec exec . -t k8s://docker-desktop将 kubeconfig -name: xxx 与放在后面的值匹配k8s://)我总是得到同样的错误:

# inspec exec -t k8s://docker-desktop
Traceback (most recent call last):
        20: from /usr/local/bundle/bin/inspec:23:in `<main>'
        19: from /usr/local/bundle/bin/inspec:23:in `load'
        18: from /usr/local/bundle/gems/inspec-bin-4.18.51/bin/inspec:11:in `<top (required)>'
        17: from /usr/local/bundle/gems/inspec-4.18.51/lib/inspec/base_cli.rb:35:in `start'
        16: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        15: from /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        14: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        13: from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        12: from /usr/local/bundle/gems/inspec-4.18.51/lib/inspec/cli.rb:284:in `exec'
        11: from /usr/local/bundle/gems/inspec-4.18.51/lib/inspec/cli.rb:284:in `new'
        10: from /usr/local/bundle/gems/inspec-4.18.51/lib/inspec/runner.rb:78:in `initialize'
         9: from /usr/local/bundle/gems/inspec-4.18.51/lib/inspec/runner.rb:86:in `configure_transport'
         8: from /usr/local/bundle/gems/inspec-4.18.51/lib/inspec/backend.rb:53:in `create'
         7: from /usr/local/bundle/gems/train-kubernetes-0.1.6/lib/train-kubernetes/transport.rb:9:in `connection'
         6: from /usr/local/bundle/gems/train-kubernetes-0.1.6/lib/train-kubernetes/transport.rb:9:in `new'
         5: from /usr/local/bundle/gems/train-kubernetes-0.1.6/lib/train-kubernetes/connection.rb:13:in `initialize'
         4: from /usr/local/bundle/gems/train-kubernetes-0.1.6/lib/train-kubernetes/connection.rb:36:in `parse_kubeconfig'
         3: from /usr/local/bundle/gems/k8s-ruby-0.10.5/lib/k8s/client.rb:40:in `config'
         2: from /usr/local/bundle/gems/k8s-ruby-0.10.5/lib/k8s/transport.rb:81:in `config'
         1: from /usr/local/bundle/gems/k8s-ruby-0.10.5/lib/k8s/transport.rb:117:in `token_from_exec'
/usr/local/bundle/gems/k8s-ruby-0.10.5/lib/k8s/transport.rb:117:in ``': No such file or directory - aws (Errno::ENOENT)

我认为这是因为ekskubeconfigs 链接到了 aws 配置文件。但是对于 docker-desktop 我也遇到了同样的错误。

我尝试更新Makefile COMMANDCOMMAND=docker run --rm -it -v pwd:$(WORKDIR) -v $(HOME)/.kube:/root/.kube:ro -v $(HOME)/.aws:/root/.aws:ro

错误结束后,No such file or directory - aws但没有喜悦。

任何想法如何解决或进步?

谢谢

小更新,它确实在确保名称正确后开始运行。但后来又停了。。

我已连接到 docker-desktop(我最初运行它时它没有运行)我已连接到 eks 集群

我做了一个vi controls/basic.rb开始寻找我的测试,它又开始出错了。

我认为由于我的更改存在语法问题,它可能会出错,所以make build现在做了一个新的但仍然没有乐趣:(

我也尝试将 chef/inspec 图像更新到最新的 4.26,但这会破坏 dockerfile,因为它apk不再有。

4

1 回答 1

1

好的,我不明白,但我可以让它运行:

它看起来与使用kubectx. 如果我设置kubectxdocker-desktop然后运行 ​​docker 映像,它就可以工作。如果我设置为其他任何东西,它不会。

于 2021-02-26T11:28:28.377 回答