Skip to content

Instantly share code, notes, and snippets.

@linktohack
Last active July 5, 2022 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linktohack/b3fafbce53eabed611e97d3d64366025 to your computer and use it in GitHub Desktop.
Save linktohack/b3fafbce53eabed611e97d3d64366025 to your computer and use it in GitHub Desktop.
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