Skip to content

Instantly share code, notes, and snippets.

@sarjarapu
Created July 11, 2018 20:48
Show Gist options
  • Save sarjarapu/f6753dc926efb9cb008e08c8bd8a37ab to your computer and use it in GitHub Desktop.
Save sarjarapu/f6753dc926efb9cb008e08c8bd8a37ab to your computer and use it in GitHub Desktop.
A bash script showing the connectivity to the MongoDB replica set member using NodePort
kubectl -n ${K8_NAMESPACE} describe pod/mongodb-world-replicaset-0 | grep 'Node:'
# Node: 10.128.0.7
kubectl -n ${K8_NAMESPACE} get services
# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
# mongodb-world-replicaset-svc ClusterIP None <none> 27017/TCP 41m
# mongodb-world-replicaset-svc-external NodePort 10.43.252.153 <none> 27017:31750/TCP 41m
mongo --host 10.128.0.7 --port 31750
# MongoDB shell version v3.6.5
# connecting to: mongodb://mongodb-world-replicaset-0:27017/
# MongoDB server version: 3.6.5
# mongodb-world-replicaset:PRIMARY>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment