Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ jobs:
run: |
make helm-tests

- name: Dependency-Tests
working-directory: ${{env.working-directory}}
run: |
go test -v ./tests/dependency-tests

- name: E2E-Tests
working-directory: ${{env.working-directory}}
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/go-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ jobs:
run: |
make helm-tests

- name: Dependency-Tests
working-directory: ${{env.working-directory}}
run: |
go test -v ./tests/dependency-tests

- name: E2E-Tests
working-directory: ${{env.working-directory}}
run: |
Expand Down
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ dependencies:
repository: https://charts.timescale.com
- name: kube-prometheus-stack
condition: kube-prometheus-stack.enabled
version: 15.2.4
version: 18.0.0
repository: https://prometheus-community.github.io/helm-charts
39 changes: 0 additions & 39 deletions chart/docs/ha-setup.md

This file was deleted.

130 changes: 130 additions & 0 deletions chart/docs/values-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Tobs helm values config
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. I think there are two different types of config here.

  1. config which you need only for things that don't use the CLI (high-availability)
  2. config applicable to both helm chart and CLI. (multicluster)

Type 1 is ok here. I'd move type 2 stuff into a new top-level /docs directory. It does not belong under /chart and I'd add new links from the front-page readme here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So currently using CLI we offer only abstract features with flags like HA, integration with forge, etc... all these features can also be configured within values.yaml. All the flexibility lies in the values.yaml so the intention behind creating this file is to document all possible configurations across different components in tobs.

Yes, I agree with you only config related to values.yaml will reside in this file. Anything about CLI will be in a new file in the high level root directory of this repo.


## Prometheus High-Availability

**Note**: This is unnecessary if using the tobs CLI, To enable Prometheus high-availability with tobs CLI use `--enable-prometheus-ha`.

The following steps will explain how to enable Prometheus high-availability with Promscale when using tobs helm chart (without tobs CLI).

Update the tobs `values.yaml` with below HA configuration.

Increase the TimescaleDB connection pool i.e.

```
timescaledb-single:
patroni:
bootstrap:
dcs:
postgresql:
parameters:
max_connections: 400
```

Update the Promscale configuration to enable HA mode and increase the replicas to 3:

```
promscale:
replicaCount: 3
args:
- --high-availability
```

Update Prometheus configuration to send prometheus pod name with `__replica__` and prometheus cluster name as `cluster` labelSets in the form of external labels and run Prometheus as 3 replicas for HA.

```
kube-prometheus-stack:
prometheus:
prometheusSpec:
replicaExternalLabelName: "__replica__"
prometheusExternalLabelName: "cluster"
replicas: 3
```

## Multi-cluster support
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a diagram for this section showing the various clusters etc.


<img src="./../../docs/assets/multi-cluster.png" alt="multi-cluster setup diagram" width="800"/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you forgot to add this image in the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


In tobs you can enable multi-cluster support to install a data aggregation cluster to collect observability data coming from different observer clusters.

With tobs you can deploy both observer clusters and data aggregation cluster.

### Deploying the data aggregation cluster

The data aggregation cluster acts as central observability cluster which stores, visualizes data flowing from observer clusters.

Steps to deploy data aggregation cluster

* Enable LoadBalancer service to Promscale to remote-wrtie, remote-read data from observer clusters.

```
promscale:
service:
loadBalancer:
enabled: true
```

* Add external cluster label to differentiate the visualisation in Grafana dashboards per cluster level.

```
kube-prometheus-stack:
prometheus:
prometheusSpec:
externalLabels:
cluster: <clusterName>
```

* Enable multi-cluster support in Grafana dashboards

```
kube-prometheus-stack:
grafana:
sidecar:
dashboards:
multicluster:
global:
enabled: true
```

### Deploying the observer cluster

The observer cluster forwards the metrics to data-aggregation/centralised monitoring cluster which supports ingesting, visualising of metrics flowing from different observer clusters.

Steps to install an observer cluster

* Disable TimescaleDB

```
timescaledb-single:
enabled: false
```

* Disable Promscale

```
promscale:
enabled: false
```


* Disable Grafana

```
kube-prometheus-stack:
grafana:
enabled: false
```

* Configure Prometheus remote-write to Promscale loadbalancer service in data aggregation cluster and add the external label representing the current cluster name to differentiate the visualisation on per cluster basis in Grafana.

