From cd5d1dfd4f6cbcadd030ec0363a8909842850895 Mon Sep 17 00:00:00 2001 From: Ashwin Venkatesh Date: Tue, 10 Jan 2023 15:32:19 -0500 Subject: [PATCH] Allow users to explicitly disable sidecar health checks for a service - This allows users to setup their own health check and not rely on Consul's health check to query the application and check for readiness. --- CHANGELOG.md | 2 ++ .../connect-inject/constants/annotations_and_labels.go | 5 +++++ .../connect-inject/webhook/consul_dataplane_sidecar.go | 1 + 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e1a511c5..d0596484f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ IMPROVEMENTS: * Helm: * Add a `global.extraLabels` stanza to allow setting global Kubernetes labels for all components deployed by the `consul-k8s` Helm chart. [[GH-1778](https://github.com/hashicorp/consul-k8s/pull/1778)] * Add the `accessLogs` field to the `ProxyDefaults` CRD. [[GH-1816](https://github.com/hashicorp/consul-k8s/pull/1816)] +* Control-Plane + * Add support for the annotation `consul.hashicorp.com/use-proxy-health-check`. [[GH-1824](https://github.com/hashicorp/consul-k8s/pull/1824)] BUG FIXES: * Control Plane diff --git a/control-plane/connect-inject/constants/annotations_and_labels.go b/control-plane/connect-inject/constants/annotations_and_labels.go index c3ba29ace2..637e028202 100644 --- a/control-plane/connect-inject/constants/annotations_and_labels.go +++ b/control-plane/connect-inject/constants/annotations_and_labels.go @@ -86,6 +86,11 @@ const ( // e.g. consul.hashicorp.com/service-meta-foo:bar. AnnotationMeta = "consul.hashicorp.com/service-meta-" + // AnnotationUseProxyHealthCheck creates a readiness listener on the sidecar proxy and + // queries this instead of the application health check for the status of the application. + // Enable this only if the application does not support health checks. + AnnotationUseProxyHealthCheck = "consul.hashicorp.com/use-proxy-health-check" + // annotations for sidecar proxy resource limits. AnnotationSidecarProxyCPULimit = "consul.hashicorp.com/sidecar-proxy-cpu-limit" AnnotationSidecarProxyCPURequest = "consul.hashicorp.com/sidecar-proxy-cpu-request" diff --git a/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go b/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go index 9d9c4af7d4..d0cd232c84 100644 --- a/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go +++ b/control-plane/connect-inject/webhook/consul_dataplane_sidecar.go @@ -55,6 +55,7 @@ func (w *MeshWebhook) consulDataplaneSidecar(namespace corev1.Namespace, pod cor }, InitialDelaySeconds: 1, } + container := corev1.Container{ Name: containerName, Image: w.ImageConsulDataplane,