Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Catalog: Add k8s endpoint health state to consul health check #3874

Merged
3 changes: 3 additions & 0 deletions .changelog/3874.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:sync-catalog
Add Endpoint health state to registered consul service
```
12 changes: 9 additions & 3 deletions control-plane/catalog/to-consul/resource.go
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ const (
// consulKubernetesCheckName is the name of health check in Consul for Kubernetes readiness status.
consulKubernetesCheckName = "Kubernetes Readiness Check"
kubernetesSuccessReasonMsg = "Kubernetes health checks passing"
kubernetesFailureReasonMsg = "Kubernetes health checks failing"
)

type NodePortSyncType string
@@ -693,7 +694,6 @@ func (t *ServiceResource) generateRegistrations(key string) {
}
}
}

}
}
}
@@ -800,11 +800,17 @@ func (t *ServiceResource) registerServiceInstance(
Name: consulKubernetesCheckName,
Namespace: baseService.Namespace,
Type: consulKubernetesCheckType,
Status: consulapi.HealthPassing,
ServiceID: serviceID(r.Service.Service, addr),
Output: kubernetesSuccessReasonMsg,
}

// Consider endpoint health state for registered consul service
if endpoint.Conditions.Ready != nil && *endpoint.Conditions.Ready {
r.Check.Status = consulapi.HealthPassing
r.Check.Output = kubernetesSuccessReasonMsg
} else {
r.Check.Status = consulapi.HealthCritical
r.Check.Output = kubernetesFailureReasonMsg
}
t.consulMap[key] = append(t.consulMap[key], &r)
}
}
Loading