jsonnet: do not hide alerting configuration

Signed-off-by: paulfantom <pawel@krupa.net.pl>
This commit is contained in:
paulfantom 2021-11-04 12:39:53 +01:00
parent 31d86b7946
commit dbc64a0300
2 changed files with 14 additions and 7 deletions

View File

@ -2,20 +2,21 @@ local defaults = {
local defaults = self, local defaults = self,
// Convention: Top-level fields related to CRDs are public, other fields are hidden // Convention: Top-level fields related to CRDs are public, other fields are hidden
// If there is no CRD for the component, everything is hidden in defaults. // If there is no CRD for the component, everything is hidden in defaults.
name:: error 'must provide name',
namespace:: error 'must provide namespace', namespace:: error 'must provide namespace',
version: error 'must provide version', version: error 'must provide version',
image: error 'must provide image', image: error 'must provide image',
resources: { resources: {
requests: { memory: '400Mi' }, requests: { memory: '400Mi' },
}, },
//TODO(paulfantom): remove alertmanagerName after release-0.10 and convert to plain 'alerting' object.
name:: error 'must provide name', alertmanagerName:: '',
//TODO: remove alertmanagerName and convert to plain 'alerting' object alerting: {},
alertmanagerName:: error 'must provide alertmanagerName',
namespaces:: ['default', 'kube-system', defaults.namespace], namespaces:: ['default', 'kube-system', defaults.namespace],
replicas: 2, replicas: 2,
externalLabels: {}, externalLabels: {},
enableFeatures: [], enableFeatures: [],
ruleSelector: {},
commonLabels:: { commonLabels:: {
'app.kubernetes.io/name': 'prometheus', 'app.kubernetes.io/name': 'prometheus',
'app.kubernetes.io/version': defaults.version, 'app.kubernetes.io/version': defaults.version,
@ -27,7 +28,6 @@ local defaults = {
for labelName in std.objectFields(defaults.commonLabels) for labelName in std.objectFields(defaults.commonLabels)
if !std.setMember(labelName, ['app.kubernetes.io/version']) if !std.setMember(labelName, ['app.kubernetes.io/version'])
} + { prometheus: defaults.name }, } + { prometheus: defaults.name },
ruleSelector: {},
mixin:: { mixin:: {
ruleLabels: {}, ruleLabels: {},
_config: { _config: {
@ -273,7 +273,7 @@ function(params) {
serviceMonitorNamespaceSelector: {}, serviceMonitorNamespaceSelector: {},
nodeSelector: { 'kubernetes.io/os': 'linux' }, nodeSelector: { 'kubernetes.io/os': 'linux' },
resources: p._config.resources, resources: p._config.resources,
alerting: { alerting: if p._config.alerting != {} then p._config.alerting else {
alertmanagers: [{ alertmanagers: [{
namespace: p._config.namespace, namespace: p._config.namespace,
name: 'alertmanager-' + p._config.alertmanagerName, name: 'alertmanager-' + p._config.alertmanagerName,

View File

@ -91,7 +91,14 @@ local utils = import './lib/utils.libsonnet';
version: $.values.common.versions.prometheus, version: $.values.common.versions.prometheus,
image: $.values.common.images.prometheus, image: $.values.common.images.prometheus,
name: 'k8s', name: 'k8s',
alertmanagerName: $.values.alertmanager.name, alerting: {
alertmanagers: [{
namespace: $.values.common.namespace,
name: 'alertmanager-' + $.values.alertmanager.name,
port: $.alertmanager.service.spec.ports[0].name,
apiVersion: 'v2',
}],
},
mixin+: { ruleLabels: $.values.common.ruleLabels }, mixin+: { ruleLabels: $.values.common.ruleLabels },
}, },
prometheusAdapter: { prometheusAdapter: {