Skip to content

Commit 38862ad

Browse files
authored
Merge pull request #265 from yevgeny-shnaidman/yevgeny/add-probes-to-gc
Adding liveliness readiness probes to the GC
2 parents de90323 + 301e99d commit 38862ad

File tree

3 files changed

+49
-8
lines changed

3 files changed

+49
-8
lines changed

internal/deployment/deployment.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
corev1 "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/runtime"
28+
"k8s.io/apimachinery/pkg/util/intstr"
2829
"k8s.io/utils/ptr"
2930
"sigs.k8s.io/controller-runtime/pkg/client"
3031
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -89,6 +90,7 @@ func (d *deployment) SetMasterDeploymentAsDesired(nfdInstance *nfdv1.NodeFeature
8990
SecurityContext: getMasterSecurityContext(),
9091
LivenessProbe: getLivenessProbe(),
9192
ReadinessProbe: getReadinessProbe(),
93+
Ports: getPorts(),
9294
},
9395
},
9496
},
@@ -123,6 +125,9 @@ func (d *deployment) SetGCDeploymentAsDesired(nfdInstance *nfdv1.NodeFeatureDisc
123125
},
124126
Env: getEnvs(),
125127
SecurityContext: getGCSecurityContext(),
128+
LivenessProbe: getLivenessProbe(),
129+
ReadinessProbe: getReadinessProbe(),
130+
Ports: getPorts(),
126131
},
127132
},
128133
},
@@ -279,8 +284,12 @@ func getLivenessProbe() *corev1.Probe {
279284
return &corev1.Probe{
280285
InitialDelaySeconds: 10,
281286
ProbeHandler: corev1.ProbeHandler{
282-
GRPC: &corev1.GRPCAction{
283-
Port: 8082,
287+
HTTPGet: &corev1.HTTPGetAction{
288+
Path: "/healthz",
289+
Port: intstr.IntOrString{
290+
Type: intstr.String,
291+
StrVal: "http",
292+
},
284293
},
285294
},
286295
}
@@ -291,9 +300,22 @@ func getReadinessProbe() *corev1.Probe {
291300
InitialDelaySeconds: 5,
292301
FailureThreshold: 10,
293302
ProbeHandler: corev1.ProbeHandler{
294-
GRPC: &corev1.GRPCAction{
295-
Port: 8082,
303+
HTTPGet: &corev1.HTTPGetAction{
304+
Path: "/healthz",
305+
Port: intstr.IntOrString{
306+
Type: intstr.String,
307+
StrVal: "http",
308+
},
296309
},
297310
},
298311
}
299312
}
313+
314+
func getPorts() []corev1.ContainerPort {
315+
return []corev1.ContainerPort{
316+
{
317+
ContainerPort: 8080,
318+
Name: "http",
319+
},
320+
}
321+
}

internal/deployment/testdata/test_gc_deployment.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@ spec:
4141
drop:
4242
- ALL
4343
readOnlyRootFilesystem: true
44+
livenessProbe:
45+
httpGet:
46+
path: /healthz
47+
port: http
48+
initialDelaySeconds: 10
49+
readinessProbe:
50+
httpGet:
51+
path: /healthz
52+
port: http
53+
failureThreshold: 10
54+
initialDelaySeconds: 5
55+
ports:
56+
- containerPort: 8080
57+
name: http

internal/deployment/testdata/test_master_deployment.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,16 @@ spec:
7070
- ALL
7171
readOnlyRootFilesystem: true
7272
livenessProbe:
73-
grpc:
74-
port: 8082
73+
httpGet:
74+
path: /healthz
75+
port: http
7576
initialDelaySeconds: 10
7677
readinessProbe:
77-
grpc:
78-
port: 8082
78+
httpGet:
79+
path: /healthz
80+
port: http
7981
failureThreshold: 10
8082
initialDelaySeconds: 5
83+
ports:
84+
- containerPort: 8080
85+
name: http

0 commit comments

Comments
 (0)