Skip to content

Commit

Permalink
Add Metrics-server and Prometheus-adapter (#298)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Jan 12, 2024
1 parent a485a51 commit 7012742
Show file tree
Hide file tree
Showing 7 changed files with 189 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
2 changes: 2 additions & 0 deletions charts/opscenter-features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ The following table lists the configurable parameters of the `opscenter-features
| helm.releases.kubevault-opscenter.version | | <code>"v2023.10.26-rc.0"</code> |
| helm.releases.license-proxyserver.version | | <code>"v2023.11.14"</code> |
| helm.releases.longhorn.version | | <code>"1.5.3"</code> |
| helm.releases.metrics-server.version | | <code>"3.11.0"</code> |
| helm.releases.monitoring-operator.version | | <code>"v0.0.3"</code> |
| helm.releases.opencost.version | | <code>"1.18.1"</code> |
| helm.releases.opscenter-features.version | | <code>"v2023.12.20"</code> |
| helm.releases.panopticon.version | | <code>"v2023.10.1"</code> |
| helm.releases.prepare-cluster.version | | <code>"v2023.12.21"</code> |
| helm.releases.prometheus-adapter.version | | <code>"4.9.0"</code> |
| helm.releases.reloader.version | | <code>"1.0.50"</code> |
| helm.releases.scanner.version | | <code>"v2023.10.18"</code> |
| helm.releases.sidekick.version | | <code>"v2023.12.11"</code> |
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
1 change: 1 addition & 0 deletions features.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ graph TD;
kube-grafana-dashboards-->grafana-operator;
kube-prometheus-stack-->monitoring-operator;
panopticon-->license-proxyserver;
prometheus-adapter-->kube-prometheus-stack;
kubestash-presets-->kubestash;
stash-presets-->stash;
falco-ui-server-->grafana-operator;
Expand Down

0 comments on commit 7012742

Please sign in to comment.