Remove ksonnet from ingress.jsonnet
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
This commit is contained in:
@@ -1,9 +1,17 @@
|
|||||||
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
local ingress(name, namespace, rules) = {
|
||||||
local secret = k.core.v1.secret;
|
apiVersion: 'extensions/v1beta1',
|
||||||
local ingress = k.extensions.v1beta1.ingress;
|
kind: 'Ingress',
|
||||||
local ingressTls = ingress.mixin.spec.tlsType;
|
metadata: {
|
||||||
local ingressRule = ingress.mixin.spec.rulesType;
|
name: name,
|
||||||
local httpIngressPath = ingressRule.mixin.http.pathsType;
|
namespace: namespace,
|
||||||
|
annotations: {
|
||||||
|
'nginx.ingress.kubernetes.io/auth-type': 'basic',
|
||||||
|
'nginx.ingress.kubernetes.io/auth-secret': 'basic-auth',
|
||||||
|
'nginx.ingress.kubernetes.io/auth-realm': 'Authentication Required',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
spec: { rules: rules },
|
||||||
|
};
|
||||||
|
|
||||||
local kp =
|
local kp =
|
||||||
(import 'kube-prometheus/kube-prometheus.libsonnet') +
|
(import 'kube-prometheus/kube-prometheus.libsonnet') +
|
||||||
@@ -37,67 +45,65 @@ local kp =
|
|||||||
},
|
},
|
||||||
// Create ingress objects per application
|
// Create ingress objects per application
|
||||||
ingress+:: {
|
ingress+:: {
|
||||||
'alertmanager-main':
|
'alertmanager-main': ingress(
|
||||||
ingress.new() +
|
'alertmanager-main',
|
||||||
ingress.mixin.metadata.withName('alertmanager-main') +
|
$._config.namespace,
|
||||||
ingress.mixin.metadata.withNamespace($._config.namespace) +
|
[{
|
||||||
ingress.mixin.metadata.withAnnotations({
|
host: 'alertmanager.example.com',
|
||||||
'nginx.ingress.kubernetes.io/auth-type': 'basic',
|
http: {
|
||||||
'nginx.ingress.kubernetes.io/auth-secret': 'basic-auth',
|
paths: [{
|
||||||
'nginx.ingress.kubernetes.io/auth-realm': 'Authentication Required',
|
backend: {
|
||||||
}) +
|
serviceName: 'alertmanager-main',
|
||||||
ingress.mixin.spec.withRules(
|
servicePort: 'web',
|
||||||
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(
|
||||||
),
|
'grafana',
|
||||||
),
|
$._config.namespace,
|
||||||
grafana:
|
[{
|
||||||
ingress.new() +
|
host: 'grafana.example.com',
|
||||||
ingress.mixin.metadata.withName('grafana') +
|
http: {
|
||||||
ingress.mixin.metadata.withNamespace($._config.namespace) +
|
paths: [{
|
||||||
ingress.mixin.metadata.withAnnotations({
|
backend: {
|
||||||
'nginx.ingress.kubernetes.io/auth-type': 'basic',
|
serviceName: 'grafana',
|
||||||
'nginx.ingress.kubernetes.io/auth-secret': 'basic-auth',
|
servicePort: 'http',
|
||||||
'nginx.ingress.kubernetes.io/auth-realm': 'Authentication Required',
|
},
|
||||||
}) +
|
}],
|
||||||
ingress.mixin.spec.withRules(
|
},
|
||||||
ingressRule.new() +
|
}],
|
||||||
ingressRule.withHost('grafana.example.com') +
|
),
|
||||||
ingressRule.mixin.http.withPaths(
|
'prometheus-k8s': ingress(
|
||||||
httpIngressPath.new() +
|
'prometheus-k8s',
|
||||||
httpIngressPath.mixin.backend.withServiceName('grafana') +
|
$._config.namespace,
|
||||||
httpIngressPath.mixin.backend.withServicePort('http')
|
[{
|
||||||
),
|
host: 'prometheus.example.com',
|
||||||
),
|
http: {
|
||||||
'prometheus-k8s':
|
paths: [{
|
||||||
ingress.new() +
|
backend: {
|
||||||
ingress.mixin.metadata.withName('prometheus-k8s') +
|
serviceName: 'prometheus-k8s',
|
||||||
ingress.mixin.metadata.withNamespace($._config.namespace) +
|
servicePort: 'web',
|
||||||
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')
|
|
||||||
),
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
} + {
|
} + {
|
||||||
// Create basic auth secret - replace 'auth' file with your own
|
// 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') }) +
|
apiVersion: 'v1',
|
||||||
secret.mixin.metadata.withNamespace($._config.namespace),
|
kind: 'Secret',
|
||||||
|
metadata: {
|
||||||
|
name: 'basic-auth',
|
||||||
|
namespace: $._config.namespace,
|
||||||
|
},
|
||||||
|
data: { auth: std.base64(importstr 'auth') },
|
||||||
|
type: 'Opaque',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user