diff --git a/charts/ace-installer/templates/apps/monitoring/kube-prometheus-stack.yaml b/charts/ace-installer/templates/apps/monitoring/kube-prometheus-stack.yaml index 296027963..a1a262376 100644 --- a/charts/ace-installer/templates/apps/monitoring/kube-prometheus-stack.yaml +++ b/charts/ace-installer/templates/apps/monitoring/kube-prometheus-stack.yaml @@ -52,6 +52,15 @@ kube-state-metrics: prometheus-node-exporter: image: registry: %s + prometheus: + monitor: + relabelings: + - sourceLabels: [__meta_kubernetes_pod_node_name] + separator: ; + regex: ^(.*)$ + targetLabel: node + replacement: $1 + action: replace ` (include "registry.quay" $) | fromYaml }} # https://github.com/grafana/helm-charts/blob/main/charts/grafana/README.md diff --git a/charts/opscenter-features/templates/featuresets/opscenter-monitoring/kube-prometheus-stack.yaml b/charts/opscenter-features/templates/featuresets/opscenter-monitoring/kube-prometheus-stack.yaml index 16a455ba6..574169cb7 100644 --- a/charts/opscenter-features/templates/featuresets/opscenter-monitoring/kube-prometheus-stack.yaml +++ b/charts/opscenter-features/templates/featuresets/opscenter-monitoring/kube-prometheus-stack.yaml @@ -51,6 +51,15 @@ kube-state-metrics: prometheus-node-exporter: image: registry: %s + prometheus: + monitor: + relabelings: + - sourceLabels: [__meta_kubernetes_pod_node_name] + separator: ; + regex: ^(.*)$ + targetLabel: node + replacement: $1 + action: replace ` (include "registry.quay" $) | fromYaml }} # https://github.com/grafana/helm-charts/blob/main/charts/grafana/README.md diff --git a/charts/opscenter-features/templates/featuresets/opscenter-monitoring/metrics-server.yaml b/charts/opscenter-features/templates/featuresets/opscenter-monitoring/metrics-server.yaml new file mode 100644 index 000000000..b505e73c9 --- /dev/null +++ b/charts/opscenter-features/templates/featuresets/opscenter-monitoring/metrics-server.yaml @@ -0,0 +1,59 @@ +{{- if not (has "Rancher" .Values.clusterManagers) }} + +{{ $overrides := printf ` +image: + repository: %s +args: +- --kubelet-insecure-tls +` + (include "image.kubernetes" (merge (dict "_repo" "metrics-server/metrics-server") $)) + | fromYaml }} + +{{ $vals := dict }} +{{ $vals = mergeOverwrite $vals $overrides }} + +apiVersion: ui.k8s.appscode.com/v1alpha1 +kind: Feature +metadata: + name: metrics-server + labels: + app.kubernetes.io/part-of: opscenter-monitoring +spec: + title: Kubernetes Metrics Server + description: | + Container resource metrics for Kubernetes built-in autoscaling pipelines. + icons: + - src: https://cdn.appscode.com/k8s/icons/menu/cluster.svg + type: image/svg+xml + featureSet: opscenter-monitoring + featureBlock: metrics-server + recommended: false + readinessChecks: + resources: + - group: metrics.k8s.io + version: v1beta1 + kind: NodeMetrics + - group: metrics.k8s.io + version: v1beta1 + kind: PodMetrics + workloads: + - group: apps + version: v1 + kind: Deployment + selector: + app.kubernetes.io/instance: metrics-server + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: metrics-server + chart: + name: metrics-server + namespace: monitoring + version: {{ dig "metrics-server" "version" "" $.Values.helm.releases }} + sourceRef: + kind: HelmRepository + name: appscode-charts-oci + namespace: {{ .Release.Namespace }} +{{- with $vals }} + {{- dict "values" . | toYaml | nindent 2 }} +{{- end }} + +{{- end }} diff --git a/charts/opscenter-features/templates/featuresets/opscenter-monitoring/prometheus-adapter.yaml b/charts/opscenter-features/templates/featuresets/opscenter-monitoring/prometheus-adapter.yaml new file mode 100644 index 000000000..9227318a0 --- /dev/null +++ b/charts/opscenter-features/templates/featuresets/opscenter-monitoring/prometheus-adapter.yaml @@ -0,0 +1,105 @@ +{{- if not (has "Rancher" .Values.clusterManagers) }} + +{{ $overrides := printf ` +image: + repository: %s +prometheus: + url: http://kube-prometheus-stack-prometheus +rules: + resource: + cpu: + containerQuery: | + sum by (<<.GroupBy>>) ( + rate(container_cpu_usage_seconds_total{container!="",<<.LabelMatchers>>}[3m]) + ) + nodeQuery: | + sum by (<<.GroupBy>>) ( + rate(node_cpu_seconds_total{mode!="idle",mode!="iowait",mode!="steal",<<.LabelMatchers>>}[3m]) + ) + resources: + overrides: + node: + resource: node + namespace: + resource: namespace + pod: + resource: pod + containerLabel: container + memory: + containerQuery: | + sum by (<<.GroupBy>>) ( + avg_over_time(container_memory_working_set_bytes{container!="",<<.LabelMatchers>>}[3m]) + ) + nodeQuery: | + sum by (<<.GroupBy>>) ( + avg_over_time(node_memory_MemTotal_bytes{<<.LabelMatchers>>}[3m]) + - + avg_over_time(node_memory_MemAvailable_bytes{<<.LabelMatchers>>}[3m]) + ) + resources: + overrides: + node: + resource: node + namespace: + resource: namespace + pod: + resource: pod + containerLabel: container + window: 3m +` + (include "image.kubernetes" (merge (dict "_repo" "prometheus-adapter/prometheus-adapter") $)) + | fromYaml }} + +{{ $vals := dict }} +{{ $vals = mergeOverwrite $vals $overrides }} + +apiVersion: ui.k8s.appscode.com/v1alpha1 +kind: Feature +metadata: + name: prometheus-adapter + labels: + app.kubernetes.io/part-of: opscenter-monitoring +spec: + title: Prometheus Metrics Adapter + description: | + Prometheus Adapter for Kubernetes Metrics APIs + icons: + - src: https://cdn.appscode.com/k8s/icons/menu/cluster.svg + type: image/svg+xml + featureSet: opscenter-monitoring + featureBlock: kube-prometheus-stack + recommended: true + requirements: + features: + - kube-prometheus-stack + readinessChecks: + resources: + - group: metrics.k8s.io + version: v1beta1 + kind: NodeMetrics + - group: metrics.k8s.io + version: v1beta1 + kind: PodMetrics + workloads: + - group: apps + version: v1 + kind: Deployment + selector: + app.kubernetes.io/component: metrics + app.kubernetes.io/instance: prometheus-adapter + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: prometheus-adapter + app.kubernetes.io/part-of: prometheus-adapter + chart: + name: prometheus-adapter + namespace: monitoring + version: {{ dig "prometheus-adapter" "version" "" $.Values.helm.releases }} + sourceRef: + kind: HelmRepository + name: appscode-charts-oci + namespace: {{ .Release.Namespace }} +{{- with $vals }} + {{- dict "values" . | toYaml | nindent 2 }} +{{- end }} + +{{- end }} diff --git a/charts/opscenter-features/values.yaml b/charts/opscenter-features/values.yaml index 477f54d21..8fe027482 100644 --- a/charts/opscenter-features/values.yaml +++ b/charts/opscenter-features/values.yaml @@ -107,6 +107,8 @@ helm: version: "v2023.11.14" longhorn: version: "1.5.3" + metrics-server: + version: "3.11.0" monitoring-operator: version: "v0.0.3" opencost: @@ -117,6 +119,8 @@ helm: version: "v2023.10.1" prepare-cluster: version: "v2023.12.21" + prometheus-adapter: + version: "4.9.0" reloader: version: "1.0.50" scanner: