Skip to content

Instantly share code, notes, and snippets.

@jamesholcomb
Created February 22, 2019 03:31
Show Gist options
  • Save jamesholcomb/1a1d968d3e3bdd7d80060090ecc122bf to your computer and use it in GitHub Desktop.
Save jamesholcomb/1a1d968d3e3bdd7d80060090ecc122bf to your computer and use it in GitHub Desktop.
outputs the mongodb replica set master host name in a Kubernetes cluster
kubectl exec db-mongodb-replicaset-0 -- sh -c 'mongo --quiet --eval="printjson(rs.isMaster().primary)"' | sed 's/"//g' | awk -F\. '{print $1}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment