From 53b31ec856da01b5ceb736e0694bee7496fe65a5 Mon Sep 17 00:00:00 2001 From: CarlosEDP Date: Fri, 1 Feb 2019 11:43:22 -0200 Subject: [PATCH] Added Traefik. Updated image versions --- arm_exporter.jsonnet | 5 +- main.jsonnet | 3 +- .../0prometheus-operator-deployment.yaml | 4 +- manifests/arm-exporter-daemonset.yaml | 8 +- manifests/grafana-deployment.yaml | 17 +---- manifests/node-exporter-daemonset.yaml | 2 +- manifests/prometheus-adapter-deployment.yaml | 2 +- manifests/traefik-serviceMonitor.yaml | 19 +++++ operator_stack.jsonnet | 74 +++++++++---------- traefik.jsonnet | 45 +++++++++++ 10 files changed, 114 insertions(+), 65 deletions(-) create mode 100644 manifests/traefik-serviceMonitor.yaml create mode 100644 traefik.jsonnet diff --git a/arm_exporter.jsonnet b/arm_exporter.jsonnet index cb5dc20..21f0bbb 100644 --- a/arm_exporter.jsonnet +++ b/arm_exporter.jsonnet @@ -25,9 +25,8 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + { local armExporter = container.new('arm-exporter', $._config.imageRepos.armExporter + ':' + $._config.versions.armExporter) + - container.mixin.resources.withRequests({ cpu: '100m', memory: '180Mi' }) + - container.mixin.resources.withLimits({ cpu: '200m', memory: '180Mi' }); - + 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([ diff --git a/main.jsonnet b/main.jsonnet index 6099c2c..e594914 100644 --- a/main.jsonnet +++ b/main.jsonnet @@ -1,2 +1,3 @@ (import 'operator_stack.jsonnet') + -(import 'arm_exporter.jsonnet') +(import 'arm_exporter.jsonnet') + +(import 'traefik.jsonnet') diff --git a/manifests/0prometheus-operator-deployment.yaml b/manifests/0prometheus-operator-deployment.yaml index 833bec9..eb02935 100644 --- a/manifests/0prometheus-operator-deployment.yaml +++ b/manifests/0prometheus-operator-deployment.yaml @@ -20,8 +20,8 @@ spec: - --kubelet-service=kube-system/kubelet - --logtostderr=true - --config-reloader-image=carlosedp/configmap-reload:v0.2.2 - - --prometheus-config-reloader=carlosedp/prometheus-config-reloader:v0.26.0 - image: carlosedp/prometheus-operator:v0.26.0 + - --prometheus-config-reloader=carlosedp/prometheus-config-reloader:v0.28.0 + image: carlosedp/prometheus-operator:v0.28.0 name: prometheus-operator ports: - containerPort: 8080 diff --git a/manifests/arm-exporter-daemonset.yaml b/manifests/arm-exporter-daemonset.yaml index 1d247d0..11b3703 100644 --- a/manifests/arm-exporter-daemonset.yaml +++ b/manifests/arm-exporter-daemonset.yaml @@ -19,11 +19,11 @@ spec: name: arm-exporter resources: limits: - cpu: 200m - memory: 180Mi - requests: cpu: 100m - memory: 180Mi + memory: 100Mi + requests: + cpu: 50m + memory: 50Mi - args: - --secure-listen-address=$(IP):9243 - --upstream=http://127.0.0.1:9243/ diff --git a/manifests/grafana-deployment.yaml b/manifests/grafana-deployment.yaml index 1ef1d7b..6e0b26f 100644 --- a/manifests/grafana-deployment.yaml +++ b/manifests/grafana-deployment.yaml @@ -16,9 +16,7 @@ spec: app: grafana spec: containers: - - args: - - -config=/etc/grafana/grafana.ini - image: carlosedp/monitoring-grafana:v5.4.0 + - image: carlosedp/monitoring-grafana:v5.4.0 name: grafana ports: - containerPort: 3000 @@ -117,16 +115,3 @@ spec: - name: grafana-config secret: secretName: grafana-config - volumeClaimTemplate: - apiVersion: v1 - kind: PersistentVolumeClaim - metadata: - name: grafana-storage - namespace: monitoring - spec: - accessModes: - - ReadWriteMany - resources: - requests: - storage: 2Gi - storageClassName: nfs-ssd-node1 diff --git a/manifests/node-exporter-daemonset.yaml b/manifests/node-exporter-daemonset.yaml index 9b781c7..ed85468 100644 --- a/manifests/node-exporter-daemonset.yaml +++ b/manifests/node-exporter-daemonset.yaml @@ -49,7 +49,7 @@ spec: valueFrom: fieldRef: fieldPath: status.podIP - image: carlosedp/kube-rbac-proxy:v0.4.0 + image: carlosedp/kube-rbac-proxy:v0.4.1 name: kube-rbac-proxy ports: - containerPort: 9100 diff --git a/manifests/prometheus-adapter-deployment.yaml b/manifests/prometheus-adapter-deployment.yaml index ddf6a32..cdba964 100644 --- a/manifests/prometheus-adapter-deployment.yaml +++ b/manifests/prometheus-adapter-deployment.yaml @@ -25,7 +25,7 @@ spec: - --metrics-relist-interval=1m - --prometheus-url=http://prometheus-k8s.monitoring.svc:9090/ - --secure-port=6443 - image: directxman12/k8s-prometheus-adapter-arm64:v0.4.0 + image: directxman12/k8s-prometheus-adapter-arm64:v0.4.1 name: prometheus-adapter ports: - containerPort: 6443 diff --git a/manifests/traefik-serviceMonitor.yaml b/manifests/traefik-serviceMonitor.yaml new file mode 100644 index 0000000..fdf7d3d --- /dev/null +++ b/manifests/traefik-serviceMonitor.yaml @@ -0,0 +1,19 @@ +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + k8s-app: traefik-ingress-lb + name: traefik-ingress-lb + namespace: monitoring +spec: + endpoints: + - interval: 30s + port: admin + scheme: https + jobLabel: k8s-app + namespaceSelector: + matchNames: + - kube-system + selector: + matchLabels: + k8s-app: traefik-ingress-lb diff --git a/operator_stack.jsonnet b/operator_stack.jsonnet index 8b2b49f..7b36362 100644 --- a/operator_stack.jsonnet +++ b/operator_stack.jsonnet @@ -17,15 +17,15 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + { versions+:: { prometheus: "v2.5.0", alertmanager: "v0.15.3", - kubeStateMetrics: "v1.4.0", - kubeRbacProxy: "v0.4.0", + kubeStateMetrics: "v1.5.0", + kubeRbacProxy: "v0.4.1", addonResizer: "2.1", nodeExporter: "v0.17.0", - prometheusOperator: "v0.26.0", - prometheusAdapter: "v0.4.0", + prometheusOperator: "v0.28.0", + prometheusAdapter: "v0.4.1", grafana: "v5.4.0", configmapReloader: "v0.2.2", - prometheusConfigReloader: "v0.26.0", + prometheusConfigReloader: "v0.28.0", }, imageRepos+:: { @@ -136,38 +136,38 @@ local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + { }, # Override command for Grafana to load ini from correct path - grafana+:: { - deployment+: - { - local pvc = k.core.v1.persistentVolumeClaim, - spec+: { - volumeClaimTemplate: - pvc.new() + - pvc.mixin.metadata.withNamespace($._config.namespace) + - pvc.mixin.metadata.withName("grafana-storage") + - pvc.mixin.spec.withAccessModes('ReadWriteMany') + - pvc.mixin.spec.resources.withRequests({ storage: '2Gi' }) + - pvc.mixin.spec.withStorageClassName('nfs-ssd-node1'), - template+: { - spec+: { - containers: - std.map( - function(c) - if c.name == 'grafana' then - c { - args+: [ - '-config=/etc/grafana/grafana.ini', - ], - } - else - c, - super.containers, - ), - }, - }, - }, - }, - }, + // grafana+:: { + // deployment+: + // { + // local pvc = k.core.v1.persistentVolumeClaim, + // spec+: { + // volumeClaimTemplate: + // pvc.new() + + // pvc.mixin.metadata.withNamespace($._config.namespace) + + // pvc.mixin.metadata.withName("grafana-storage") + + // pvc.mixin.spec.withAccessModes('ReadWriteMany') + + // pvc.mixin.spec.resources.withRequests({ storage: '2Gi' }) + + // pvc.mixin.spec.withStorageClassName('nfs-ssd-node1'), + // template+: { + // spec+: { + // containers: + // std.map( + // function(c) + // if c.name == 'grafana' then + // c { + // args+: [ + // '-config=/etc/grafana/grafana.ini', + // ], + // } + // else + // c, + // super.containers, + // ), + // }, + // }, + // }, + // }, + // }, // Override command for addon-resizer due to change from parameter --threshold to --acceptance-offset kubeStateMetrics+:: { diff --git a/traefik.jsonnet b/traefik.jsonnet new file mode 100644 index 0000000..9fa0926 --- /dev/null +++ b/traefik.jsonnet @@ -0,0 +1,45 @@ +local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; + +local kp = (import 'kube-prometheus/kube-prometheus.libsonnet') + { + _config+:: { + namespace: 'monitoring', + }, + + traefik+:: { + serviceMonitor: + { + + apiVersion: 'monitoring.coreos.com/v1', + kind: 'ServiceMonitor', + metadata: { + name: 'traefik-ingress-lb', + namespace: $._config.namespace, + labels: { + 'k8s-app': 'traefik-ingress-lb', + }, + }, + spec: { + jobLabel: 'k8s-app', + selector: { + matchLabels: { + 'k8s-app': 'traefik-ingress-lb', + }, + }, + endpoints: [ + { + port: 'admin', + scheme: 'https', + interval: '30s', + }, + ], + namespaceSelector: { + matchNames: [ + 'kube-system', + ] + }, + }, + }, + }, +}; + +{ ['traefik-' + name]: kp.traefik[name] for name in std.objectFields(kp.traefik) } \ No newline at end of file