-
Notifications
You must be signed in to change notification settings - Fork 138
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
feat: add health probes to node & go service #174
Conversation
@lance I am getting port 0 instead 8080 in the resulting |
livenessProbe:
httpGet:
path: /health/liveness
port: 0
name: user-container
readinessProbe:
httpGet:
path: /health/readiness
port: 0
successThreshold: 1 |
I tired fix that and got:
|
knative/deployer.go
Outdated
Handler: corev1.Handler{ | ||
HTTPGet: &corev1.HTTPGetAction{ | ||
Path: url, | ||
Port: intstr.IntOrString{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intstr.FromString(port)
might be better.
But leads to validation error mentioned before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to drop this completely. The "correct" port is inferred. The readiness endpoint has to be served on the "default" server though (the one listening on $PORT
).
@lance Maybe the port shouldn't be set for
Above is from pods generated for Looks like |
@rhuss could you pleas help us here, how are readiness/liveness probes supposed to work with knative service? |
@matejvasek your function was deployed when you first tried with the PR as written, and it came up? If so, then they work as expected, right? I tested on a local cluster and it was successful for me. When testing with |
@lance diff --git a/knative/deployer.go b/knative/deployer.go
index 5745ed0..760e51e 100644
--- a/knative/deployer.go
+++ b/knative/deployer.go
@@ -8,7 +8,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
- "k8s.io/apimachinery/pkg/util/intstr"
servinglib "knative.dev/client/pkg/serving"
"knative.dev/client/pkg/wait"
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
@@ -91,14 +90,11 @@ func (d *Deployer) Deploy(f faas.Function) (err error) {
return nil
}
-func probeFor(port, url string) *corev1.Probe {
+func probeFor(url string) *corev1.Probe {
return &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Path: url,
- Port: intstr.IntOrString{
- StrVal: port,
- },
},
},
}
@@ -115,8 +111,8 @@ func generateNewService(name, image string, healthChecks bool) *servingv1.Servic
}
if healthChecks {
- containers[0].LivenessProbe = probeFor("8080", "/health/liveness")
- containers[0].ReadinessProbe = probeFor("8080", "/health/readiness")
+ containers[0].LivenessProbe = probeFor("/health/liveness")
+ containers[0].ReadinessProbe = probeFor("/health/readiness")
}
return &v1.Service{
With that it works for me (service is up). This: Port: intstr.IntOrString{
StrVal: port,
} doesn't hurt, but it does nothing, because there is I mean if anything it should be: Port: intstr.IntOrString{
Type: intstr.String,
StrVal: "8080",
}, |
that's odd, it works for me, I think removing it should have no effect. |
Until the next release of Quarkus in November, we'll need to have some special checks so that we don't add these probes to Quarkus based functions. In the meantime, we can at least set the liveness and readiness endpoints on the Node.js/Go functions to /health/liveness and /health/readiness respectively. Fixes: knative#169 Signed-off-by: Lance Ball <lball@redhat.com>
262d9cd
to
8efb7e3
Compare
Until the next release of Quarkus in November, we'll need to have some special
checks so that we don't add these probes to Quarkus based functions. In the
meantime, we can at least set the liveness and readiness endpoints on the
Node.js/Go functions to /health/liveness and /health/readiness respectively.
Fixes: #169
Signed-off-by: Lance Ball lball@redhat.com