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
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.
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 namespacedI also tried passing in a
nilfor 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.
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
defaultnamespace