Skip to content
This repository has been archived by the owner on Jun 14, 2018. It is now read-only.

Fix loopback issue injecting istio proxy #494

Merged
merged 4 commits into from
Apr 12, 2017
Merged

Conversation

lizan
Copy link
Contributor

@lizan lizan commented Apr 11, 2017

Previously for loopback traffic the iptables rule routed it as:
app -> proxy -> app

This will route it as:
app -> proxy (client-side) -> proxy (server-side) -> app

So proxy can upgrade the protocol between proxies (e.g. HTTP/2, TLS)

cc @myidpt @kyessenov

Closes #103 .

Copy link
Contributor

@myidpt myidpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@istio-testing
Copy link
Contributor

Jenkins job manager/presubmit passed

@istio-testing
Copy link
Contributor

Jenkins job manager/e2e-smoketest passed

@codecov
Copy link

codecov bot commented Apr 11, 2017

Codecov Report

Merging #494 into master will increase coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #494      +/-   ##
==========================================
+ Coverage    75.7%   75.83%   +0.12%     
==========================================
  Files          25       25              
  Lines        3219     3219              
==========================================
+ Hits         2437     2441       +4     
+ Misses        596      594       -2     
+ Partials      186      184       -2
Impacted Files Coverage Δ
platform/kube/queue.go 95.55% <0%> (+8.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92a76d2...4344a5a. Read the comment docs.

@@ -41,6 +41,12 @@ if [[ -z "${ISTIO_PROXY_PORT-}" ]] || [[ -z "${ISTIO_PROXY_UID-}" ]]; then
fi

iptables -t nat -A PREROUTING -p tcp -j REDIRECT --to-port ${ISTIO_PROXY_PORT}
# To make sure when pod A wants to talk to service A, which is backed by pod A,
# the traffic is going through proxy twice, client-side and server-side.
# lo traffic doesn't go through PREROUTING, so needed to be processed in OUTPUT.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you rephrase the comment to say pod belonging to service "a" rather than pod "a"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you expand on the meaning on the rule? e.g. concretely in terms of TCP quadruples and POD_IPs

# the traffic is going through proxy twice, client-side and server-side.
# lo traffic doesn't go through PREROUTING, so needed to be processed in OUTPUT.
iptables -t nat -A OUTPUT -p tcp -j REDIRECT -o lo \
! -d 127.0.0.1/32 --to-port ${ISTIO_PROXY_PORT}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this not capturing traffic from proxy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intended to capture traffic from (client-side) proxy to (server-side) proxy, and exclude (server-side) proxy to app by excluding -d 127.0.0.1/32.

@kyessenov kyessenov requested review from ayj and rshriram April 11, 2017 20:23
Copy link
Contributor

@ayj ayj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I've convinced myself this is okay. I double checked with "iptables -t nat -S -v" in a standalone docker container that the appropriate rules are triggered for the 3 cases (external inbound traffic, implicit loopback, explicit loopback/proxy traffic).

Rule #1 - external traffic is redirected to proxy port

Rule #2 - locally generated traffic sent on loopback interface (because traffic was routed locally) and destination IP is not explicitly the loopback IP (e.g. 172.17.0.2 and not 127.0.0.1) is redirected back to proxy port. This should include any proxy generated traffic which is necessary to make (app => proxy => proxy => app) work as Lizan described.

Rule #3 - locally generated traffic not sent explicitly to loopback IP (i.e. proxy aware) or not from the proxy itself is redirected proxy port.

@lizan
Copy link
Contributor Author

lizan commented Apr 11, 2017

Thanks @ayj! added comments based on yours to the shell script for each iptables rule.

@istio-testing
Copy link
Contributor

Jenkins job manager/presubmit passed

@istio-testing
Copy link
Contributor

Jenkins job manager/e2e-smoketest passed

Copy link
Member

@rshriram rshriram left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clarify the comments in the shell script a bit more.

@istio-testing
Copy link
Contributor

Jenkins job manager/presubmit passed

@istio-testing
Copy link
Contributor

Jenkins job manager/e2e-smoketest passed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants