Skip to content

Commit

Permalink
Merge pull request #675 from paulfantom/db-cluster-rename
Browse files Browse the repository at this point in the history
*: specify clusterName and bump tsdb chart
  • Loading branch information
paulfantom committed Dec 19, 2022
2 parents 89df39f + b4ca13a commit 54feb7e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -2,7 +2,7 @@ KUBE_VERSION ?= 1.24
KIND_CONFIG ?= ./testdata/kind-$(KUBE_VERSION).yaml
CERT_MANAGER_VERSION ?= v1.10.1

KUBESCAPE_THRESHOLD=30
KUBESCAPE_THRESHOLD=31

MDOX_BIN=mdox
MDOX_VALIDATE_CONFIG?=.mdox.validate.yaml
Expand Down
4 changes: 2 additions & 2 deletions chart/Chart.yaml
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
@@ -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 -
6 changes: 3 additions & 3 deletions chart/scripts/test-metrics.sh
Expand Up @@ -47,13 +47,13 @@ EOF
)

testset="$genericTests"
if [ $FEATURE_KUBE_PROMETHEUS -eq 1 ]; then
if [ "$FEATURE_KUBE_PROMETHEUS" -eq 1 ]; then
testset="$kubePrometheusTests,$testset"
fi
if [ $FEATURE_PROMSCALE -eq 1 ]; then
if [ "$FEATURE_PROMSCALE" -eq 1 ]; then
testset="$promscaleTests,$testset"
fi
if [ $FEATURE_TIMESCALEDB -eq 1 ]; then
if [ "$FEATURE_TIMESCALEDB" -eq 1 ]; then
testset="$timescaleTests,$testset"
fi

Expand Down
19 changes: 11 additions & 8 deletions chart/templates/connection-secret-job.yaml
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
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
@@ -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 54feb7e

Please sign in to comment.