hashicorp / consul-k8s

First-class support for Consul Service Mesh on Kubernetes
https://www.consul.io/docs/k8s
Mozilla Public License 2.0
666 stars 317 forks source link

consul k8s sync statically setting pod status to healthy #4207

Open nabilmasri0 opened 1 month ago

nabilmasri0 commented 1 month ago

Community Note

Overview

when syncing k8s services to consul the k8s healthcheck is always set to "healthy" regardless of the actual health status

Recreation scenario

  1. consul deployed with the following values
    syncCatalog:
    enabled: true
    default: true
    toConsul: true
    k8sAllowNamespaces: ["ns"]
    toK8S: false
    addK8SNamespaceSuffix: false      
    consulWriteInterval: 5s
    connectInject:
    enabled: false
  2. Scale new pods scale a certain deployment to more replicas, they will be added to consul with status healthy even before passing the k8s health check

Context

the healthcheck status is set to passing regardless of the the actual endpoint status https://github.com/hashicorp/consul-k8s/blob/main/control-plane/catalog/to-consul/resource.go#L797

the Endpoint object from discovery/v1 does expose an EndpointConditions object from which the actual status can be retrieved