Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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