kube-prometheus: Example jsonnet ingress, add alertmanager and grafana
This commit is contained in:
@@ -11,6 +11,23 @@ local kp =
|
|||||||
_config+:: {
|
_config+:: {
|
||||||
namespace: 'monitoring',
|
namespace: 'monitoring',
|
||||||
},
|
},
|
||||||
|
// Configure External URL's per application
|
||||||
|
alertmanager+:: {
|
||||||
|
alertmanager+: {
|
||||||
|
spec+: {
|
||||||
|
externalURL: 'http://alertmanager.example.com',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
grafana+:: {
|
||||||
|
config: {
|
||||||
|
sections: {
|
||||||
|
server: {
|
||||||
|
root_url: 'http://grafana.example.com/',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
prometheus+:: {
|
prometheus+:: {
|
||||||
prometheus+: {
|
prometheus+: {
|
||||||
spec+: {
|
spec+: {
|
||||||
@@ -18,10 +35,47 @@ local kp =
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// Create ingress objects per application
|
||||||
ingress+:: {
|
ingress+:: {
|
||||||
'prometheus-k8s':
|
alertmanager:
|
||||||
ingress.new() +
|
ingress.new() +
|
||||||
ingress.mixin.metadata.withName('prometheus-k8s') +
|
ingress.mixin.metadata.withName('alertmanager-main') +
|
||||||
|
ingress.mixin.metadata.withNamespace($._config.namespace) +
|
||||||
|
ingress.mixin.metadata.withAnnotations({
|
||||||
|
'nginx.ingress.kubernetes.io/auth-type': 'basic',
|
||||||
|
'nginx.ingress.kubernetes.io/auth-secret': 'basic-auth',
|
||||||
|
'nginx.ingress.kubernetes.io/auth-realm': 'Authentication Required',
|
||||||
|
}) +
|
||||||
|
ingress.mixin.spec.withRules(
|
||||||
|
ingressRule.new() +
|
||||||
|
ingressRule.withHost('alertmanager.example.com') +
|
||||||
|
ingressRule.mixin.http.withPaths(
|
||||||
|
httpIngressPath.new() +
|
||||||
|
httpIngressPath.mixin.backend.withServiceName('alertmanager-main') +
|
||||||
|
httpIngressPath.mixin.backend.withServicePort('web')
|
||||||
|
),
|
||||||
|
),
|
||||||
|
grafana:
|
||||||
|
ingress.new() +
|
||||||
|
ingress.mixin.metadata.withName('grafana') +
|
||||||
|
ingress.mixin.metadata.withNamespace($._config.namespace) +
|
||||||
|
ingress.mixin.metadata.withAnnotations({
|
||||||
|
'nginx.ingress.kubernetes.io/auth-type': 'basic',
|
||||||
|
'nginx.ingress.kubernetes.io/auth-secret': 'basic-auth',
|
||||||
|
'nginx.ingress.kubernetes.io/auth-realm': 'Authentication Required',
|
||||||
|
}) +
|
||||||
|
ingress.mixin.spec.withRules(
|
||||||
|
ingressRule.new() +
|
||||||
|
ingressRule.withHost('grafana.example.com') +
|
||||||
|
ingressRule.mixin.http.withPaths(
|
||||||
|
httpIngressPath.new() +
|
||||||
|
httpIngressPath.mixin.backend.withServiceName('grafana') +
|
||||||
|
httpIngressPath.mixin.backend.withServicePort('http')
|
||||||
|
),
|
||||||
|
),
|
||||||
|
prometheus:
|
||||||
|
ingress.new() +
|
||||||
|
ingress.mixin.metadata.withName('prometheus') +
|
||||||
ingress.mixin.metadata.withNamespace($._config.namespace) +
|
ingress.mixin.metadata.withNamespace($._config.namespace) +
|
||||||
ingress.mixin.metadata.withAnnotations({
|
ingress.mixin.metadata.withAnnotations({
|
||||||
'nginx.ingress.kubernetes.io/auth-type': 'basic',
|
'nginx.ingress.kubernetes.io/auth-type': 'basic',
|
||||||
@@ -39,6 +93,7 @@ local kp =
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
} + {
|
} + {
|
||||||
|
// Create basic auth secret - replace 'auth' file with your own
|
||||||
ingress+:: {
|
ingress+:: {
|
||||||
'basic-auth-secret':
|
'basic-auth-secret':
|
||||||
secret.new('basic-auth', { auth: std.base64(importstr 'auth') }) +
|
secret.new('basic-auth', { auth: std.base64(importstr 'auth') }) +
|
||||||
@@ -46,7 +101,4 @@ local kp =
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
k.core.v1.list.new([
|
{ [name + '-ingress']: kp.ingress[name] for name in std.objectFields(kp.ingress) }
|
||||||
kp.ingress['prometheus-k8s'],
|
|
||||||
kp.ingress['basic-auth-secret'],
|
|
||||||
])
|
|
||||||
|
Reference in New Issue
Block a user