Skip to content

Commit 6572fe4

Browse files
authored
Merge pull request kubernetes#100550 from dims/add-new-iptables-rule-for-local-up-cluster.sh
Add new iptables rule for local-up-cluster.sh
2 parents e33a80b + 44d143f commit 6572fe4

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

hack/local-up-cluster.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ cleanup()
378378
if [[ "${PRESERVE_ETCD}" == "false" ]]; then
379379
[[ -n "${ETCD_DIR-}" ]] && kube::etcd::clean_etcd_dir
380380
fi
381+
382+
# Drop the rule we added
383+
iptables -t nat -D OUTPUT -m addrtype --dst-type LOCAL -j DOCKER || true
381384
exit 0
382385
}
383386

@@ -1094,8 +1097,17 @@ if [[ "${START_MODE}" != "kubeletonly" ]]; then
10941097
kube::etcd::validate
10951098
fi
10961099

1097-
if [ "${CONTAINER_RUNTIME}" == "docker" ] && ! kube::util::ensure_docker_daemon_connectivity; then
1098-
exit 1
1100+
if [ "${CONTAINER_RUNTIME}" == "docker" ]; then
1101+
if ! kube::util::ensure_docker_daemon_connectivity; then
1102+
exit 1
1103+
else
1104+
# docker doesn't allow to reach exposed hostPorts from the node, however, Kubernetes does
1105+
# so we append a new rule on top of the docker one
1106+
# -A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER <-- docker rule
1107+
if ! iptables -t nat -C OUTPUT -m addrtype --dst-type LOCAL -j DOCKER; then
1108+
iptables -t nat -A OUTPUT -m addrtype --dst-type LOCAL -j DOCKER
1109+
fi
1110+
fi
10991111
fi
11001112

11011113
if [[ "${START_MODE}" != "kubeletonly" ]]; then

0 commit comments

Comments
 (0)