Skip to content

Commit 38e576b

Browse files
authored
[backport v0.31.x-gp] custom ReadinessProbe (#483) (#484)
* custom ReadinessProbe (#483) * custom ReadinessProbe * merge * typo * comment * changelog type fix
1 parent d52f374 commit 38e576b

File tree

5 files changed

+43
-26
lines changed

5 files changed

+43
-26
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
changelog:
2+
- type: FIX
3+
issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/11314
4+
resolvesIssue: false
5+
description: Use custom type for readiness probe to allow passing in templates for values.

codegen/cmd_test.go

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -781,13 +781,9 @@ var _ = Describe("Cmd", func() {
781781
Value: "BAR",
782782
},
783783
},
784-
ReadinessProbe: &v1.Probe{
785-
ProbeHandler: v1.ProbeHandler{
786-
HTTPGet: &v1.HTTPGetAction{
787-
Path: "/",
788-
Port: intstr.FromInt(8080),
789-
},
790-
},
784+
ReadinessProbe: &ReadinessProbe{
785+
Path: "/",
786+
Port: "8080",
791787
PeriodSeconds: 10,
792788
InitialDelaySeconds: 5,
793789
},
@@ -944,13 +940,9 @@ var _ = Describe("Cmd", func() {
944940
Value: "BAR",
945941
},
946942
},
947-
ReadinessProbe: &v1.Probe{
948-
ProbeHandler: v1.ProbeHandler{
949-
HTTPGet: &v1.HTTPGetAction{
950-
Path: "/",
951-
Port: intstr.FromInt(8080),
952-
},
953-
},
943+
ReadinessProbe: &ReadinessProbe{
944+
Path: "/",
945+
Port: "8080",
954946
PeriodSeconds: 10,
955947
InitialDelaySeconds: 5,
956948
},
@@ -1532,13 +1524,8 @@ roleRef:
15321524
Value: "BAR",
15331525
},
15341526
},
1535-
ReadinessProbe: &v1.Probe{
1536-
ProbeHandler: v1.ProbeHandler{
1537-
HTTPGet: &v1.HTTPGetAction{
1538-
Path: "/",
1539-
Port: intstr.FromInt(8080),
1540-
},
1541-
},
1527+
ReadinessProbe: &ReadinessProbe{
1528+
Exec: []string{"redis-cli", "ping"},
15421529
PeriodSeconds: 10,
15431530
InitialDelaySeconds: 5,
15441531
},

codegen/model/chart.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ type Container struct {
124124
// not configurable via helm values
125125
Args []string
126126
VolumeMounts []corev1.VolumeMount
127-
ReadinessProbe *corev1.Probe
127+
ReadinessProbe *ReadinessProbe
128128
LivenessProbe *corev1.Probe
129129

130130
Image Image
@@ -133,6 +133,14 @@ type Container struct {
133133
SecurityContext *corev1.SecurityContext
134134
}
135135

136+
type ReadinessProbe struct {
137+
Exec []string // optional: if specified, the readiness probe will be an exec probe with the specified commands
138+
Path string // Path to access on the HTTP server. Either specify Path and Port for httpGet probes, or specify Exec
139+
Port string
140+
PeriodSeconds int
141+
InitialDelaySeconds int
142+
}
143+
136144
// sidecars require a container config and a unique name
137145
type Sidecar struct {
138146
Container

codegen/templates/chart/operator-deployment.yamltmpl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,23 @@ spec:
151151
{{- end }}
152152
[[- if $container.ReadinessProbe ]]
153153
readinessProbe:
154-
[[ toYaml $container.ReadinessProbe | indent 10 ]]
154+
[[- if $container.ReadinessProbe.Exec ]]
155+
exec:
156+
command:
157+
[[- range $command := $container.ReadinessProbe.Exec ]]
158+
- [[ $command ]]
159+
[[- end ]]
160+
[[- else ]]
161+
httpGet:
162+
path: [[ $container.ReadinessProbe.Path ]]
163+
port: [[ $container.ReadinessProbe.Port ]]
164+
[[- end ]]
165+
[[- if $container.ReadinessProbe.InitialDelaySeconds ]]
166+
initialDelaySeconds: [[ $container.ReadinessProbe.InitialDelaySeconds ]]
167+
[[- end ]]
168+
[[- if $container.ReadinessProbe.PeriodSeconds ]]
169+
periodSeconds: [[ $container.ReadinessProbe.PeriodSeconds ]]
170+
[[- end ]]
155171
[[- end ]]
156172
[[- if $container.LivenessProbe ]]
157173
livenessProbe:

codegen/test/chart-no-desc/templates/deployment.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ spec:
9090
- ALL
9191
{{- end }}
9292
readinessProbe:
93-
httpGet:
94-
path: /
95-
port: 8080
93+
exec:
94+
command:
95+
- redis-cli
96+
- ping
9697
initialDelaySeconds: 5
9798
periodSeconds: 10
9899
{{- $palette := $.Values.painter.sidecars.palette }}

0 commit comments

Comments
 (0)