Skip to content

Instantly share code, notes, and snippets.

@sumanthkumarc
Last active October 17, 2020 06:53
Show Gist options
  • Save sumanthkumarc/8216c00a9d98834f0eedd833696ea04c to your computer and use it in GitHub Desktop.
Save sumanthkumarc/8216c00a9d98834f0eedd833696ea04c to your computer and use it in GitHub Desktop.
# Make target
port-forward:
while true; do \
kubectl port-forward -n my-ns service/mongodb-0 27017:27017 & \
kubectl port-forward -n my-ns service/mongodb-1 27011:27017 & \
kubectl port-forward -n my-ns service/mongodb-2 27012:27017 & \
kubectl port-forward -n my-ns service/mongodb-3 27013:27017 & \
kubectl port-forward -n my-ns service/mongodb-arbiter-0 27014:27017 \
done;
# Shell command
(trap 'kill 0' INT; kubectl -n my-ns port-forward service/mongodb-0 27017:27017 & kubectl -n my-ns port-forward service/mongodb-1 27011:27017 & kubectl port-forward -n my-ns service/mongodb-2 27012:27017 & kubectl port-forward -n my-ns service/mongodb-3 27013:27017 & kubectl port-forward -n my-ns service/mongodb-arbiter-0 27014:27017)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment