Skip to content

Unable to query cluster-wide resources using k8sobject #34

@jrbeilke

Description

@jrbeilke

For cluster-wide resources that do not have a namespace it doesn't seem possible to query them using k8sobject()

Describe the problem

Attempting to test StorageClasses in a cluster ie.

describe k8sobject({:api=>"storage.k8s.io/v1", :type=>"storageclasses", :name=>"ebs-sc"}) do
  it { should exist }
end

But it appears that inspec-k8s adds the default namespace when querying the cluster and this fails because StorageClass is a cluster-wide resource:
Resource storageclasses is not namespaced

I also tried passing in a nil for the namespace, but that resulted in the same error:
{:api=>"storage.k8s.io/v1", :type=>"storageclasses", :namespace=>nil, :name=>"ebs-sc"}

Possible Solution

There is already support for some cluster-wide resources like k8s_node which extends k8sobject and overrides the namespace ie.

    class K8sNode < K8sObject
      DEFAULT_NAMESPACE = nil

It would be nice to have a flag or param that could be used with k8sobject to query cluster-wide resources and not inject the default namespace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions