Skip to content

Commit

Permalink
*: specify clusterName and bump tsdb chart
Browse files Browse the repository at this point in the history
Signed-off-by: Paweł Krupa (paulfantom) <pawel@krupa.net.pl>
  • Loading branch information
paulfantom committed Dec 19, 2022
1 parent 89df39f commit 5bf8616
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 13 deletions.
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ keywords:
- monitoring
- tracing
- opentelemetry
version: 19.0.0
version: 20.0.0
# TODO(paulfantom): Enable after kubernetes 1.22 reaches EOL (2022-10-28)
# kubeVersion: ">= 1.23.0"
dependencies:
- name: timescaledb-single
condition: timescaledb-single.enabled
version: 0.24.1
version: 0.27.2
repository: https://charts.timescale.com
- name: promscale
condition: promscale.enabled
Expand Down
13 changes: 13 additions & 0 deletions chart/scripts/password-initializer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

: "${NAMESPACE:="default"}"
: "${DB_SECRET_NAME:="tobs-credentials"}"
: "${PROMSCALE_SECRET_NAME:="tobs-promscale-connection"}"

while ! kubectl get secret "${DB_SECRET_NAME}" --namespace "${NAMESPACE}"; do
echo "Waiting for ${DB_SECRET_NAME} secret."
sleep 1
done
PASS="$(kubectl get secret --namespace "${NAMESPACE}" "${DB_SECRET_NAME}" -o json | jq -r '.data["PATRONI_SUPERUSER_PASSWORD"]')"

kubectl get secret --namespace "${NAMESPACE}" "${PROMSCALE_SECRET_NAME}" -o json | jq --arg PASS "$PASS" '.data["PROMSCALE_DB_PASSWORD"]=$PASS' | kubectl apply -f -
19 changes: 11 additions & 8 deletions chart/templates/connection-secret-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ metadata:
heritage: {{ .Release.Service }}
stringData:
PROMSCALE_DB_PORT: "5432"
PROMSCALE_DB_HOST: "{{ .Release.Name }}.{{ .Release.Namespace }}.svc"
PROMSCALE_DB_HOST: "{{ tpl $db.clusterName . }}.{{ .Release.Namespace }}.svc"
PROMSCALE_DB_NAME: "postgres"
PROMSCALE_DB_USER: "postgres"
PROMSCALE_DB_SSL_MODE: "require"
Expand All @@ -86,13 +86,7 @@ metadata:
heritage: {{ .Release.Service }}
data:
password-initializer.sh: |
#!/bin/bash
while ! kubectl get secret {{ .Release.Name }}-credentials --namespace {{ template "tobs.namespace" . }}; do
echo "Waiting for {{ .Release.Name }}-credentials secret."
sleep 1
done
PASS=$(kubectl get secret --namespace {{ template "tobs.namespace" . }} {{ .Release.Name }}-credentials -o json | jq -r '.data["PATRONI_SUPERUSER_PASSWORD"]')
kubectl get secret --namespace {{ template "tobs.namespace" . }} {{ .Values.promscale.connectionSecretName }} -o json | jq --arg PASS "$PASS" '.data["PROMSCALE_DB_PASSWORD"]=$PASS' | kubectl apply -f -
{{- $.Files.Get "scripts/password-initializer.sh" | nindent 4 }}
---
apiVersion: batch/v1
kind: Job
Expand All @@ -111,6 +105,15 @@ spec:
- name: copier
image: bitnami/kubectl:latest
command: [ '/scripts/password-initializer.sh' ]
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: DB_SECRET_NAME
value: {{ tpl $db.clusterName . }}-credentials
- name: PROMSCALE_SECRET_NAME
value: {{ .Values.promscale.connectionSecretName }}
volumeMounts:
- name: promscale-initializer
mountPath: /scripts
Expand Down
2 changes: 2 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ timescaledb-single:
repository: timescale/timescaledb-ha
tag: pg14.5-ts2.8.1-p2
pullPolicy: IfNotPresent

clusterName: "{{ .Release.Name }}-tsdb"
env:
- name: TSTUNE_PROFILE
value: promscale
Expand Down
20 changes: 17 additions & 3 deletions docs/upgrades.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
# Upgrading tobs using helm (without tobs CLI)

The following steps are necessary if using helm without the tobs CLI. The tobs CLI will handle these upgrade tasks automatically for you.
# Upgrading tobs

Firstly upgrade the helm repo to pull the latest available tobs helm chart. We always recommend upgrading to the [latest](https://github.com/timescale/tobs/releases/latest) tobs stack available.

```shell
helm repo update
```

## Upgrading from 19.x to 20.x

Version 20 of tobs is specifying `clusterName` for timescaledb resources. This is required to make seamless connection
string propagation work out of the box with version 0.27+ of timescaledb helm chart. Since tobs is now specifying
`clusterName` in values file, we took this opportunity to also change the default `clusterName` to `{{ .Release.Name }}-tsdb`.
This allows easier operations on the installed cluster as the objects are clearly associated with particular component.

Sadly this is a breaking change for users who are using tobs with version 0.26 or lower of timescaledb helm chart.
If you are using tobs with version 0.26 or lower of timescaledb helm chart and you don't want to manually migrate
your timescaledb resources, you can specify the following option in your `values.yaml` file.

```yaml
timescaledb-single:
clusterName: "{{ .Release.Name }}"
```
## Upgrading from 18.x to 19.x
There is a breaking change in [kube-prometheus-stack](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack#from-41x-to-42x).
Expand Down

0 comments on commit 5bf8616

Please # to comment.