Skip to content

Commit

Permalink
custom ReadinessProbe (#485)
Browse files Browse the repository at this point in the history
* custom ReadinessProbe

* gen
  • Loading branch information
puertomontt authored Aug 23, 2023
1 parent f9d6f9b commit 99cf5b9
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 29 deletions.
5 changes: 5 additions & 0 deletions changelog/v0.29.12/readiness-probe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/11314
resolvesIssue: false
description: Use custom type for readiness probe to allow passing in templates for values.
29 changes: 8 additions & 21 deletions codegen/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,13 +670,9 @@ var _ = Describe("Cmd", func() {
Value: "BAR",
},
},
ReadinessProbe: &v1.Probe{
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(8080),
},
},
ReadinessProbe: &ReadinessProbe{
Path: "/",
Port: "8080",
PeriodSeconds: 10,
InitialDelaySeconds: 5,
},
Expand Down Expand Up @@ -833,13 +829,9 @@ var _ = Describe("Cmd", func() {
Value: "BAR",
},
},
ReadinessProbe: &v1.Probe{
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(8080),
},
},
ReadinessProbe: &ReadinessProbe{
Path: "/",
Port: "8080",
PeriodSeconds: 10,
InitialDelaySeconds: 5,
},
Expand Down Expand Up @@ -1230,13 +1222,8 @@ var _ = Describe("Cmd", func() {
Value: "BAR",
},
},
ReadinessProbe: &v1.Probe{
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(8080),
},
},
ReadinessProbe: &ReadinessProbe{
Exec: []string{"redis-cli", "ping"},
PeriodSeconds: 10,
InitialDelaySeconds: 5,
},
Expand Down
10 changes: 9 additions & 1 deletion codegen/model/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ type Container struct {
// not configurable via helm values
Args []string
VolumeMounts []v1.VolumeMount
ReadinessProbe *v1.Probe
ReadinessProbe *ReadinessProbe
LivenessProbe *v1.Probe

Image Image
Expand All @@ -124,6 +124,14 @@ type Container struct {
SecurityContext *v1.SecurityContext
}

type ReadinessProbe struct {
Exec []string // optional: if specified, the readiness probe will be an exec probe with the specified commands
Path string // Path to access on the HTTP server. Either specify Path and Port for httpGet probes, or specify Exec
Port string
PeriodSeconds int
InitialDelaySeconds int
}

// sidecars require a container config and a unique name
type Sidecar struct {
Container
Expand Down
18 changes: 17 additions & 1 deletion codegen/templates/chart/operator-deployment.yamltmpl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,23 @@ spec:
{{- end}}
[[- if $container.ReadinessProbe ]]
readinessProbe:
[[ toYaml $container.ReadinessProbe | indent 10 ]]
[[- if $container.ReadinessProbe.Exec ]]
exec:
command:
[[- range $command := $container.ReadinessProbe.Exec ]]
- [[ $command ]]
[[- end ]]
[[- else ]]
httpGet:
path: [[ $container.ReadinessProbe.Path ]]
port: [[ $container.ReadinessProbe.Port ]]
[[- end ]]
[[- if $container.ReadinessProbe.InitialDelaySeconds ]]
initialDelaySeconds: [[ $container.ReadinessProbe.InitialDelaySeconds ]]
[[- end ]]
[[- if $container.ReadinessProbe.PeriodSeconds ]]
periodSeconds: [[ $container.ReadinessProbe.PeriodSeconds ]]
[[- end ]]
[[- end ]]
[[- if $container.LivenessProbe ]]
livenessProbe:
Expand Down
7 changes: 4 additions & 3 deletions codegen/test/chart-no-desc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ spec:
- ALL
{{- end}}
readinessProbe:
httpGet:
path: /
port: 8080
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 5
periodSeconds: 10
{{- $palette := $.Values.painter.sidecars.palette }}
Expand Down
7 changes: 4 additions & 3 deletions codegen/test/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ spec:
- ALL
{{- end}}
readinessProbe:
httpGet:
path: /
port: 8080
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 5
periodSeconds: 10
{{- $palette := $.Values.painter.sidecars.palette }}
Expand Down

0 comments on commit 99cf5b9

Please sign in to comment.