Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve the support.sh script. Secrets are now redacted. #294

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions support.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ mkdir -p "$OUTPUT_DIR"/cluster
# Grab stuff not returned by `get all`
for namespace in $(\kubectl get namespaces --output=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}')
do
# Get YAML for everything in the namespace
for resource_type in $(\kubectl api-resources --namespaced --verbs=list -o name | tr "\n" " ");
# Get YAML for everything in the namespace, except secrets. If more resources need to be excluded, add them to the grep list.
for resource_type in $(\kubectl api-resources --namespaced --verbs=list -o name | grep -Ewv "^(secrets)$" | tr "\n" " ");
do
mkdir -p "${OUTPUT_DIR}/namespaces/${namespace}"
\kubectl get -n "$namespace" "$resource_type" --show-kind --ignore-not-found -o yaml > "${OUTPUT_DIR}/namespaces/${namespace}"/"$resource_type".yaml
done

# Get secrets in the namespace. All data values will be redacted.
for secret in $(\kubectl get secrets -n "$namespace" -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}')
do
\kubectl get secret "$secret" -n "$namespace" -o json | jq '.data |= with_entries(.value = "--REDACTED--")' >> "${OUTPUT_DIR}/namespaces/${namespace}"/secrets.json
done

# Attempt to discover token and url for cloud-api in cluster
if [[ -z "$CALYPTIA_CLOUD_TOKEN" ]]; then
if \kubectl get --namespace "$namespace" secret auth-secret &>/dev/null; then
Expand Down
Loading