-
Notifications
You must be signed in to change notification settings - Fork 324
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
Adding support for lifecycle hooks and health probe for sidecars #1482
Adding support for lifecycle hooks and health probe for sidecars #1482
Conversation
Hi @narendrapatel have you been able to test and see that this works on Consul K8s? |
@david-yu yes I have tested this functionality in my local K8s cluster. |
Hi @narendrapatel thanks for the PR, I initially thought this was going to be a PR to address health probes for sidecars but I am as able to see the whole picture here a bit better now that the whole PR is put up. It looks like the use case is to address a few different proxy lifecycle management use cases. The Consul K8s team is intending to support a few different proxy lifecycle management use cases after our 1.14 release, however we can't merge this PR as is since we will be making significant architecture changes in how the proxy is deployed and configured as part of that release. I'll leave this PR open for the time being so others can use this for their own purposes as well. |
@david-yu thanks for the sharing. I don't it was mentioned in the 1.14 release doc. Maybe I am overlooking something? https://github.com/hashicorp/consul/releases/tag/v1.14.0 |
be43bc8
to
68d7cbe
Compare
I've updated the PR to be compatible with consul version v1.14 and consul control plane 1.0.0. But with the consul dataplane now using distroless base container, we'll need to add couple of binaries like Change required for consul version < 1.14 and consul k8s control plane < 1.0.0 is here |
Hi, |
Any news on that? We could highly benefit from such functionality. |
Closing as this is now resolved by #2233 and will be released in upcoming patch releases for 1.0.x, 1.1.x and 1.2.x. |
Thanks everyone, this was a critical fix for us. |
@david-yu it seems #2233 doesn't address the startup issue fixed by this PR (Envoy proxy sidecar goes up only after the app container). Without a fix Consul Connect is pretty much unusable for us, we wished a fix would make its way to the just-released 1.2 version. What's the reason to not fix both lifecycle issues at once? Since this PR is now closed is there any other place to track the startup issue progress? |
Hi @psypuff We really wanted to get all proxy lifecycle features in but needed to stagger them out due to the amount of work that was scheduled for Consul 1.16.0 and Consul K8s 1.2. Just as a clarification, the fix for pod shut down will come in patch releases of Consul K8s 1.1.x and 1.0.x that are releasing today, but for Consul K8s 1.2.x we will deliver them in 1.2.1. The official issue tracking application startup scenarios is #1397. I'll also link this closed PR there as well for folks to reference if they need a workaround. |
Command: []string{ | ||
"/bin/sh", | ||
"-c", | ||
`total_time=0; until wget --spider localhost:19000;` + |
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.
The /ready
endpoint should be more appropriate for this check IMHO:
#!/bin/sh
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:19000/ready)" != "200" ]]; do
sleep 1
done
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.
We do while [[ "$(curl -sf http://127.0.0.1:19000/ready)" != "LIVE" ]]; do sleep 1; done
with great success :)
Changes proposed in this PR:
Adding support to start main app containers after sidecar is started. Done by adding a postStart lifecycle hook to the sidecar container.
(via boolean annotation: consul.hashicorp.com/sidecar-hold-app-until-proxy-starts)
With reference from: App container unable to connect to network before sidecar is fully running istio/istio#11130 (comment)
Adding support to stop sidecar gracefully after main app container stops. Done by adding a preStop lifecycle hook to the sidecar container.
(via boolean annotation consul.hashicorp.com/sidecar-proxy-graceful-shutdown)
With reference from: Envoy shutting down before the thing it's wrapping can cause failed requests istio/istio#7136
Support to add health probes. Done by adding Liveness check to the sidecar container.
(via boolean annotation consul.hashicorp.com/sidecar-configure-probes)
One impact due to this:
On adding
sidecar-hold-app-until-proxy-starts
, the sidecar becomes the default container when usingkubectl exec
These features are added as opt in via annotations
How I've tested this PR:
How I expect reviewers to test this PR:
Checklist: