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
Allow switching kube-proxy mode for k8s cluster > 1.16 #2238
Allow switching kube-proxy mode for k8s cluster > 1.16 #2238
Conversation
@DockToFuture, can you update the PR description with the corresponding k/k issue and provide details about it? |
Will update it, please wait with merging. |
/kind/enhancement |
@DockToFuture what's the status of this PR? |
Before we switch the |
An init container with |
This cleans up the current mode not the one from which |
would a prestop hook to do the cleanup help here? |
A prestop hook would be executed whenever the kube-proxy pod stops, so I don't think that's what we want. Instead, would it be viable to go with @vpnachev's idea? Could we add an init container that reads the configured mode from the kube-proxy config and then decides whether to cleanup? Basically: When the mode is If that's not possible then we would have to "remember" the old mode and then decide in code when to spawn the |
This was exactly what I was thinking last night. I am just not sure how to properly detect existing artifacts, so maybe the init container can dump the current active mode in a file on the host, e.g. OLD_KUBE_PROXY_MODE=$(cat /kube-proxy-mode)
[[ ${OLD_KUBE_PROXY_MODE} == ${KUBE_PROXY_MODE} ]] && exit 0
kube-proxy --clean-up || exit $?
echo ${KUBE_PROXY_MODE} >/kube-proxy-mode The |
+💯 @vpnachev |
@rfranzke the --cleanup flag cleans up both IPVS and IPtables according to the documentation, do we need the check here? Or is that not the case @DockToFuture
|
You need the check because you only want to run the cleanup if you switch the mode. Otherwise, we end up with the same problem like the pre-stop hook - it would be executed everytime when kube-proxy starts. 😁 |
4b49440
to
ede51ec
Compare
ede51ec
to
02b9cde
Compare
02b9cde
to
3d07cd4
Compare
447d119
to
1046113
Compare
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-cleanup-script.yaml
Outdated
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-cleanup-script.yaml
Outdated
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-cleanup-script.yaml
Outdated
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-cleanup-script.yaml
Outdated
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-cleanup-script.yaml
Outdated
Show resolved
Hide resolved
1046113
to
7ec65ab
Compare
7ec65ab
to
60c908a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it out, works great, just a few left-over cosmetics, otherwise lgtm.
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-cleanup-script.yaml
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-cleanup-script.yaml
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-daemonset.yaml
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
It looks very well now, I have just a few minor change requests.
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-cleanup-script.yaml
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-daemonset.yaml
Outdated
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-daemonset.yaml
Show resolved
Hide resolved
charts/shoot-core/components/charts/kube-proxy/templates/kube-proxy-daemonset.yaml
Show resolved
Hide resolved
60c908a
to
c1b3491
Compare
c1b3491
to
4b4b5da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
What this PR does / why we need it:
This PR lifts the restrictions on
kube-proxy
to allow switching of kube-proxy mode (IPTables
,IPVS
) for k8s cluster > 1.16. Further theiptables
andipvs
rules of the previous mode are cleaned up in an init container before runningkube-proxy
in the new mode.PR kubernetes/kubernetes#78775 fixed the cleanup error in
v1.16
which led in the past to the restrictions.Which issue(s) this PR fixes:
Fixes #2225
Special notes for your reviewer:
Release note: