0

trying to get started testing kubernetes with inspec using: https://github.com/bgeesaman/inspec-k8s

Im running it from the make and docker image found here: https://github.com/bgeesaman/inspec-k8s-sample

I have multiple eks clusters and a local docker-desktop cluster. When i try and connect to any of them via: inspec exec . -t k8s://docker-desktop (Matching the kubeconfig -name: xxx to the value put after k8s://) I always get the same error:

# 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)

I thought it was because of eks kubeconfigs being linked to the aws profile. But i get the same error for docker-desktop as well.

I tried updating the Makefile COMMAND with: COMMAND=docker run --rm -it -v pwd:$(WORKDIR) -v $(HOME)/.kube:/root/.kube:ro -v $(HOME)/.aws:/root/.aws:ro

After the error ends with No such file or directory - aws but no joy.

Any ideas how to resolve or progress?

Thanks

Small update, It did start running after making sure names where correct. But then stopped again..

I had connected to docker-desktop (It wasnt running when i orginally ran it) I had connected to an eks cluster

I did a vi controls/basic.rb to start looking playing with my tests and it started erroring again.

I thought it might error due to a syntax problem with my changes so did a new make build but still no joy now :(

I have also tried updating the chef/inspec image to the latest 4.26 but this breaks the dockerfile as it doesnt have apk anymore.

Staggerlee011
  • 847
  • 2
  • 13
  • 23

1 Answers1

1

Ok, i dont get it but i can get it to run:

It looks to be linked to im using kubectx. If i set kubectx to docker-desktop and then run the docker image it works. If im set to anything else it doesnt.

Staggerlee011
  • 847
  • 2
  • 13
  • 23