mirror of
https://github.com/carlosedp/cluster-monitoring.git
synced 2024-12-28 00:07:44 +01:00
86 lines
3.2 KiB
Plaintext
86 lines
3.2 KiB
Plaintext
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
|
|
|
local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') +
|
|
(import 'image_sources_versions.jsonnet') +
|
|
{
|
|
_config+:: {
|
|
namespace: 'monitoring',
|
|
},
|
|
|
|
armExporter+:: {
|
|
daemonset:
|
|
local daemonset = k.apps.v1beta2.daemonSet;
|
|
local container = daemonset.mixin.spec.template.spec.containersType;
|
|
local containerPort = container.portsType;
|
|
|
|
local podLabels = { 'k8s-app': 'arm-exporter' };
|
|
|
|
local armExporter =
|
|
container.new('arm-exporter', $._config.imageRepos.armExporter + ':' + $._config.versions.armExporter) +
|
|
container.mixin.resources.withRequests({ cpu: '50m', memory: '50Mi' }) +
|
|
container.mixin.resources.withLimits({ cpu: '100m', memory: '100Mi' });
|
|
local proxy =
|
|
container.new('kube-rbac-proxy', $._config.imageRepos.kubeRbacProxy + ':' + $._config.versions.kubeRbacProxy) +
|
|
container.withArgs([
|
|
'--secure-listen-address=:9243',
|
|
'--upstream=http://127.0.0.1:9243/',
|
|
]) +
|
|
container.withPorts(containerPort.new(9243) + containerPort.withHostPort(9243) + containerPort.withName('https')) +
|
|
container.mixin.resources.withRequests({ cpu: '10m', memory: '20Mi' }) +
|
|
container.mixin.resources.withLimits({ cpu: '20m', memory: '40Mi' });
|
|
local c = [armExporter, proxy];
|
|
|
|
daemonset.new() +
|
|
daemonset.mixin.metadata.withName('arm-exporter') +
|
|
daemonset.mixin.metadata.withNamespace($._config.namespace) +
|
|
daemonset.mixin.metadata.withLabels(podLabels) +
|
|
daemonset.mixin.spec.selector.withMatchLabels(podLabels) +
|
|
daemonset.mixin.spec.template.metadata.withLabels(podLabels) +
|
|
daemonset.mixin.spec.template.spec.withNodeSelector({ 'beta.kubernetes.io/arch': 'arm64' }) +
|
|
daemonset.mixin.spec.template.spec.withContainers(c),
|
|
serviceMonitor:
|
|
{
|
|
apiVersion: 'monitoring.coreos.com/v1',
|
|
kind: 'ServiceMonitor',
|
|
metadata: {
|
|
name: 'arm-exporter',
|
|
namespace: $._config.namespace,
|
|
labels: {
|
|
'k8s-app': 'arm-exporter',
|
|
},
|
|
},
|
|
spec: {
|
|
jobLabel: 'k8s-app',
|
|
selector: {
|
|
matchLabels: {
|
|
'k8s-app': 'arm-exporter',
|
|
},
|
|
},
|
|
endpoints: [
|
|
{
|
|
port: 'https',
|
|
scheme: 'https',
|
|
interval: '30s',
|
|
bearerTokenFile: '/var/run/secrets/kubernetes.io/serviceaccount/token',
|
|
tlsConfig: {
|
|
insecureSkipVerify: true,
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
|
|
service:
|
|
local service = k.core.v1.service;
|
|
local servicePort = k.core.v1.service.mixin.spec.portsType;
|
|
|
|
local armExporterPort = servicePort.newNamed('https', 9243, 'https');
|
|
|
|
service.new('arm-exporter', $.armExporter.daemonset.spec.selector.matchLabels, armExporterPort) +
|
|
service.mixin.metadata.withNamespace($._config.namespace) +
|
|
service.mixin.metadata.withLabels({ 'k8s-app': 'arm-exporter' }) +
|
|
service.mixin.spec.withClusterIp('None'),
|
|
},
|
|
};
|
|
|
|
{ ['arm-exporter-' + name]: kp.armExporter[name] for name in std.objectFields(kp.armExporter) } |