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 = ...@@ -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 = ...@@ -18,10 +35,47 @@ local kp =
}, },
}, },
}, },
// Create ingress objects per application
ingress+:: { 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.new() +
ingress.mixin.metadata.withName('prometheus-k8s') + 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 = ...@@ -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 = ...@@ -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'],
])
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