diff --git a/image/cli/mascli/functions/must_gather b/image/cli/mascli/functions/must_gather index bc4aa17d23..dcc294630b 100644 --- a/image/cli/mascli/functions/must_gather +++ b/image/cli/mascli/functions/must_gather @@ -16,6 +16,7 @@ Collection Options (Optional): --no-pod-logs Skip collection of pod logs, greatly speeds up must-gather collection time when pod logs are not required --mas-instance-ids Collects the data for the specifed MAS instances, if not specified will collect for all MAS instances on the cluster --secret-data Collects also the content of the secrets + --extra-namespaces Collects data for additional namespaces, like ibm-common-services or db2u, must be separated by a coma Artifactory Upload (Optional): --artifactory-token ${COLOR_YELLOW}ARTIFACTORY_TOKEN${TEXT_RESET} Provide a token for Artifactory to automatically upload the file to ARTIFACTORY_UPLOAD_DIR @@ -37,6 +38,7 @@ function mustgather() { POD_LOGS=true SECRET_DATA=false MG_DIR=/tmp/must-gather + EXTRA_NAMESPACES="" # If a /must-gather directory exists, default to that as the output directory instead if [[ -d "/must-gather" ]]; then @@ -61,6 +63,9 @@ function mustgather() { --mas-instance-ids) MAS_INSTANCE_IDS=$1; shift ;; + --extra-namespaces) + EXTRA_NAMESPACES=$1; shift + ;; --secret-data) SECRET_DATA=true ;; @@ -160,6 +165,25 @@ function mustgather() { $MG_SCRIPT_DIR/mg-collect-mongoce $MONGOCE_NAMESPACE $OUTPUT_DIR done + if [[ "$EXTRA_NAMESPACES" != "" ]] + then + for EXTRA_NAMESPACE in $(echo $EXTRA_NAMESPACES | tr "," " ") + do + echo_h2 "${EXTRA_NAMESPACE}" + # Generic Kubernetes must-gather + if [[ "$SUMMARY_ONLY" == false ]] + then + $MG_SCRIPT_DIR/mg-collect-extra-namespace $EXTRA_NAMESPACE $OUTPUT_DIR + $MG_SCRIPT_DIR/mg-collect-pods $EXTRA_NAMESPACE $POD_LOGS $OUTPUT_DIR/resources + for RESOURCE in configmaps services routes pvc deployments statefulsets jobs operatorconditions clusterserviceversions installplans subscriptions serviceaccounts roles rolebindings + do + $MG_SCRIPT_DIR/mg-collect-resources -n $EXTRA_NAMESPACE -r $RESOURCE -d $OUTPUT_DIR/resources + done + $MG_SCRIPT_DIR/mg-collect-secrets -n $EXTRA_NAMESPACE -r $RESOURCE -d $OUTPUT_DIR/resources -s $SECRET_DATA + fi + done + fi + if [[ -z $MAS_INSTANCE_IDS ]] then # Find MAS instances diff --git a/image/cli/mascli/must-gather/mg-collect-extra-namespace b/image/cli/mascli/must-gather/mg-collect-extra-namespace new file mode 100644 index 0000000000..c15f12d3a1 --- /dev/null +++ b/image/cli/mascli/must-gather/mg-collect-extra-namespace @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +NAMESPACE=$1 +OUTPUT_DIR=$2 + +# Get a list of custom resources that are provided by IBM + +RESOURCES=$(oc get -n $NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') + +# Collect Custom Resources +# ----------------------------------------------------------------------------- + +for RESOURCE in ${RESOURCES[@]}; do + + $DIR/mg-collect-resources -n $NAMESPACE -r $RESOURCE -d $OUTPUT_DIR/resources + +done + +exit 0 \ No newline at end of file diff --git a/image/cli/mascli/must-gather/mg-collect-mas-add b/image/cli/mascli/must-gather/mg-collect-mas-add index c4b9695e7b..f2ca62b9d8 100644 --- a/image/cli/mascli/must-gather/mg-collect-mas-add +++ b/image/cli/mascli/must-gather/mg-collect-mas-add @@ -6,7 +6,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" NAMESPACE=$1 OUTPUT_DIR=$2 -RESOURCES=$(oc get -n NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') +RESOURCES=$(oc get -n $NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') # Collect Custom Resources # ----------------------------------------------------------------------------- diff --git a/image/cli/mascli/must-gather/mg-collect-mas-assist b/image/cli/mascli/must-gather/mg-collect-mas-assist index c4b9695e7b..f2ca62b9d8 100644 --- a/image/cli/mascli/must-gather/mg-collect-mas-assist +++ b/image/cli/mascli/must-gather/mg-collect-mas-assist @@ -6,7 +6,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" NAMESPACE=$1 OUTPUT_DIR=$2 -RESOURCES=$(oc get -n NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') +RESOURCES=$(oc get -n $NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') # Collect Custom Resources # ----------------------------------------------------------------------------- diff --git a/image/cli/mascli/must-gather/mg-collect-mas-monitor b/image/cli/mascli/must-gather/mg-collect-mas-monitor index c4b9695e7b..f2ca62b9d8 100644 --- a/image/cli/mascli/must-gather/mg-collect-mas-monitor +++ b/image/cli/mascli/must-gather/mg-collect-mas-monitor @@ -6,7 +6,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" NAMESPACE=$1 OUTPUT_DIR=$2 -RESOURCES=$(oc get -n NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') +RESOURCES=$(oc get -n $NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') # Collect Custom Resources # ----------------------------------------------------------------------------- diff --git a/image/cli/mascli/must-gather/mg-collect-mas-optimizer b/image/cli/mascli/must-gather/mg-collect-mas-optimizer index c4b9695e7b..f2ca62b9d8 100644 --- a/image/cli/mascli/must-gather/mg-collect-mas-optimizer +++ b/image/cli/mascli/must-gather/mg-collect-mas-optimizer @@ -6,7 +6,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" NAMESPACE=$1 OUTPUT_DIR=$2 -RESOURCES=$(oc get -n NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') +RESOURCES=$(oc get -n $NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') # Collect Custom Resources # ----------------------------------------------------------------------------- diff --git a/image/cli/mascli/must-gather/mg-collect-mas-predict b/image/cli/mascli/must-gather/mg-collect-mas-predict index c4b9695e7b..f2ca62b9d8 100644 --- a/image/cli/mascli/must-gather/mg-collect-mas-predict +++ b/image/cli/mascli/must-gather/mg-collect-mas-predict @@ -6,7 +6,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" NAMESPACE=$1 OUTPUT_DIR=$2 -RESOURCES=$(oc get -n NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') +RESOURCES=$(oc get -n $NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') # Collect Custom Resources # ----------------------------------------------------------------------------- diff --git a/image/cli/mascli/must-gather/mg-collect-mas-visualinspection b/image/cli/mascli/must-gather/mg-collect-mas-visualinspection index c4b9695e7b..f2ca62b9d8 100644 --- a/image/cli/mascli/must-gather/mg-collect-mas-visualinspection +++ b/image/cli/mascli/must-gather/mg-collect-mas-visualinspection @@ -6,7 +6,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" NAMESPACE=$1 OUTPUT_DIR=$2 -RESOURCES=$(oc get -n NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') +RESOURCES=$(oc get -n $NAMESPACE $(oc get crd -o=custom-columns=NAME:.metadata.name | grep ibm | tr '\n' ',' | rev |cut -c2- | rev ) -o jsonpath='{ .items[*].kind}' | tr ' ' '\n' | sort | uniq | tr '\n' ' ') # Collect Custom Resources # -----------------------------------------------------------------------------