Skip to content

Commit

Permalink
squash! Update README defaults and config
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Jern committed Mar 18, 2021
1 parent b40fe98 commit 6ece9ca
Showing 1 changed file with 9 additions and 88 deletions.
97 changes: 9 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,98 +329,19 @@ Once updated, just follow the instructions under "Compiling" and "Apply the kube

Jsonnet has the concept of hidden fields. These are fields, that are not going to be rendered in a result. This is used to configure the kube-prometheus components in jsonnet. In the example jsonnet code of the above [Customizing Kube-Prometheus section](#customizing-kube-prometheus), you can see an example of this, where the `namespace` is being configured to be `monitoring`. In order to not override the whole object, use the `+::` construct of jsonnet, to merge objects, this way you can override individual settings, but retain all other settings and defaults.

These are the available fields with their respective default values:
The available fields and their default values can be seen in [main.libsonnet](jsonnet/kube-prometheus/main.libsonnet). Note that many of the fields get their default values from variables, and for example the version numbers are imported from [versions.json](jsonnet/kube-prometheus/versions.json).

Configuration is mainly done in the `values` map. You can see this being used in the `example.jsonnet` to set the namespace to `monitoring`. This is done in the `common` field, which all other components take their default value from. See for example how Alertmanager is configured in `main.libsonnet`:

```
{
values:: {
common: {
namespace: 'default',
ruleLabels: {
role: 'alert-rules',
prometheus: $.values.prometheus.name,
},
// to allow automatic upgrades of components, we store versions in autogenerated `versions.json` file and import it here
versions: {
alertmanager: error 'must provide version',
blackboxExporter: error 'must provide version',
grafana: error 'must provide version',
kubeStateMetrics: '1.9.8',
nodeExporter: error 'must provide version',
prometheus: error 'must provide version',
prometheusAdapter: error 'must provide version',
prometheusOperator: error 'must provide version',
} + (import 'versions.json'),
images: {
alertmanager: 'quay.io/prometheus/alertmanager:v' + $.values.common.versions.alertmanager,
blackboxExporter: 'quay.io/prometheus/blackbox-exporter:v' + $.values.common.versions.blackboxExporter,
grafana: 'grafana/grafana:v' + $.values.common.versions.grafana,
kubeStateMetrics: 'k8s.gcr.io/kube-state-metrics/kube-state-metrics:v' + $.values.common.versions.kubeStateMetrics,
nodeExporter: 'quay.io/prometheus/node-exporter:v' + $.values.common.versions.nodeExporter,
prometheus: 'quay.io/prometheus/prometheus:v' + $.values.common.versions.prometheus,
prometheusAdapter: 'directxman12/k8s-prometheus-adapter:v' + $.values.common.versions.prometheusAdapter,
prometheusOperator: 'quay.io/prometheus-operator/prometheus-operator:v' + $.values.common.versions.prometheusOperator,
prometheusOperatorReloader: 'quay.io/prometheus-operator/prometheus-config-reloader:v' + $.values.common.versions.prometheusOperator,
},
},
alertmanager: {
name: 'main',
config: |||
global:
resolve_timeout: 5m
inhibit_rules:
- source_match:
severity: critical
target_match_re:
severity: warning|info
equal: ['namespace', 'alertname']
- source_match:
severity: warning
target_match_re:
severity: info
equal: ['namespace', 'alertname']
route:
group_by: ['namespace']
group_wait: 30s
group_interval: 5m
repeat_interval: 12h
receiver: 'Default'
routes:
- match:
alertname: Watchdog
receiver: Watchdog
- match:
severity: critical
receiver: Critical
receivers:
- name: Default
- name: Watchdog
- name: Critical
|||,
replicas: 3
},
kubeStateMetrics: {
resources: {
requests: { cpu: '10m', memory: '190Mi' },
limits: { cpu: '100m', memory: '250Mi' },
},
scrapeInterval: '30s',
scrapeTimeout: '30s',
},
nodeExporter: {
listenAddress: '127.0.0.1',
port: 9100,
resources: {
requests: { cpu: '102m', memory: '180Mi' },
limits: { cpu: '250m', memory: '180Mi' },
},
},
prometheus: {
name: 'k8s',
replicas: 2,
resources: { memory: '400Mi' }
// Use the namespace specified under values.common by default.
namespace: $.values.common.namespace,
version: $.values.common.versions.alertmanager,
image: $.values.common.images.alertmanager,
mixin+: { ruleLabels: $.values.common.ruleLabels },
},
}
}
```

The grafana definition is located in a different project (https://github.com/brancz/kubernetes-grafana), but needed configuration can be customized from the same top level `values` field. For example to allow anonymous access to grafana, add the following `values` section:
Expand Down

0 comments on commit 6ece9ca

Please sign in to comment.