title | platform |
---|---|
About the google_container_node_pools Resource |
gcp |
Use the google_container_node_pools
InSpec audit resource to test properties of all, or a filtered group of, GCP container node_pools for a project, cluster and zone.
A google_container_node_pools
resource block collects GCP node pools by project, cluster and zone then tests that group.
describe google_container_node_pools(project: 'chef-inspec-gcp', zone: 'europe-west2-a', cluster_name: 'inspec-gcp-cluster') do
it { should exist }
end
Use this InSpec resource to enumerate IDs then test in-depth using google_container_node_pool
.
google_container_node_pools(project: 'chef-inspec-gcp', zone: 'europe-west2-a', cluster_name: 'inspec-gcp-cluster').node_pool_names.each do |node_pool_name|
describe google_container_node_pool(project: 'chef-inspec-gcp', zone: 'europe-west2-a', cluster_name: 'inspec-gcp-cluster', nodepool_name: node_pool_name) do
it { should exist }
its('status') { should eq 'RUNNING' }
end
end
The following examples show how to use this InSpec audit resource.
describe google_container_node_pools(project: 'chef-inspec-gcp') do
its('count') { should be <= 10}
end
describe google_container_node_pools(project: 'chef-inspec-gcp') do
its('node_pool_names') { should include "us-east1-b" }
end
google_container_node_pools(project: 'chef-inspec-gcp', zone: 'europe-west2-a', cluster_name: 'inspec-gcp-cluster').where(node_pool_name: /^mypool/).node_pool_names.each do |node_pool_name|
describe google_container_node_pool(project: 'chef-inspec-gcp', zone: 'europe-west2-a', cluster_name: 'inspec-gcp-cluster', nodepool_name: node_pool_name) do
it { should exist }
its('status') { should eq 'RUNNING' }
end
end
This resource supports the following filter criteria: node_pool_name
and node_pool_status
. Any of these may be used with where
, as a block or as a method.
node_pool_names
- an array of google_container_node_pool name stringsnode_pool_statuses
- an array of google_container_node_pool status stringss
Ensure the Kubernetes Engine API is enabled for the project where the resource is located.