From a78ad7a7f90e601c9b861794077bb2be19b81e6d Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Thu, 22 Apr 2021 15:43:10 +0200 Subject: [PATCH] feat: integrating metrics support for Istio with KubeZero metrics --- charts/kubezero-istio-ingress/Chart.yaml | 2 +- .../templates/podmonitor.yaml | 36 +++++++++++++++++++ charts/kubezero-istio-ingress/values.yaml | 6 ++++ charts/kubezero-istio/Chart.yaml | 2 +- charts/kubezero-istio/README.md.gotmpl | 6 ++++ .../templates/servicemonitor.yaml | 18 ++++++++++ charts/kubezero-metrics/values.yaml | 2 ++ charts/kubezero/templates/istio-ingress.yaml | 4 +++ charts/kubezero/templates/istio.yaml | 3 ++ 9 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 charts/kubezero-istio-ingress/templates/podmonitor.yaml create mode 100644 charts/kubezero-istio/templates/servicemonitor.yaml diff --git a/charts/kubezero-istio-ingress/Chart.yaml b/charts/kubezero-istio-ingress/Chart.yaml index a478d3ae..dd1d7ded 100644 --- a/charts/kubezero-istio-ingress/Chart.yaml +++ b/charts/kubezero-istio-ingress/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: kubezero-istio-ingress description: KubeZero Umbrella Chart for Istio based Ingress type: application -version: 0.5.4 +version: 0.5.5 appVersion: 1.9.3 home: https://kubezero.com icon: https://cdn.zero-downtime.net/assets/kubezero/logo-small-64.png diff --git a/charts/kubezero-istio-ingress/templates/podmonitor.yaml b/charts/kubezero-istio-ingress/templates/podmonitor.yaml new file mode 100644 index 00000000..cfe5d51b --- /dev/null +++ b/charts/kubezero-istio-ingress/templates/podmonitor.yaml @@ -0,0 +1,36 @@ +{{- if or ( index .Values "istio-ingress" "telemetry" "enabled" ) ( index .Values "istio-private-ingress" "telemetry" "enabled" )}} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: envoy-stats-monitor + namespace: istio-ingress + labels: + release: metrics +spec: + selector: + matchExpressions: + - {key: istio-prometheus-ignore, operator: DoesNotExist} + jobLabel: envoy-stats + podMetricsEndpoints: + - path: /stats/prometheus + interval: 30s + relabelings: + - action: keep + sourceLabels: [__meta_kubernetes_pod_container_name] + regex: "istio-proxy" + - action: keep + sourceLabels: [__meta_kubernetes_pod_annotationpresent_prometheus_io_scrape] + - sourceLabels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] + action: replace + regex: ([^:]+)(?::\d+)?;(\d+) + replacement: $1:$2 + targetLabel: __address__ + - action: labeldrop + regex: "__meta_kubernetes_pod_label_(.+)" + - sourceLabels: [__meta_kubernetes_namespace] + action: replace + targetLabel: namespace + - sourceLabels: [__meta_kubernetes_pod_name] + action: replace + targetLabel: pod_name +{{- end }} diff --git a/charts/kubezero-istio-ingress/values.yaml b/charts/kubezero-istio-ingress/values.yaml index 0cf503a1..55834185 100644 --- a/charts/kubezero-istio-ingress/values.yaml +++ b/charts/kubezero-istio-ingress/values.yaml @@ -17,6 +17,9 @@ global: istio-ingress: enabled: false + telemetry: + enabled: false + gateways: istio-ingressgateway: autoscaleEnabled: false @@ -90,6 +93,9 @@ istio-ingress: istio-private-ingress: enabled: false + telemetry: + enabled: false + gateways: istio-ingressgateway: # name and labels make the ingress private diff --git a/charts/kubezero-istio/Chart.yaml b/charts/kubezero-istio/Chart.yaml index 67106652..fcc2d7a1 100644 --- a/charts/kubezero-istio/Chart.yaml +++ b/charts/kubezero-istio/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: kubezero-istio description: KubeZero Umbrella Chart for Istio type: application -version: 0.5.4 +version: 0.5.5 appVersion: 1.9.3 home: https://kubezero.com icon: https://cdn.zero-downtime.net/assets/kubezero/logo-small-64.png diff --git a/charts/kubezero-istio/README.md.gotmpl b/charts/kubezero-istio/README.md.gotmpl index 1b4d30f2..3b91ba2e 100644 --- a/charts/kubezero-istio/README.md.gotmpl +++ b/charts/kubezero-istio/README.md.gotmpl @@ -22,3 +22,9 @@ Installs the Istio control plane - https://istio.io/latest/docs/reference/config/istio.operator.v1alpha1/#IstioOperatorSpec - https://github.com/istio/istio/blob/master/manifests/profiles/default.yaml - https://istio.io/latest/docs/setup/install/standalone-operator/ + +### Grafana +- https://grafana.com/grafana/dashboards/7645 +- https://grafana.com/grafana/dashboards/7639 +- https://grafana.com/grafana/dashboards/7636 +- https://grafana.com/grafana/dashboards/7630 diff --git a/charts/kubezero-istio/templates/servicemonitor.yaml b/charts/kubezero-istio/templates/servicemonitor.yaml new file mode 100644 index 00000000..b6451866 --- /dev/null +++ b/charts/kubezero-istio/templates/servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if index .Values "istio-discovery" "telemetry" "enabled" }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: istio-component-monitor + namespace: istio-system + labels: + release: metrics +spec: + jobLabel: istio + targetLabels: [app] + selector: + matchExpressions: + - {key: istio, operator: In, values: [pilot]} + endpoints: + - port: http-monitoring + interval: 30s +{{- end }} diff --git a/charts/kubezero-metrics/values.yaml b/charts/kubezero-metrics/values.yaml index 5a533d44..2e4f52ac 100644 --- a/charts/kubezero-metrics/values.yaml +++ b/charts/kubezero-metrics/values.yaml @@ -65,6 +65,8 @@ kube-prometheus-stack: releaseNamespace: true additional: - kube-system + - istio-system + - istio-ingress - logging admissionWebhooks: diff --git a/charts/kubezero/templates/istio-ingress.yaml b/charts/kubezero/templates/istio-ingress.yaml index 4e8d5c8b..0520737a 100644 --- a/charts/kubezero/templates/istio-ingress.yaml +++ b/charts/kubezero/templates/istio-ingress.yaml @@ -8,6 +8,8 @@ global: {{- if index .Values "istio-ingress" "public" }} istio-ingress: enabled: {{ index .Values "istio-ingress" "public" "enabled" }} + telemetry: + enabled: {{ .Values.metrics.enabled }} {{- with index .Values "istio-ingress" "public" "gateway" }} gateways: istio-ingressgateway: @@ -22,6 +24,8 @@ istio-ingress: {{- if index .Values "istio-ingress" "private" }} istio-private-ingress: enabled: {{ index .Values "istio-ingress" "private" "enabled" }} + telemetry: + enabled: {{ .Values.metrics.enabled }} {{- with index .Values "istio-ingress" "private" "gateway" }} gateways: istio-ingressgateway: diff --git a/charts/kubezero/templates/istio.yaml b/charts/kubezero/templates/istio.yaml index ac750b8e..ecaba88c 100644 --- a/charts/kubezero/templates/istio.yaml +++ b/charts/kubezero/templates/istio.yaml @@ -8,6 +8,9 @@ global: istio-discovery: pilot: replicaCount: 2 + + telemetry: + enabled: {{ .Values.metrics.enabled }} {{- end }} {{- end }}