Skip to content

Commit

Permalink
Merge pull request #3 from imusmanmalik/feat/multi-cluster-support
Browse files Browse the repository at this point in the history
feat: Add support for multi-cluster
  • Loading branch information
imusmanmalik authored Jun 12, 2023
2 parents 4b72901 + 0e0b5b8 commit 3888dad
Show file tree
Hide file tree
Showing 4 changed files with 1,109 additions and 1,044 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ project documentation for examples on importing mixins.
If you don't use the jsonnet based `kube-prometheus` project then you will need to
generate the raw yaml files for inclusion in your Prometheus installation.

Install the `jsonnet` dependencies (we use versions v0.16+):
Install the `jsonnet` dependencies (tested against versions v0.20+):

```shell
go get github.com/google/go-jsonnet/cmd/jsonnet
Expand All @@ -29,7 +29,15 @@ Generate yaml:
make
```

To use the dashboard, it can be imported or provisioned for Grafana by grabbig the [cert-manager.json](dashboards/cert-manager.json) file as is.
To use the dashboard, it can be imported or provisioned for Grafana by grabbing the [cert-manager.json](dashboards/cert-manager.json) file as is.

## Multi Cluster Support

It is becoming a common use-case where we run multiple Kubernetes clusters, each one has its own certmanager and Prometheus instance. Those Prometheus remote-write metrics to a remote Long Term Storage, such as Thanos or Cortex, and a Grafana will now query metrics from the LTS tool instead of multiple Prometheus.

Grafana dashboard have now selectors for the queries to the `_config` jsonnet object.

There is a variable named `enableMultiCluster` to enable the multi cluster queries for the dashboard.

## Manifests

Expand Down
28 changes: 28 additions & 0 deletions config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,33 @@
certManagerJobLabel: 'cert-manager',
certManagerRunbookURLPattern: 'https://gitlab.com/uneeq-oss/cert-manager-mixin/-/blob/master/RUNBOOK.md#%s',
grafanaExternalUrl: 'https://grafana.example.com',

// Selectors are inserted between {} in Prometheus queries.

dashboards: {
enableMultiCluster: false,
clusterVariableSelector: '',

defaultSelector: if self.enableMultiCluster then 'cluster="$cluster"' else '',
containerSelector: if self.enableMultiCluster then 'container="cert-manager", cluster="$cluster"' else 'container="cert-manager"',
namespaceSelector: if self.enableMultiCluster then 'namespace="cert-manager", cluster="$cluster"' else 'namespace="cert-manager"',

certmanagerCertificateReadyStatusSelector: self.defaultSelector,
certmanagerCertificateExpirationTimestampSecondsSelector: self.defaultSelector,
certmanagerControllerSyncCallCountSelector: self.defaultSelector,
certmanagerHttpAcmeClientRequestCountSelector: self.defaultSelector,
certmanagerHttpAcmeClientRequestDurationSecondsSumSelector: self.defaultSelector,
certmanagerHttpAcmeClientRequestDurationSecondsCountSelector: self.defaultSelector,
containerCPUUsageSecondsTotalSelector: self.containerSelector,
kubePodContainerResourceLimitsCpuCoresSelector: self.containerSelector,
kubePodContainerResourceRequestsCpuCoresSelector: self.containerSelector,
containerCpuCfsThrottledPeriodsTotalSelector: self.containerSelector,
containerCpuCfsPeriodsTotalSelector: self.containerSelector,
containerMemoryUsageBytesSelector: self.containerSelector,
kubePodContainerResourceLimitsMemoryBytesSelector: self.containerSelector,
kubePodContainerResourceRequestsMemoryBytesSelector: self.containerSelector,
containerNetworkReceiveBytesTotalSelector: self.namespaceSelector,
containerNetworkTransmitBytesTotalSelector: self.namespaceSelector,
},
},
}
Loading

0 comments on commit 3888dad

Please sign in to comment.