Syntax

A google_container_clusters is used to test a Google Cluster resource

Beta Resource

This resource has beta fields available. To retrieve these fields, include beta: true in the constructor for the resource

Examples

describe google_container_clusters(project: 'chef-gcp-inspec', location: 'europe-west2-a') do
  its('cluster_names') { should include 'gcp-inspec-kube-cluster' }
end

Test that there are no more than a specified number of clusters available for the project in a particular zone

describe google_container_clusters(project: 'chef-inspec-gcp', location: 'europe-west2-a') do
  its('count') { should be <= 5}
end

Test that an expected cluster is available for the project

describe google_container_clusters(project: 'chef-inspec-gcp', location: 'europe-west2-a') do
  its('cluster_names') { should include "my-cluster" }
end

Test whether any clusters are in status “STOPPING”

describe google_container_clusters(project: 'chef-inspec-gcp', location: 'europe-west2-a') do
  its('cluster_statuses') { should_not include "STOPPING" }
end

Test that a subset of all clusters matching “kube*” are “RUNNING”

google_container_clusters(project: gcp_project_id).where(cluster_name: /^kube/).cluster_names.each do |cluster_name|
  describe google_container_cluster(project: 'chef-inspec-gcp', location: 'europe-west2-a', name: cluster_name) do
    it { should exist }
    its('status') { should eq 'RUNNING' }
  end
end

Properties

Properties that can be accessed from the google_container_clusters resource:

See googlecontainercluster.md for more detailed information * cluster_names: an array of google_container_cluster name * descriptions: an array of google_container_cluster description * initial_node_counts: an array of google_container_cluster initialnodecount * node_configs: an array of google_container_cluster nodeconfig * `masterauths: an array ofgooglecontainerclustermaster_auth *loggingservices: an array ofgooglecontainercluster` loggingservice * monitoring_services: an array of google_container_cluster monitoringservice * `clusternetworks: an array ofgooglecontainerclusternetwork *privateclusterconfigs: an array ofgooglecontainerclusterprivate_cluster_config *clusteripv4cidrs: an array ofgooglecontainerclustercluster_ipv4_cidr *enabletpus: an array ofgooglecontainercluster` enabletpu * tpu_ipv4_cidr_blocks: an array of google_container_cluster tpuipv4cidrblock * `addonsconfigs: an array ofgooglecontainerclusteraddons_config *subnetworks: an array ofgooglecontainerclustersubnetwork *locations: an array ofgooglecontainerclusterlocations *resourcelabels: an array ofgooglecontainercluster` resourcelabels * label_fingerprints: an array of google_container_cluster labelfingerprint * `legacyabacs: an array ofgooglecontainerclusterlegacy_abac *networkpolicies: an array ofgooglecontainercluster` networkpolicy * default_max_pods_constraints: an array of google_container_cluster defaultmaxpodsconstraint * `ipallocationpolicies: an array ofgooglecontainercluster` ipallocationpolicy * endpoints: an array of `googlecontainerclusterendpoint *initialclusterversions: an array ofgooglecontainercluster` initialclusterversion * `currentmasterversions: an array ofgooglecontainercluster` currentmasterversion * `currentnodeversions: an array ofgooglecontainercluster` currentnodeversion * `createtimes: an array ofgooglecontainerclustercreate_time *clusterstatuses: an array ofgooglecontainerclusterstatus *statusmessages: an array ofgooglecontainerclusterstatus_message *nodeipv4cidrsizes: an array ofgooglecontainercluster` nodeipv4cidrsize * services_ipv4_cidrs: an array of google_container_cluster servicesipv4cidr * current_node_counts: an array of google_container_cluster currentnodecount * expire_times: an array of google_container_cluster expiretime * conditions: an array of `googlecontainerclusterconditions *masterauthorizednetworksconfigs: an array ofgooglecontainerclustermaster_authorized_networks_config *nodepools: an array ofgooglecontainercluster` nodepools * pod_security_policy_configs: (Beta only) an array of google_container_cluster podsecuritypolicyconfig * `binaryauthorizations: an array ofgooglecontainerclusterbinary_authorization *locations: an array ofgooglecontainercluster` location

Filter Criteria

This resource supports all of the above properties as filter criteria, which can be used with where as a block or a method.

GCP Permissions

Ensure the Kubernetes Engine API is enabled for the current project.