Skip to content

Commit

Permalink
minor: added extra annotation to connect inject (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
natitomattis committed Jun 21, 2023
1 parent f79960b commit f666b73
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit f666b73

Please sign in to comment.