Skip to content

Commit

Permalink
Fix describe-kubernetes-objects role
Browse files Browse the repository at this point in the history
According to [0] kubectl get all -A does not include all types (e.g.
configmaps) and is going to be deprecated. Instead of getting all
objects with one kubectl request, doing the same for each object type
separately.

[0] kubernetes/kubectl#151

Change-Id: I624e785b95e0c5697a567251b42855545d771179
Signed-off-by: Andrii Ostapenko <andrii.ostapenko@att.com>
  • Loading branch information
aostapenko committed Oct 24, 2020
1 parent 81efbce commit cd1ca0b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
export CONTEXT={{ kctl_context | default("dummy_cluster") }}
kubectl config use-context ${CONTEXT}
export OBJECT_TYPE="{{ collect_namespaced_objects | join(',') }}"
export ALL_OBJECTS_YAML_FILE=$(tempfile)
kubectl get all -A -oyaml > ${ALL_OBJECTS_YAML_FILE}
export TMP_DIR=$(mktemp -d)
export PARALLELISM_FACTOR=2
printf ${OBJECT_TYPE} | xargs -d ',' -I {} -P ${PARALLELISM_FACTOR} -n1 bash -c 'kubectl get -A -oyaml "$@" > ${TMP_DIR}/"$@".yaml' _ {}
function get_namespaces () {
kubectl get namespaces -o name | awk -F '/' '{ print $NF }'
Expand Down Expand Up @@ -97,7 +97,7 @@
echo "${NAMESPACE}/${OBJECT}/${NAME}"
DIR="{{ logs_dir }}/objects/${CONTEXT}/namespaced/${NAMESPACE}/${OBJECT}"
mkdir -p ${DIR}
cat "${ALL_OBJECTS_YAML_FILE}" | kustomize cfg grep "metadata.namespace=${NAMESPACE}" | kustomize cfg grep "metadata.name=${OBJECT}" > "${DIR}/${NAME}.yaml"
cat "${TMP_DIR}/${OBJECT}.yaml" | kustomize cfg grep "metadata.namespace=${NAMESPACE}" | kustomize cfg grep "metadata.name=${NAME}" > "${DIR}/${NAME}.yaml"
kubectl describe -n ${NAMESPACE} ${OBJECT} ${NAME} > "${DIR}/${NAME}.txt"
}
export -f get_objects
Expand Down

0 comments on commit cd1ca0b

Please sign in to comment.