```
kube-prometheus-stack:
prometheus:
prometheusSpec:
externalLabels:
cluster: <clusterName>
remoteRead:
- url: "<PROMSCALE_SERVICE_ENDPOINT_OF_DATA_AGGREGATION_CLUSTER>/read"
readRecent: true
remoteWrite:
- url: "<PROMSCALE_ENDPOINT>/write"
```
5 changes: 5 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ kube-prometheus-stack:
# Promscale is the default datasource
defaultDatasourceEnabled: false
dashboards:
# option to enable multi-cluster support
# in Grafana dashboards by default disabled
multicluster:
global:
enabled: false
enabled: true
files:
- dashboards/k8s-cluster.json
Expand Down
26 changes: 14 additions & 12 deletions cli/cmd/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,18 +469,20 @@ func parsePgBackRestConf(data string) map[string]string {
return newData
}

var crdURLs = []string{
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.47.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.47.0/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.47.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.47.0/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.47.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.47.0/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.47.0/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.47.0/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml",
var KubePrometheusCRDVersion = "v0.50.0"

var kubePrometheusCRDURLs = []string{
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/"+KubePrometheusCRDVersion+"/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagerconfigs.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/"+KubePrometheusCRDVersion+"/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/"+KubePrometheusCRDVersion+"/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/"+KubePrometheusCRDVersion+"/example/prometheus-operator-crd/monitoring.coreos.com_probes.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/"+KubePrometheusCRDVersion+"/example/prometheus-operator-crd/monitoring.coreos.com_prometheuses.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/"+KubePrometheusCRDVersion+"/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/"+KubePrometheusCRDVersion+"/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml",
"https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/"+KubePrometheusCRDVersion+"/example/prometheus-operator-crd/monitoring.coreos.com_prometheusrules.yaml",
}

var crdNames = []string{
var kubePrometheusCRDNames = []string{
"alertmanagerconfigs.monitoring.coreos.com",
"alertmanagers.monitoring.coreos.com",
"podmonitors.monitoring.coreos.com",
Expand All @@ -492,11 +494,11 @@ var crdNames = []string{
}

func createCRDS() error {
err := k8s.CreateCRDS(crdURLs)
err := k8s.CreateCRDS(kubePrometheusCRDURLs)
if err != nil {
return err
}
fmt.Println("Successfully created CRDs: ", crdNames)
fmt.Println("Successfully created CRDs: ", kubePrometheusCRDNames)
return nil
}

Expand Down
64 changes: 64 additions & 0 deletions cli/tests/dependency-tests/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package dependency_tests

import (
"fmt"
"io/ioutil"
"log"
"net/http"
"testing"

"github.com/timescale/tobs/cli/cmd/upgrade"
"github.com/timescale/tobs/cli/pkg/helm"
"sigs.k8s.io/yaml"
)

func TestMain(m *testing.M) {
validateKubePrometheusVersions()
}

func validateKubePrometheusVersions() {
// Get existing tobs helm chart metadata
b, err := ioutil.ReadFile("./../../../chart/Chart.yaml")
if err != nil {
log.Fatal(err)
}
existingTobsChart := &helm.ChartMetadata{}
err = yaml.Unmarshal(b, existingTobsChart)
if err != nil {
log.Fatal(err)
}
var kubePrometheusVersion string
for _, i := range existingTobsChart.Dependencies {
if i.Name == "kube-prometheus-stack" {
kubePrometheusVersion = i.Version
break
}
}

// Get upstream kube-prometheus chart metadata using kube-prometheus version used in tobs local Chart.yaml
resp, err := http.Get("https://raw.githubusercontent.com/prometheus-community/helm-charts/kube-prometheus-stack-" + kubePrometheusVersion + "/charts/kube-prometheus-stack/Chart.yaml")
if err != nil {
log.Fatalf("failed to get the kube-prometheus CHart.yaml info %v", err)
}
defer resp.Body.Close()

bodyBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}

upstreamKPChart := &helm.ChartMetadata{}
err = yaml.Unmarshal(bodyBytes, upstreamKPChart)
if err != nil {
log.Fatal(err)
}

upstreamKPChart.AppVersion = "v" + upstreamKPChart.AppVersion
// validate existing tobs kube-prometheus helm chart version & CRDs version with upstream version and CRDs that are being used
if upstreamKPChart.Version != kubePrometheusVersion || upstreamKPChart.AppVersion != upgrade.KubePrometheusCRDVersion {
log.Fatalf("failed to validate tobs kube-prometheus helm chart version and CRDs version with upstream versions."+
"Mismatch in validation, tobs Kube-Prometheus version: %s, tobs kube-prometheus CRD version: %s, "+
"upstream kube-prometheus CRD version: %s", kubePrometheusVersion, upgrade.KubePrometheusCRDVersion, upstreamKPChart.AppVersion)
}
fmt.Println("successfully validated kube-prometheus CRD versions with upstream versions.")
}
Binary file added docs/assets/multi-cluster.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.