cluster/gce/list-resources.sh: also list stackdriver logging sinks

This commit is contained in:
Jeff Grafton 2018-03-16 16:22:46 -07:00
parent ca02c11887
commit 3bf83deff2

View File

@ -38,17 +38,18 @@ if [[ "${KUBERNETES_PROVIDER:-}" == "gke" ]]; then
INSTANCE_PREFIX="${INSTANCE_PREFIX:0:26}" INSTANCE_PREFIX="${INSTANCE_PREFIX:0:26}"
fi fi
# Usage: gcloud-compute-list <resource> <additional parameters to gcloud...> # Usage: gcloud-list <group> <resource> <additional parameters to gcloud...>
# GREP_REGEX is applied to the output of gcloud if set # GREP_REGEX is applied to the output of gcloud if set
GREP_REGEX="" GREP_REGEX=""
function gcloud-compute-list() { function gcloud-list() {
local -r resource=$1 local -r group=$1
local -r filter=${2:-} local -r resource=$2
echo -e "\n\n[ ${resource} ]" local -r filter=${3:-}
echo -e "\n\n[ ${group} ${resource} ]"
local attempt=1 local attempt=1
local result="" local result=""
while true; do while true; do
if result=$(gcloud compute ${resource} list --project=${PROJECT} ${filter:+--filter="$filter"} ${@:3}); then if result=$(gcloud ${group} ${resource} list --project=${PROJECT} ${filter:+--filter="$filter"} ${@:4}); then
if [[ ! -z "${GREP_REGEX}" ]]; then if [[ ! -z "${GREP_REGEX}" ]]; then
result=$(echo "${result}" | grep "${GREP_REGEX}" || true) result=$(echo "${result}" | grep "${GREP_REGEX}" || true)
fi fi
@ -74,21 +75,23 @@ echo "Provider: ${KUBERNETES_PROVIDER:-}"
# List resources related to instances, filtering by the instance prefix if # List resources related to instances, filtering by the instance prefix if
# provided. # provided.
gcloud-compute-list instance-templates "name ~ '${INSTANCE_PREFIX}.*'" gcloud-list compute instance-templates "name ~ '${INSTANCE_PREFIX}.*'"
gcloud-compute-list instance-groups "${ZONE:+"zone:(${ZONE}) AND "}name ~ '${INSTANCE_PREFIX}.*'" gcloud-list compute instance-groups "${ZONE:+"zone:(${ZONE}) AND "}name ~ '${INSTANCE_PREFIX}.*'"
gcloud-compute-list instances "${ZONE:+"zone:(${ZONE}) AND "}name ~ '${INSTANCE_PREFIX}.*'" gcloud-list compute instances "${ZONE:+"zone:(${ZONE}) AND "}name ~ '${INSTANCE_PREFIX}.*'"
# List disk resources, filtering by instance prefix if provided. # List disk resources, filtering by instance prefix if provided.
gcloud-compute-list disks "${ZONE:+"zone:(${ZONE}) AND "}name ~ '${INSTANCE_PREFIX}.*'" gcloud-list compute disks "${ZONE:+"zone:(${ZONE}) AND "}name ~ '${INSTANCE_PREFIX}.*'"
# List network resources. We include names starting with "a", corresponding to # List network resources. We include names starting with "a", corresponding to
# those that Kubernetes creates. # those that Kubernetes creates.
gcloud-compute-list addresses "${REGION:+"region=(${REGION}) AND "}name ~ 'a.*|${INSTANCE_PREFIX}.*'" gcloud-list compute addresses "${REGION:+"region=(${REGION}) AND "}name ~ 'a.*|${INSTANCE_PREFIX}.*'"
# Match either the header or a line with the specified e2e network. # Match either the header or a line with the specified e2e network.
# This assumes that the network name is the second field in the output. # This assumes that the network name is the second field in the output.
GREP_REGEX="^NAME\|^[^ ]\+[ ]\+\(default\|${NETWORK}\) " GREP_REGEX="^NAME\|^[^ ]\+[ ]\+\(default\|${NETWORK}\) "
gcloud-compute-list routes "name ~ 'default.*|${INSTANCE_PREFIX}.*'" gcloud-list compute routes "name ~ 'default.*|${INSTANCE_PREFIX}.*'"
gcloud-compute-list firewall-rules "name ~ 'default.*|k8s-fw.*|${INSTANCE_PREFIX}.*'" gcloud-list compute firewall-rules "name ~ 'default.*|k8s-fw.*|${INSTANCE_PREFIX}.*'"
GREP_REGEX="" GREP_REGEX=""
gcloud-compute-list forwarding-rules ${REGION:+"region=(${REGION})"} gcloud-list compute forwarding-rules ${REGION:+"region=(${REGION})"}
gcloud-compute-list target-pools ${REGION:+"region=(${REGION})"} gcloud-list compute target-pools ${REGION:+"region=(${REGION})"}
gcloud-list logging sinks