Skip to content

Instantly share code, notes, and snippets.

@howardjohn
Created February 10, 2022 17:55
Show Gist options
  • Save howardjohn/803099c796a235563ed2e63f96d0b203 to your computer and use it in GitHub Desktop.
Save howardjohn/803099c796a235563ed2e63f96d0b203 to your computer and use it in GitHub Desktop.
Consumer vs producer
# This script checks which virtual services are creating in producer namespaces (eg defining a VirtualService for a Service I own) vs in consumer namespce (defining a VirtualService for a Service in another namespace).
# Raw results
kubectl get vs -A -ojson | jq '.items[] | {match: (.spec.hosts[] | select(. | contains(".svc.cluster.local")) | split(".")[1]), ns: .metadata.namespace}' -c
# Just get the counts
kubectl get vs -A -ojson | jq '[.items[] | {match: (.spec.hosts[] | select(. | contains(".svc.cluster.local")) | split(".")[1]), ns: .metadata.namespace}] | group_by(.match == .ns)| map(length) | "Consumer: " + (.[0] | tostring) + "\nProducer: " + (.[1] | tostring)' -r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment