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

INFRA 11282 #7

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ const (
// passed via the -envoy-extra-args flag.
AnnotationEnvoyExtraArgs = "consul.hashicorp.com/envoy-extra-args"

// annotationSidecarProxyPreStopDelay to add a pre-stop delay to the sidecar proxy.
AnnotationSidecarProxyPreStopDelay = "consul.hashicorp.com/sidecar-proxy-prestop-delay"

// AnnotationConsulNamespace is the Consul namespace the service is registered into.
AnnotationConsulNamespace = "consul.hashicorp.com/consul-namespace"

Expand Down
13 changes: 13 additions & 0 deletions control-plane/connect-inject/webhook/consul_dataplane_sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ func (w *MeshWebhook) consulDataplaneSidecar(namespace corev1.Namespace, pod cor
container.VolumeMounts = append(container.VolumeMounts, saTokenVolumeMount)
}

// Prestop hook
if _, ok := pod.Annotations[constants.AnnotationSidecarProxyPreStopDelay]; ok {
preStopHook := &corev1.Lifecycle{
PreStop: &corev1.LifecycleHandler {
Exec: &corev1.ExecAction {
Command: []string{
"/bin/sh",
"-c",
"sleep " + pod.Annotations[constants.AnnotationSidecarProxyPreStopDelay],
}}}}
container.Lifecycle = preStopHook
}

if useProxyHealthCheck(pod) {
// Configure the Readiness Address for the proxy's health check to be the Pod IP.
container.Env = append(container.Env, corev1.EnvVar{
Expand Down