Skip to content
Snippets Groups Projects
Commit 352c9171 authored by Karl Skewes's avatar Karl Skewes
Browse files

kube-prometheus: Example jsonnet ingress, add alertmanager and grafana

parent 71f51bd1
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,23 @@ local kp =
_config+:: {
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+: {
spec+: {
......@@ -18,10 +35,47 @@ local kp =
},
},
},
// Create ingress objects per application
ingress+:: {
'prometheus-k8s':
alertmanager:
ingress.new() +
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-k8s') +
ingress.mixin.metadata.withName('prometheus') +
ingress.mixin.metadata.withNamespace($._config.namespace) +
ingress.mixin.metadata.withAnnotations({
'nginx.ingress.kubernetes.io/auth-type': 'basic',
......@@ -39,6 +93,7 @@ local kp =
),
},
} + {
// Create basic auth secret - replace 'auth' file with your own
ingress+:: {
'basic-auth-secret':
secret.new('basic-auth', { auth: std.base64(importstr 'auth') }) +
......@@ -46,7 +101,4 @@ local kp =
},
};
k.core.v1.list.new([
kp.ingress['prometheus-k8s'],
kp.ingress['basic-auth-secret'],
])
{ [name + '-ingress']: kp.ingress[name] for name in std.objectFields(kp.ingress) }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment