Skip to content

Commit

Permalink
Add Metrics-server and Prometheus-adapter
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Jan 12, 2024
1 parent b3b057b commit 893f0d8
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 4 additions & 0 deletions charts/opscenter-features/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 893f0d8

Please sign in to comment.