<p>Kuberhealthy deployment health check fails frequently saying [Prometheus]: [FIRING:2] kuberhealthy (ClusterUnhealthy kuberhealthy http kuberhealthy observability/kube-prometheus-stack-prometh</p>
<h2>Steps to reproduce:</h2>
<p>kuberhealthy runs a deployment check regularly While the deployment seems to complete it fails to report the status on kuberhealthy service</p>
<pre><code>$ k get events -nkuberhealthy | grep deployment | tail
12m         Normal    ScalingReplicaSet        deployment/deployment-deployment                      Scaled down replica set deployment-deployment-XXX to 2
12m         Normal    ScalingReplicaSet        deployment/deployment-deployment                      Scaled up replica set deployment-deployment-XXXto 4
12m         Normal    ScalingReplicaSet        deployment/deployment-deployment                      Scaled down replica set deployment-deployment-XXX to 0
3m31s       Normal    ScalingReplicaSet        deployment/deployment-deployment                      Scaled up replica set deployment-deployment-XXX to 4
3m9s        Normal    ScalingReplicaSet        deployment/deployment-deployment                      Scaled up replica set deployment-deployment-XXX to 2
3m9s        Normal    ScalingReplicaSet        deployment/deployment-deployment                      Scaled down replica set deployment-deployment-69459d778b to 2
3m9s        Normal    ScalingReplicaSet        deployment/deployment-deployment                      Scaled up replica set deployment-deployment-XXX to 4
3m          Normal    ScalingReplicaSet        deployment/deployment-deployment                      Scaled down replica set deployment-deployment-XXX to 0
63m         Warning   FailedToUpdateEndpoint   endpoints/deployment-svc                              Failed to update endpoint kuberhealthy/deployment-svc: Operation cannot be fulfilled on endpoints &quot;deployment-svc&quot;: the object has been modified; please apply your changes to the latest version and try again
53m         Warning   FailedToUpdateEndpoint
</code></pre>
<h2>debug logs</h2>
<pre><code>$ k logs deployment-XXX -nkuberhealthy
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Found instance namespace: kuberhealthy&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Kuberhealthy is located in the kuberhealthy namespace.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Debug logging enabled.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=debug msg=&quot;[/app/deployment-check]&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Parsed CHECK_IMAGE: XXXX&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Parsed CHECK_IMAGE_ROLL_TO: XXX&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Found pod namespace: kuberhealthy&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Performing check in kuberhealthy namespace.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Parsed CHECK_DEPLOYMENT_REPLICAS: 2&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Parsed CHECK_SERVICE_ACCOUNT: default&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Check time limit set to: 14m46.760673918s&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Parsed CHECK_DEPLOYMENT_ROLLING_UPDATE: true&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Check deployment image will be rolled from [XXX] to [XXXX]&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=debug msg=&quot;Allowing this check 14m46.760673918s to finish.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Kubernetes client created.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Waiting for node to become ready before starting check.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=debug msg=&quot;Checking if the kuberhealthy endpoint: XXX is ready.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=debug msg=&quot;XXX.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=debug msg=&quot;Kuberhealthy endpoint: XXX is ready. Proceeding to run check.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Starting check.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Wiping all found orphaned resources belonging to this check.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Attempting to find previously created service(s) belonging to this check.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=debug msg=&quot;Found 1 service(s).&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=debug msg=&quot;Service: kuberhealthy&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Did not find any old service(s) belonging to this check.&quot;
time=&quot;2022-12-16T12:36:43Z&quot; level=info msg=&quot;Attempting to find previously created deployment(s) belonging to this check.&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=debug msg=&quot;Found 1 deployment(s)&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=debug msg=kuberhealthy
time=&quot;2022-12-16T12:36:44Z&quot; level=info msg=&quot;Did not find any old deployment(s) belonging to this check.&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=info msg=&quot;Successfully cleaned up prior check resources.&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=info msg=&quot;Creating deployment resource with 2 replica(s) in kuberhealthy namespace using image XXX]&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=info msg=&quot;Creating container using image [XXX]&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=info msg=&quot;Created deployment resource.&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=info msg=&quot;Creating deployment in cluster with name: deployment-deployment&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=info msg=&quot;Watching for deployment to exist.&quot;
time=&quot;2022-12-16T12:36:44Z&quot; level=debug msg=&quot;Received an event watching for deployment changes: deployment-deployment got event ADDED&quot;
time=&quot;2022-12-16T12:36:47Z&quot; level=debug msg=&quot;Received an event watching for deployment changes: deployment-deployment got event MODIFIED&quot;
time=&quot;2022-12-16T12:36:48Z&quot; level=debug msg=&quot;Received an event watching for deployment changes: deployment-deployment got event MODIFIED&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=debug msg=&quot;Received an event watching for deployment changes: deployment-deployment got event MODIFIED&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Deployment is reporting Available with True.&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Created deployment in kuberhealthy namespace: deployment-deployment&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Creating service resource for kuberhealthy namespace.&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Created service resource.&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Creating service in cluster with name: deployment-svc&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Watching for service to exist.&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=debug msg=&quot;Received an event watching for service changes: ADDED&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Cluster IP found:XXX&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Created service in kuberhealthy namespace: deployment-svc&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=debug msg=&quot;Retrieving a cluster IP belonging to: deployment-svc&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Found service cluster IP address: XXX&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Looking for a response from the endpoint.&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=debug msg=&quot;Setting timeout for backoff loop to: 3m0s&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Beginning backoff loop for HTTP GET request.&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=debug msg=&quot;Making GET to XXX&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=debug msg=&quot;Got a 401&quot;
time=&quot;2022-12-16T12:36:53Z&quot; level=info msg=&quot;Retrying in 5 seconds.&quot;
time=&quot;2022-12-16T12:36:58Z&quot; level=error msg=&quot;error occurred making request to service in cluster: could not get a response from the given address: XXX&quot;
time=&quot;2022-12-16T12:36:58Z&quot; level=info msg=&quot;Cleaning up deployment and service.&quot;
time=&quot;2022-12-16T12:36:58Z&quot; level=info msg=&quot;Attempting to delete service deployment-svc in kuberhealthy namespace.&quot;
time=&quot;2022-12-16T12:36:58Z&quot; level=debug msg=&quot;Checking if service has been deleted.&quot;
time=&quot;2022-12-16T12:36:58Z&quot; level=debug msg=&quot;Delete service and wait has not yet timed out.&quot;
time=&quot;2022-12-16T12:36:58Z&quot; level=debug msg=&quot;Waiting 5 seconds before trying again.&quot;
time=&quot;2022-12-16T12:37:03Z&quot; level=info msg=&quot;Attempting to delete deployment in kuberhealthy namespace.&quot;
time=&quot;2022-12-16T12:37:03Z&quot; level=debug msg=&quot;Checking if deployment has been deleted.&quot;
time=&quot;2022-12-16T12:37:03Z&quot; level=debug msg=&quot;Delete deployment and wait has not yet timed out.&quot;
time=&quot;2022-12-16T12:37:03Z&quot; level=debug msg=&quot;Waiting 5 seconds before trying again.&quot;
time=&quot;2022-12-16T12:37:08Z&quot; level=info msg=&quot;Finished clean up process.&quot;
time=&quot;2022-12-16T12:37:08Z&quot; level=error msg=&quot;Reporting errors to Kuberhealthy: [could not get a response from the given address: XXX&quot;
</code></pre>

Daemon
<p><strong>Looks like your kubernetes deployment is working fine. It's common behavior of k8s to let the k8s clients (Controllers) know to try again, it's perfectly fine and you can safely ignore that.</strong></p>
<p><em><strong>Let me try to explain the generic cause of such warning in the events:</strong></em></p>
<p>The K8s API Server is implementing something called <code>&quot;Optimistic concurrency control&quot;</code> (sometimes referred to as optimistic locking). This is a method where instead of locking a piece of data and preventing it from being read or updated while the lock is in place, the piece of data includes a version number. Every time the data is updated, the version number increases.</p>
<p>When updating the data, the version number is checked to see if it has increased between the time the client reads the data and the time it submits the update. If this happens, the update is rejected and the client must re-read the new data and try to update it again. The result is that when two clients try to update the same data entry, only the first one succeeds.</p>
<p>You can also refer to the <a href="https://stackoverflow.com/questions/57957516/kubernetes-failed-to-update-endpoints-warning">SO</a> for relevant information.</p>
<p>Also please go through the <a href="https://komodor.com/blog/kubernetes-health-checks-everything-you-need-to-know/" rel="nofollow noreferrer">Kubernetes Health Checks: Everything You Need to Know</a> for more info.</p>
<p><strong>EDIT:</strong>
If you're running a version which doesn't contain the latest fixes/ patches,I recommend you upgrade your master and nodes to a newer minor version. For example, 1.12.10-gke.20 or 22. This will help isolate the issue on whether it is the GKE version or some other underlying issue, please go through the <a href="https://cloud.google.com/kubernetes-engine/docs/release-notes#november_11_2019" rel="nofollow noreferrer">GKE release notes</a> for more information.
The nodes are unhealthy and deployments are experiencing timeouts. Upgrading might resolve the issue.</p>
<p>Seems the above warning message detects when you run the current file from Kubernetes Engine &gt; Workloads &gt; YAML. If so, then to solve the problem, you need to find the exact yaml file and then edit it as per your requirement, after that you can run the following command like  <code>$kubectl apply -f nginx-1.yaml</code>. If this way does not work then please check the details of your executed operation (Including deployment of pod).</p>
<p>Please check <a href="https://kubernetes.io/docs/tasks/debug/debug-application/debug-pods/" rel="nofollow noreferrer">Debug Pods</a>instructions, which describe some common troubleshooting to help users debug applications that are deployed into Kubernetes and not behaving correctly.</p>
<p>You may also visit troubleshooting document for <a href="https://kubernetes.io/docs/tasks/debug/" rel="nofollow noreferrer">Monitoring, Logging, and Debugging</a> for more information.</p>
<p>Also go through another similar <a href="https://stackoverflow.com/questions/60942257/kubernetes-high-latency-access-svc-ip-on-other-nodes-but-works-well-in-nodeport">SO</a>, which may help to resolve your issue.</p>
