diff --git a/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet b/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet index a3f59958901e53fa2063feb2516c82fcef7e4083..c4230e197e9e23af57c03d6e7c8b4db1637c4876 100644 --- a/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet +++ b/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet @@ -1,63 +1,70 @@ -local k = import 'github.com/ksonnet/ksonnet-lib/ksonnet.beta.4/k.libsonnet'; -local service = k.core.v1.service; -local servicePort = k.core.v1.service.mixin.spec.portsType; - { _config+:: { eks: { minimumAvailableIPs: 10, - minimumAvailableIPsTime: '10m' - } + minimumAvailableIPsTime: '10m', + }, }, prometheus+: { serviceMonitorCoreDNS+: { - spec+: { - endpoints: [ - { - bearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token", - interval: "15s", - targetPort: 9153 - } - ] + spec+: { + endpoints: [ + { + bearerTokenFile: '/var/run/secrets/kubernetes.io/serviceaccount/token', + interval: '15s', + targetPort: 9153, + }, + ], + }, + }, + AwsEksCniMetricService: { + apiVersion: 'v1', + kind: 'Service', + metadata: { + name: 'aws-node', + namespace: 'kube-system', + labels: { 'k8s-app': 'aws-node' }, + }, + spec: { + ports: [ + { name: 'cni-metrics-port', port: 61678, targetPort: 61678 }, + ], + selector: { 'k8s-app': 'aws-node' }, + clusterIP: 'None', + }, + }, + + serviceMonitorAwsEksCNI: { + apiVersion: 'monitoring.coreos.com/v1', + kind: 'ServiceMonitor', + metadata: { + name: 'awsekscni', + namespace: $._config.namespace, + labels: { + 'k8s-app': 'eks-cni', }, }, - AwsEksCniMetricService: - service.new('aws-node', { 'k8s-app' : 'aws-node' } , servicePort.newNamed('cni-metrics-port', 61678, 61678)) + - service.mixin.metadata.withNamespace('kube-system') + - service.mixin.metadata.withLabels({ 'k8s-app': 'aws-node' }) + - service.mixin.spec.withClusterIp('None'), - serviceMonitorAwsEksCNI: - { - apiVersion: 'monitoring.coreos.com/v1', - kind: 'ServiceMonitor', - metadata: { - name: 'awsekscni', - namespace: $._config.namespace, - labels: { - 'k8s-app': 'eks-cni', + spec: { + jobLabel: 'k8s-app', + selector: { + matchLabels: { + 'k8s-app': 'aws-node', }, }, - spec: { - jobLabel: 'k8s-app', - selector: { - matchLabels: { - 'k8s-app': 'aws-node', - }, - }, - namespaceSelector: { - matchNames: [ - 'kube-system', - ], - }, - endpoints: [ - { - port: 'cni-metrics-port', - interval: '30s', - path: '/metrics', - }, + namespaceSelector: { + matchNames: [ + 'kube-system', ], }, + endpoints: [ + { + port: 'cni-metrics-port', + interval: '30s', + path: '/metrics', + }, + ], }, + }, }, prometheusRules+: { groups+: [ @@ -70,10 +77,10 @@ local servicePort = k.core.v1.service.mixin.spec.portsType; severity: 'critical', }, annotations: { - message: 'Instance {{ $labels.instance }} has less than 10 IPs available.' + message: 'Instance {{ $labels.instance }} has less than 10 IPs available.', }, 'for': $._config.eks.minimumAvailableIPsTime, - alert: 'EksAvailableIPs' + alert: 'EksAvailableIPs', }, ], },