Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Opt to enable linkerd proxy shutdown from lifecycle preStop
Browse files Browse the repository at this point in the history
Added a new `linkerd` object to values & schema. If `enabled=true` &
`shutdownAfterCheckpoint=true`, then the STS pod's `lifecycle.preStop`
hook will be configured to issue a shutdown call to the local
linkerd-proxy.

This is entirely optional. If a deployment is not using linkerd, then
this option should be left in the default disabled state.
  • Loading branch information
thedodd committed Dec 6, 2023
1 parent 7ded6b6 commit 9ffe03d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/timescaledb-single/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
apiVersion: v1
name: timescaledb-single
description: 'TimescaleDB HA Deployment.'
version: 0.33.2
version: 0.34.0
icon: https://cdn.iconscout.com/icon/free/png-256/timescaledb-1958407-1651618.png

# appVersion specifies the version of the software, which can vary wildly,
Expand Down
4 changes: 3 additions & 1 deletion charts/timescaledb-single/docs/admin-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ The following table lists the configurable parameters of the TimescaleDB Helm ch
| `image.pullPolicy` | The pull policy | `IfNotPresent` |
| `image.repository` | The image to pull | `timescale/timescaledb-ha` |
| `image.tag` | The version of the image to pull | `pg13-ts2.1-latest`
| `linkerd.enabled` | Enabled limited linkerd support. | `false`
| `linkerd.shutdownAfterCheckpoint` | When `true`, configures the StatefulSet Pod's `lifecycle.preStop` to issue a shutdown call to the local linkerd-proxy sidecar after checkpointing is complete. | `false`
| `service.primary.type` | The service type to use for the primary service | `ClusterIP` |
| `service.primary.port` | The service port to use for the primary service | `5432` |
| `service.primary.nodePort` | The service nodePort to use for the primary service when `type` is `NodePort` | `null` |
Expand Down Expand Up @@ -373,7 +375,7 @@ bootstrapFromBackup:
Restoring a different deployment using an existing deployment is possible, but can be dangerous,
as at this point you may be having 2 deployments pointing to the same S3 bucket/path.
Therefore, `bootstrapFromBackup.repo1-path` is required to be set.

If there are any other changes to be made, for example the bucket itself, you can create a secret containing that
information, for example:

Expand Down
4 changes: 4 additions & 0 deletions charts/timescaledb-single/scripts/prestop.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ CHECKPOINT;
SELECT 'We are a primary: Successfully invoked checkpoints, now issuing a switchover.';
\! curl -s http://localhost:8008/switchover -XPOST -d '{"leader": "$(hostname)"}'
\endif

\if :linkerdShutdown
\! curl -s -m 5 -X POST http://localhost:4191/shutdown
\endif
1 change: 0 additions & 1 deletion charts/timescaledb-single/templates/configmap-scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ data:
{{- .Files.Get "scripts/patroni_callback.sh" | nindent 4 }}
lifecycle_preStop.sql: |-
{{- .Files.Get "scripts/prestop.sql" | nindent 4 }}
...
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ spec:
command:
- psql
- -X
- --set=linkerdShutdown="{{ if and .Values.linkerd.enabled .Values.linkerd.terminateAfterCheckpoint }}1{{else}}0{{end}}"
- --file
- "{{ template "scripts_dir" . }}/lifecycle_preStop.sql"
# When reusing an already existing volume it sometimes happens that the permissions
Expand Down
17 changes: 17 additions & 0 deletions charts/timescaledb-single/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@
},
"type": "object"
},
"linkerd": {
"additionalProperties": false,
"properties": {
"enabled": {
"type": [
"boolean"
]
},
"terminateAfterCheckpoint": {
"type": [
"boolean"
]
}
},
"type": "object"
},
"enabled": {
"additionalProperties": true
},
Expand Down Expand Up @@ -818,6 +834,7 @@
"fullnameOverride",
"image",
"curlImage",
"linkerd",
"networkPolicy",
"nodeSelector",
"patroni",
Expand Down
9 changes: 9 additions & 0 deletions charts/timescaledb-single/values.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ required:
- fullnameOverride
- image
- curlImage
- linkerd
- networkPolicy
- nodeSelector
- patroni
Expand Down Expand Up @@ -432,6 +433,14 @@ properties:
type:
- string
- "null"
linkerd:
type: object
additionalProperties: false
properties:
enabled:
type: boolean
terminateAfterCheckpoint:
type: boolean
env:
type:
- array
Expand Down
8 changes: 8 additions & 0 deletions charts/timescaledb-single/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -597,3 +597,11 @@ debug:
# This command will be executed *before* the main container starts. In the
# example below, we can mimick a slow restore by sleeping for 5 minutes before starting
execStartPre: # sleep 300

# Support for specific use cases when deploying with the linkerd service mesh.
linkerd:
enabled: false
# As part of the statefulset pod's `lifecycle.preStop`, call the local linkerd sidecar
# to cleanly terminate the proxy. If this is not performed, then the proxy will remain
# alive unnecessarily, blocking pod termination for a period of time.
terminateAfterCheckpoint: true

0 comments on commit 9ffe03d

Please sign in to comment.