46 lines
1.5 KiB
Jsonnet
46 lines
1.5 KiB
Jsonnet
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
|
local secret = k.core.v1.secret;
|
|
local ingress = k.extensions.v1beta1.ingress;
|
|
local ingressTls = ingress.mixin.spec.tlsType;
|
|
local ingressRule = ingress.mixin.spec.rulesType;
|
|
local httpIngressPath = ingressRule.mixin.http.pathsType;
|
|
|
|
local kp =
|
|
(import 'kube-prometheus/kube-prometheus.libsonnet') +
|
|
{
|
|
_config+:: {
|
|
namespace: 'monitoring',
|
|
},
|
|
ingress+:: {
|
|
'prometheus-k8s':
|
|
ingress.new() +
|
|
ingress.mixin.metadata.withName('prometheus-k8s') +
|
|
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('prometheus.example.com') +
|
|
ingressRule.mixin.http.withPaths(
|
|
httpIngressPath.new() +
|
|
httpIngressPath.mixin.backend.withServiceName('prometheus-k8s') +
|
|
httpIngressPath.mixin.backend.withServicePort('web')
|
|
),
|
|
),
|
|
},
|
|
} + {
|
|
ingress+:: {
|
|
'basic-auth-secret':
|
|
secret.new('basic-auth', { auth: std.base64(importstr 'auth') }) +
|
|
secret.mixin.metadata.withNamespace($._config.namespace),
|
|
},
|
|
};
|
|
|
|
k.core.v1.list.new([
|
|
kp.ingress['prometheus-k8s'],
|
|
kp.ingress['basic-auth-secret'],
|
|
])
|