Skip to content

Commit

Permalink
Add the ability to set up container lifecycle hooks (#312)
Browse files Browse the repository at this point in the history
* Add the ability to set up container lifecycle hooks

* Fix template example container lifecycle hooks
  • Loading branch information
VyacheslavSemin authored Jun 7, 2024
1 parent d6fc8cf commit c137d7e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ The `helm delete` command removes all the Kubernetes components associated with
| `docservice.image.tag` | Docservice container image tag | `8.0.1-1` |
| `docservice.image.pullPolicy` | Docservice container image pull policy | `IfNotPresent` |
| `docservice.containerSecurityContext.enabled` | Enable security context for the Docservice container | `false` |
| `docservice.lifecycleHooks` | Defines the Docservice [container lifecycle hooks](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks). It is used to trigger events to run at certain points in a container's lifecycle | `{}` |
| `docservice.resources.requests` | The requested resources for the Docservice container | `{}` |
| `docservice.resources.limits` | The resources limits for the Docservice container | `{}` |
| `docservice.readinessProbe.enabled` | Enable readinessProbe for Docservice container | `true` |
Expand Down Expand Up @@ -482,6 +483,7 @@ The `helm delete` command removes all the Kubernetes components associated with
| `proxy.image.tag` | Docservice Proxy container image tag | `8.0.1-1` |
| `proxy.image.pullPolicy` | Docservice Proxy container image pull policy | `IfNotPresent` |
| `proxy.containerSecurityContext.enabled` | Enable security context for the Proxy container | `false` |
| `proxy.lifecycleHooks` | Defines the Proxy [container lifecycle hooks](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks). It is used to trigger events to run at certain points in a container's lifecycle | `{}` |
| `proxy.resources.requests` | The requested resources for the Proxy container | `{}` |
| `proxy.resources.limits` | The resources limits for the Proxy container | `{}` |
| `proxy.readinessProbe.enabled` | Enable readinessProbe for Proxy container | `true` |
Expand All @@ -503,6 +505,7 @@ The `helm delete` command removes all the Kubernetes components associated with
| `converter.image.tag` | Converter container image tag | `8.0.1-1` |
| `converter.image.pullPolicy` | Converter container image pull policy | `IfNotPresent` |
| `converter.containerSecurityContext.enabled` | Enable security context for the Converter container | `false` |
| `converter.lifecycleHooks` | Defines the Converter [container lifecycle hooks](https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks). It is used to trigger events to run at certain points in a container's lifecycle | `{}` |
| `converter.resources.requests` | The requested resources for the Converter container | `{}` |
| `converter.resources.limits` | The resources limits for the Converter container | `{}` |
| `converter.autoscaling.enabled` | Enable Converter deployment autoscaling | `false` |
Expand Down
3 changes: 3 additions & 0 deletions templates/deployments/converter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ spec:
{{- if .Values.converter.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.converter.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.converter.lifecycleHooks }}
lifecycle: {{- toYaml .Values.converter.lifecycleHooks | nindent 12 }}
{{- end }}
resources: {{- toYaml .Values.converter.resources | nindent 12 }}
env:
- name: DB_PWD
Expand Down
6 changes: 6 additions & 0 deletions templates/deployments/docservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ spec:
{{- if .Values.proxy.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.proxy.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.proxy.lifecycleHooks }}
lifecycle: {{- toYaml .Values.proxy.lifecycleHooks | nindent 12 }}
{{- end }}
ports:
- containerPort: {{ .Values.proxy.containerPorts.http }}
{{- if .Values.proxy.startupProbe.enabled }}
Expand Down Expand Up @@ -187,6 +190,9 @@ spec:
{{- if .Values.docservice.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.docservice.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.docservice.lifecycleHooks }}
lifecycle: {{- toYaml .Values.docservice.lifecycleHooks | nindent 12 }}
{{- end }}
ports:
- containerPort: {{ .Values.docservice.containerPorts.http }}
{{- if .Values.docservice.startupProbe.enabled }}
Expand Down
3 changes: 3 additions & 0 deletions templates/statefulset/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ spec:
{{- if .Values.example.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.example.containerSecurityContext "enabled" | toYaml | nindent 10 }}
{{- end }}
{{- if .Values.example.lifecycleHooks }}
lifecycle: {{- toYaml .Values.example.lifecycleHooks | nindent 10 }}
{{- end }}
ports:
- containerPort: {{ .Values.example.containerPorts.http }}
name: http
Expand Down
40 changes: 40 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,16 @@ docservice:
## docservice.containerSecurityContext.capabilities Defines the privileges granted to the process
capabilities:
drop: ["ALL"]
## docservice.lifecycleHooks Defines the Docservice container lifecycle hooks
## ref: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
## It is used to trigger events to run at certain points in a container's lifecycle
## There are two hooks that are exposed: `PostStart` and `PreStop`
## Example:
## lifecycleHooks:
## preStop:
## exec:
## command: ["/bin/sh", "-c", "sleep 25"]
lifecycleHooks: {}
## docservice.containerPorts.http docservice container port
containerPorts:
http: 8000
Expand Down Expand Up @@ -648,6 +658,16 @@ proxy:
## proxy.containerSecurityContext.capabilities Defines the privileges granted to the process
capabilities:
drop: ["ALL"]
## proxy.lifecycleHooks Defines the Proxy container lifecycle hooks
## ref: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
## It is used to trigger events to run at certain points in a container's lifecycle
## There are two hooks that are exposed: `PostStart` and `PreStop`
## Example:
## lifecycleHooks:
## preStop:
## exec:
## command: ["/bin/sh", "-c", "sleep 25"]
lifecycleHooks: {}
## proxy.containerPorts.http proxy container port
containerPorts:
http: 8888
Expand Down Expand Up @@ -886,6 +906,16 @@ converter:
## converter.containerSecurityContext.capabilities Defines the privileges granted to the process
capabilities:
drop: ["ALL"]
## converter.lifecycleHooks Defines the Converter container lifecycle hooks
## ref: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
## It is used to trigger events to run at certain points in a container's lifecycle
## There are two hooks that are exposed: `PostStart` and `PreStop`
## Example:
## lifecycleHooks:
## preStop:
## exec:
## command: ["/bin/sh", "-c", "sleep 25"]
lifecycleHooks: {}
## converter container resource requests and limits
## ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
## converter.resources.requests The requested resources for the converter container
Expand Down Expand Up @@ -1013,6 +1043,16 @@ example:
## example.containerSecurityContext.capabilities Defines the privileges granted to the process
capabilities:
drop: ["ALL"]
## example.lifecycleHooks Defines the Example container lifecycle hooks
## ref: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
## It is used to trigger events to run at certain points in a container's lifecycle
## There are two hooks that are exposed: `PostStart` and `PreStop`
## Example:
## lifecycleHooks:
## preStop:
## exec:
## command: ["/bin/sh", "-c", "sleep 25"]
lifecycleHooks: {}
## example.containerPorts.http example container port
containerPorts:
http: 3000
Expand Down

0 comments on commit c137d7e

Please sign in to comment.