Skip to content

Instantly share code, notes, and snippets.

@linktohack
Last active July 5, 2022 07:56
Embed
What would you like to do?
KUBERNETES List all ingress
k get ingress -A --output json | jq '
def pad(n): tostring | if length >= n then . else ([range(n-length) | "0"] | join("")) + . end;
.items
| sort_by(.metadata.namespace)
| map({ ns: .metadata.namespace, name: .spec.rules[].http.paths[].backend.service.name, host: .spec.rules[].host, path: .spec.rules[].http.paths[].path })
| to_entries
| map({ name: [.value.ns, .value.name, .key | pad(2)] | join("-"), url: ["https://", .value.host, .value.path] | join("") })
| map(select(.url | contains("*") | not))
| unique_by(.url)
| sort_by(.name)
' | yq -y
k get ing -A -o json | jq '[ .items[] | {
namespace: .metadata.namespace,
host: .spec.rules[].host,
path: .spec.rules[].http.paths[].path,
service: .spec.rules[].http.paths[].backend.service.name
} ] | group_by(.namespace)' | yq -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment