The Wayback Machine - https://web.archive.org/web/20210220002913/https://github.com/linkerd/linkerd2/issues/5786
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init: Add a check for existing iptables rules #5786

Open
cpretzer opened this issue Feb 20, 2021 · 0 comments
Open

init: Add a check for existing iptables rules #5786

cpretzer opened this issue Feb 20, 2021 · 0 comments

Comments

@cpretzer
Copy link
Member

@cpretzer cpretzer commented Feb 20, 2021

Feature Request

What problem are you trying to solve?

The proxy-init container will fail to start if either of the PROXY_INIT_OUTPUT or PROXY_INIT_REDIRECT chains already exist in the iptables rules. When the init container fails to start, the pod goes into a CrashLoopBackOff state.

The scenario where this behavior was discovered is an edge case where a process external to Kubernetes removed the proxy-init image from the node. k8s has its own garbage collection mechanism for images, so when an image is removed outside of that mechanism, k8s will pull the missing image and restart any containers that use the image.

The underlying cause for this behavior is that the logic in iptables.go adds the PROXY_INIT_OUTPUT and PROXY_INIT_REDIRECT chains without checking to see if they exist first.

How should the problem be solved?

Add logic to iptables.go that captures the output from the iptables save command and uses regex to search for the PROXY_INIT_OUTPUT and PROXY_INIT_REDIRECT rules.

If either of them exist, remove them, then allow the existing code to add the rules back in.

Any alternatives you've considered?

  1. Do the same check outlined above to see if the rules exist, and if they do, then don't remove them or run the addIncomingTrafficRules and addOutgoingTrafficRules functions. Instead exit 0 and assume that the rules are valid.

The drawback here is that a skipped port could have been added at the namespace level, and those won't be reflected in the iptables rules. I see this being a pretty infrequent or improbable scenario, since updating skipped ports at the namespace level should be followed by restarting the pods.

  1. Set restartPolicy: never in the proxy-init PodSpec

I don't know the full ramifications of this, so it could be a really bad idea 😄

How would users interact with this feature?

This would be transparent to users and they won't need any interaction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant