Created
February 10, 2022 17:55
-
-
Save howardjohn/803099c796a235563ed2e63f96d0b203 to your computer and use it in GitHub Desktop.
Consumer vs producer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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