diff --git a/cluster/addons/metadata-proxy/gce/metadata-proxy.yaml b/cluster/addons/metadata-proxy/gce/metadata-proxy.yaml index 376fb65f17..767322549c 100644 --- a/cluster/addons/metadata-proxy/gce/metadata-proxy.yaml +++ b/cluster/addons/metadata-proxy/gce/metadata-proxy.yaml @@ -38,7 +38,7 @@ spec: dnsPolicy: Default containers: - name: metadata-proxy - image: gcr.io/google_containers/metadata-proxy:v0.1.4 + image: gcr.io/google_containers/metadata-proxy:v0.1.5 securityContext: privileged: true resources: diff --git a/cluster/gce/configure-vm.sh b/cluster/gce/configure-vm.sh index 124cff8e9c..4bc6dc5a67 100755 --- a/cluster/gce/configure-vm.sh +++ b/cluster/gce/configure-vm.sh @@ -86,11 +86,9 @@ ensure-local-disks() { function config-ip-firewall { echo "Configuring IP firewall rules" - iptables -N KUBE-METADATA-SERVER - iptables -I FORWARD -p tcp -d 169.254.169.254 --dport 80 -j KUBE-METADATA-SERVER - if [[ "${ENABLE_METADATA_CONCEALMENT:-}" == "true" ]]; then - iptables -A KUBE-METADATA-SERVER -j DROP + echo "Add rule for metadata concealment" + iptables -w -t nat -I PREROUTING -p tcp -d 169.254.169.254 --dport 80 -m comment --comment "metadata-concealment: bridge traffic to metadata server goes to metadata proxy" -j DNAT --to-destination 127.0.0.1:988 fi } @@ -856,7 +854,6 @@ fi if [[ -z "${is_push}" ]]; then echo "== kube-up node config starting ==" set-broken-motd - config-ip-firewall ensure-basic-networking fix-apt-sources ensure-install-dir @@ -873,6 +870,7 @@ if [[ -z "${is_push}" ]]; then download-release configure-salt remove-docker-artifacts + config-ip-firewall run-salt reset-motd diff --git a/cluster/gce/gci/configure-helper.sh b/cluster/gce/gci/configure-helper.sh index 5af388c4d8..bf53f684c6 100644 --- a/cluster/gce/gci/configure-helper.sh +++ b/cluster/gce/gci/configure-helper.sh @@ -57,18 +57,11 @@ function config-ip-firewall { iptables -A FORWARD -w -p ICMP -j ACCEPT fi - iptables -w -N KUBE-METADATA-SERVER - iptables -w -I FORWARD -p tcp -d 169.254.169.254 --dport 80 -j KUBE-METADATA-SERVER - - if [[ "${ENABLE_METADATA_CONCEALMENT:-}" == "true" ]]; then - iptables -w -A KUBE-METADATA-SERVER -j DROP - fi - # Flush iptables nat table iptables -w -t nat -F || true - echo "Add rules for ip masquerade" if [[ "${NON_MASQUERADE_CIDR:-}" == "0.0.0.0/0" ]]; then + echo "Add rules for ip masquerade" iptables -w -t nat -N IP-MASQ iptables -w -t nat -A POSTROUTING -m comment --comment "ip-masq: ensure nat POSTROUTING directs all non-LOCAL destination traffic to our custom IP-MASQ chain" -m addrtype ! --dst-type LOCAL -j IP-MASQ iptables -w -t nat -A IP-MASQ -d 169.254.0.0/16 -m comment --comment "ip-masq: local traffic is not subject to MASQUERADE" -j RETURN @@ -77,6 +70,11 @@ function config-ip-firewall { iptables -w -t nat -A IP-MASQ -d 192.168.0.0/16 -m comment --comment "ip-masq: local traffic is not subject to MASQUERADE" -j RETURN iptables -w -t nat -A IP-MASQ -m comment --comment "ip-masq: outbound traffic is subject to MASQUERADE (must be last in chain)" -j MASQUERADE fi + + if [[ "${ENABLE_METADATA_CONCEALMENT:-}" == "true" ]]; then + echo "Add rule for metadata concealment" + iptables -w -t nat -I PREROUTING -p tcp -d 169.254.169.254 --dport 80 -m comment --comment "metadata-concealment: bridge traffic to metadata server goes to metadata proxy" -j DNAT --to-destination 127.0.0.1:988 + fi } function create-dirs {