From 529e38594330ea024a90b82e0372b40f9da8f665 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Wed, 6 Apr 2016 11:08:38 -0700 Subject: [PATCH] fix(scripts): fix kube-up.sh creating multiple iptables rules --- scripts/kube-up.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/kube-up.sh b/scripts/kube-up.sh index 6977222ea..0a08b0f8f 100755 --- a/scripts/kube-up.sh +++ b/scripts/kube-up.sh @@ -62,8 +62,10 @@ setup_iptables() { echo "Adding iptables hackery for docker-machine..." local machine_ip=$(docker-machine ip "$machine") - if ! docker-machine ssh "${machine}" "sudo /usr/local/sbin/iptables -t nat -L -n" | grep -q "${machine_ip}" | grep -q ":${KUBE_PORT}"; then - docker-machine ssh "${machine}" "sudo /usr/local/sbin/iptables -t nat -I PREROUTING -p tcp -d ${machine_ip} --dport ${KUBE_PORT} -j DNAT --to-destination 127.0.0.1:${KUBE_PORT}" + local iptables_rule="PREROUTING -p tcp -d ${machine_ip} --dport ${KUBE_PORT} -j DNAT --to-destination 127.0.0.1:${KUBE_PORT}" + + if ! docker-machine ssh "${machine}" "sudo /usr/local/sbin/iptables -t nat -C ${iptables_rule}"; then + docker-machine ssh "${machine}" "sudo /usr/local/sbin/iptables -t nat -I ${iptables_rule}" fi }