Skip to content

Conversation

nmittler
Copy link
Contributor

@nmittler nmittler commented Feb 16, 2018

Fixes #3514

@nmittler nmittler requested review from costinm and a team February 16, 2018 20:38
@istio-merge-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
We suggest the following additional approver: nmittler

Assign the PR to them by writing /assign @nmittler in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

echo ' -i: Comma separated list of IP ranges in CIDR form to redirect to envoy (optional)'
echo ''
}

IP_RANGES_INCLUDE=""
REDIRECT_INBOUND_TRAFFIC="yes" # Route all inbound traffic to Envoy by default
Copy link
Member

Choose a reason for hiding this comment

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

nit: TRAP_INBOUND_TRAFFIC and change the rest to reflect this statement.. In general, we want TRAP_INBOUND, TRAP_OUTBOUND, etc.. If at all possible, use a different flag than -g.
And this does not have much to do with gateway btw, as gateways will not have any IPTables stuff.

@@ -28,6 +30,9 @@ while getopts ":p:u:e:i:h" opt; do
i)
IP_RANGES_INCLUDE=${OPTARG}
;;
g)
REDIRECT_INBOUND_TRAFFIC="no" # For gateways, do not redirect inbound traffic
Copy link
Member

Choose a reason for hiding this comment

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

Please remove gateway, as it implies that we need IPtables for gateways.. What you need here is a customization for the use case you point to (trap outbound but not inbound). That could apply to any normal pod as well.

iptables -t nat -N ISTIO_REDIRECT -m comment --comment "istio/redirect-common-chain"
iptables -t nat -A ISTIO_REDIRECT -p tcp -j REDIRECT --to-port ${ENVOY_PORT} -m comment --comment "istio/redirect-to-envoy-port"

# Redirect all inbound traffic to Envoy.
iptables -t nat -A PREROUTING -j ISTIO_REDIRECT -m comment --comment "istio/install-istio-prerouting"
# Redirect all inbound traffic to Envoy (if not configuring a gateway).
Copy link
Member

Choose a reason for hiding this comment

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

same here

@rshriram
Copy link
Member

A simpler and less riskier option would be to have the nginx ingress controller generate 127.0.0.1 as the upstream address for each entry.. You could then run both nginx and envoy as two processes without any IPtables interception business (this becomes especially useful when you install firewalls and other such stuff that may in turn have more IPtables stuff). But this is something left to the end user's appetite.

@nmittler nmittler requested a review from ldemailly as a code owner February 16, 2018 23:05
@nmittler nmittler changed the title Add iptables option for configuring gateways Making iptables scripts consistent. Feb 16, 2018
@nmittler nmittler force-pushed the ingress_sidecar branch 2 times, most recently from 91a899b to 06a973b Compare February 16, 2018 23:18
@nmittler
Copy link
Contributor Author

nmittler commented Feb 16, 2018

FYI, I've backed off on the original change to instead focus on making the two scripts within istio identical. Renamed this PR accordingly.

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.

If you are going to be touching the core script, we need to test this thoroughly with all e2e tests.

I suggest you tweak the circleci file to add all the jobs to the “all” workflow (bookinfo and mixer). Make sure they all pass. Once they do, undo the change to circleci config, and then merge.

Copy link
Contributor

@costinm costinm left a comment

Choose a reason for hiding this comment

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

Looks good as code - but I agree with Shriram, this deserves testing with the full suite. Please check the prow tests first - they do run the bookinfo.

@costinm
Copy link
Contributor

costinm commented Feb 17, 2018

In particular, the state on the proxy_init in the circleci test:
State: Waiting
Reason: CrashLoopBackOff

@costinm costinm closed this Feb 17, 2018
@costinm costinm reopened this Feb 17, 2018
Copy link
Contributor

@costinm costinm left a comment

Choose a reason for hiding this comment

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

Sorry, clicked the close accidentally.

Added 'request changes' so it doesn't get accidentally merged, will approve again once the tests pass.

@ldemailly
Copy link
Member

/test e2e-suite-rbac-auth

@ldemailly
Copy link
Member

now (beginning of 0.7 cycle) is the perfect time to get this left over from 0.2 cleanup as well as get the feature we do need. but yes it does mean all tests should be good

one thing to do is check / compare the output of iptables-save on a pod with this script and on a pod with the last release

@nmittler nmittler requested review from a team February 19, 2018 04:14
@nmittler nmittler force-pushed the ingress_sidecar branch 5 times, most recently from 23b773a to 344e853 Compare February 20, 2018 00:49
@@ -30,19 +28,26 @@
# After more testing, the goal is to replace and unify the script in K8S - by generating
# the sidecar image using the .deb file created by proxy.

set -o errexit
Copy link
Member

@ldemailly ldemailly Mar 14, 2018

Choose a reason for hiding this comment

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

in short, this makes it fail because it's doing -D commands that are expected to fail; those commands should have || true

@ldemailly
Copy link
Member

ping

@ldemailly
Copy link
Member

@nmittler can we get this done for 0.8 ?

@ldemailly ldemailly modified the milestones: Istio 0.7, Istio 0.8 Mar 22, 2018
@nmittler nmittler force-pushed the ingress_sidecar branch 3 times, most recently from 7b5964c to dcef0dc Compare March 30, 2018 22:12
fi

# Remove the old chains, to generate new configs.
iptables -t nat -D PREROUTING -p tcp -j ISTIO_INBOUND 2>/dev/null
Copy link
Contributor

Choose a reason for hiding this comment

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

This will result in an unexpected message the first time it is run. ( and next lines - the second time it is run ).

I think ignoring the err is useful and avoids confusion

Copy link
Contributor Author

@nmittler nmittler Mar 30, 2018

Choose a reason for hiding this comment

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

@costinm that's fine .... doing this seems to negate the set -x at the top of the file, resulting in the echo for each statement also being redirected to /dev/null. Do you happen to know some bash magic that might make it work?

Copy link
Contributor

@costinm costinm left a comment

Choose a reason for hiding this comment

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

See my comment, also discussed offline about better docs on the env variables we support and using env variables consistently ( for VM and inject ), but can be done in separate PRs.

@nmittler
Copy link
Contributor Author

/test istio-presubmit

@nmittler
Copy link
Contributor Author

@ldemailly
Copy link
Member

/test e2e-suite-rbac-auth
(the output above is pre readiness updates / old from 2/16)

@nmittler
Copy link
Contributor Author

/test istio-pilot-e2e-v1alpha3

@nmittler
Copy link
Contributor Author

@costinm looks like CI is happy .... can you lgtm?

@ldemailly
Copy link
Member

/lgtm

@istio-testing
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ldemailly

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nmittler nmittler removed the do-not-merge/hold Block automatic merging of a PR. label Apr 1, 2018
@istio-merge-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@istio-merge-robot
Copy link

Automatic merge from submit-queue.

@istio-merge-robot istio-merge-robot merged commit 391a510 into istio:master Apr 1, 2018
bianpengyuan pushed a commit to bianpengyuan/istio that referenced this pull request Apr 5, 2018
Automatic merge from submit-queue.

Merging iptables scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants