Skip to content

Commit

Permalink
Merge pull request #30 from wrongerror/main
Browse files Browse the repository at this point in the history
[prometheus-node-exporter] Integrate process-exporter and calico-exporter
  • Loading branch information
benjaminhuo authored Dec 15, 2023
2 parents 078dde5 + 99ac760 commit 460c2ce
Show file tree
Hide file tree
Showing 33 changed files with 1,703 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:
python-version: 3.7

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.3.1
uses: helm/chart-testing-action@v2.6.1

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --config .github/linters/ct.yaml)
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: install helm unittest plugin
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Chart dependencies
/charts/*/charts
#/charts/*/charts
.idea
.vscode
ks-prometheus/jsonnetfile.lock.json
Expand Down
11 changes: 10 additions & 1 deletion charts/prometheus-node-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords:
- prometheus
- exporter
type: application
version: 4.20.0
version: 4.21.0
appVersion: 1.6.0
home: https://github.com/prometheus/node_exporter/
sources:
Expand All @@ -23,3 +23,12 @@ annotations:
"artifacthub.io/links": |
- name: Chart Source
url: https://github.com/prometheus-community/helm-charts
dependencies:
- condition: ProcessExporter.enabled
name: ProcessExporter
repository: file://charts/prometheus-process-exporter
version: 0.5.2
- condition: CalicoExporter.enabled
name: CalicoExporter
repository: file://charts/calico-exporter
version: 0.2.0
23 changes: 23 additions & 0 deletions charts/prometheus-node-exporter/charts/calico-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
32 changes: 32 additions & 0 deletions charts/prometheus-node-exporter/charts/calico-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v2
name: CalicoExporter
description: A Helm chart for Calico Exporter on Kubernetes
# Specify the Kubernetes version range that we support.
# We allow pre-release versions for cloud-specific Kubernetes versions such as v1.21.5-gke.1302 or v1.18.9-eks-d1db3c
kubeVersion: ">=v1.19.0-0"
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.2.0"
keywords:
- calico
- prometheus
- exporter
maintainers:
- email: [email protected]
name: wangyifei

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# calico-exporter
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: alerting.kubesphere.io/v2beta1
kind: GlobalRuleGroup
metadata:
annotations:
alerting.kubesphere.io/initial-configuration: |
{"apiVersion":"alerting.kubesphere.io/v2beta1","kind":"GlobalRuleGroup","metadata":{"annotations":{},"labels":{"alerting.kubesphere.io/builtin":"true","alerting.kubesphere.io/enable":"true"},"name":"calico-bgp"},"spec":{"rules":[{"alert":"CalicoBGPRouterDown","annotations":{"description":"Calico BGP router {{ $labels.instance }} ({{ $labels.router_id }}) is down.","runbook_url":"https://alert-runbooks.kubesphere.io/runbooks/calico/calicobgprouterdown","summary":"Calico BGP router is down."},"expr":"calico_bgp_router_info{up=\"false\"} == 1\n","for":"5m","labels":{"rule_id":"6a9f0b8a4c7e4c9d8f3b5a6c0d8f9e7b"},"severity":"critical"},{"alert":"CalicoBGPPeerStateAbnormal","annotations":{"description":"Calico BGP peer {{ $labels.name }} ({{ $labels.ip }}) is not in established state.","runbook_url":"https://alert-runbooks.kubesphere.io/runbooks/calico/calicobgppeerstateabnormal","summary":"Calico BGP peer state is abnormal."},"expr":"calico_bgp_peer_info{bgp_state!=\"Established\"} == 1\n","for":"5m","labels":{"rule_id":"8f7c4f0a9d6a4b0c9f3a7b8c6d7f8e9c"},"severity":"warning"},{"alert":"CalicoBGPPeerBirdStateDown","annotations":{"description":"Calico BGP peer {{ $labels.name }} ({{ $labels.ip }}) has bird state down.","runbook_url":"https://alert-runbooks.kubesphere.io/runbooks/calico/calicobgppeerbirdstatedown","summary":"Calico BGP peer bird state is down."},"expr":"calico_bgp_peer_info{bird_state!=\"up\"} == 1\n","for":"5m","labels":{"rule_id":"9d6b4e1a8c7b4c0d8f3b7a6c0d8f9e7d"},"severity":"critical"},{"alert":"CalicoIPPoolUsageHigh","annotations":{"description":"Calico IP pool {{ $labels.name }} ({{ $labels.cidr }}) has {{ $value | humanizePercentage }} of IPs allocated.","runbook_url":"https://alert-runbooks.kubesphere.io/runbooks/calico/calicopoolusagehigh","summary":"Calico IP pool usage is high."},"expr":"calico_ippool_allocated_ips / calico_ippool_capacity \u003e= 0.9\n","for":"5m","labels":{"rule_id":"a7b8c9d0e1f2g3h4i5j6k7l8m9n0o1p2"},"severity":"warning"}]}}
labels:
alerting.kubesphere.io/builtin: "true"
alerting.kubesphere.io/enable: "true"
name: calico-exporter-rules
spec:
rules:
- alert: CalicoBGPRouterDown
annotations:
description: 'Calico BGP router {{ $labels.instance }} ({{ $labels.router_id }}) is down.'
runbook_url: https://alert-runbooks.kubesphere.io/runbooks/calico/calicobgprouterdown
summary: Calico BGP router is down.
expr: |
calico_bgp_router_info{up="false"} == 1
for: 5m
labels:
rule_id: 6a9f0b8a4c7e4c9d8f3b5a6c0d8f9e7b
severity: critical
- alert: CalicoBGPPeerStateAbnormal
annotations:
description: 'Calico BGP peer {{ $labels.name }} ({{ $labels.ip }}) is not in established state.'
runbook_url: https://alert-runbooks.kubesphere.io/runbooks/calico/calicobgppeerstateabnormal
summary: Calico BGP peer state is abnormal.
expr: |
calico_bgp_peer_info{bgp_state!="Established"} == 1
for: 5m
labels:
rule_id: 8f7c4f0a9d6a4b0c9f3a7b8c6d7f8e9c
severity: warning
- alert: CalicoBGPPeerBirdStateDown
annotations:
description: 'Calico BGP peer {{ $labels.name }} ({{ $labels.ip }}) has bird state down.'
runbook_url: https://alert-runbooks.kubesphere.io/runbooks/calico/calicobgppeerbirdstatedown
summary: Calico BGP peer bird state is down.
expr: |
calico_bgp_peer_info{bird_state!="up"} == 1
for: 5m
labels:
rule_id: 9d6b4e1a8c7b4c0d8f3b7a6c0d8f9e7d
severity: critical
- alert: CalicoIPPoolUsageHigh
annotations:
description: 'Calico IP pool {{ $labels.name }} ({{ $labels.cidr }}) has {{ $value | humanizePercentage }} of IPs allocated.'
runbook_url: https://alert-runbooks.kubesphere.io/runbooks/calico/calicopoolusagehigh
summary: Calico IP pool usage is high.
expr: |
calico_ippool_allocated_ips / calico_ippool_capacity >= 0.9
for: 5m
labels:
rule_id: a7b8c9d0e1f2g3h4i5j6k7l8m9n0o1p2
severity: warning
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{{/* vim: set filetype=mustache: */}}

{{/*
Return the target Kubernetes version
*/}}
{{- define "common.capabilities.kubeVersion" -}}
{{- if .Values.global }}
{{- if .Values.global.kubeVersion }}
{{- .Values.global.kubeVersion -}}
{{- else }}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
{{- end -}}
{{- else }}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for poddisruptionbudget.
*/}}
{{- define "common.capabilities.policy.apiVersion" -}}
{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "policy/v1beta1" -}}
{{- else -}}
{{- print "policy/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for networkpolicy.
*/}}
{{- define "common.capabilities.networkPolicy.apiVersion" -}}
{{- if semverCompare "<1.7-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for cronjob.
*/}}
{{- define "common.capabilities.cronjob.apiVersion" -}}
{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "batch/v1beta1" -}}
{{- else -}}
{{- print "batch/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for deployment.
*/}}
{{- define "common.capabilities.deployment.apiVersion" -}}
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for statefulset.
*/}}
{{- define "common.capabilities.statefulset.apiVersion" -}}
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "apps/v1beta1" -}}
{{- else -}}
{{- print "apps/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "common.capabilities.ingress.apiVersion" -}}
{{- if .Values.ingress -}}
{{- if .Values.ingress.apiVersion -}}
{{- .Values.ingress.apiVersion -}}
{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end }}
{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for RBAC resources.
*/}}
{{- define "common.capabilities.rbac.apiVersion" -}}
{{- if semverCompare "<1.17-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "rbac.authorization.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "rbac.authorization.k8s.io/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for CRDs.
*/}}
{{- define "common.capabilities.crd.apiVersion" -}}
{{- if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "apiextensions.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "apiextensions.k8s.io/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for APIService.
*/}}
{{- define "common.capabilities.apiService.apiVersion" -}}
{{- if semverCompare "<1.10-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "apiregistration.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "apiregistration.k8s.io/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for Horizontal Pod Autoscaler.
*/}}
{{- define "common.capabilities.hpa.apiVersion" -}}
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) -}}
{{- print "autoscaling/v2beta2" -}}
{{- else -}}
{{- print "autoscaling/v2" -}}
{{- end -}}
{{- end -}}

{{/*
Returns true if the used Helm version is 3.3+.
A way to check the used Helm version was not introduced until version 3.3.0 with .Capabilities.HelmVersion, which contains an additional "{}}" structure.
This check is introduced as a regexMatch instead of {{ if .Capabilities.HelmVersion }} because checking for the key HelmVersion in <3.3 results in a "interface not found" error.
**To be removed when the catalog's minimun Helm version is 3.3**
*/}}
{{- define "common.capabilities.supportsHelmVersion" -}}
{{- if regexMatch "{(v[0-9])*[^}]*}}$" (.Capabilities | toString ) }}
{{- true -}}
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{/*
# Containers for the calico-exporter daemonset.
*/}}
{{- define "calico-exporter.daemonset.containers" -}}
- name: calico-exporter
env:
- name: NODENAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
image: "{{ .Values.CalicoExporter.image.repository }}:{{ .Values.CalicoExporter.image.tag }}"
imagePullPolicy: {{ .Values.CalicoExporter.image.pullPolicy }}
args:
- --web.listen-address=127.0.0.1:{{ .Values.CalicoExporter.service.innerPort }}
- --collector.enable-collectors=bgp
resources:
{{ toYaml .Values.CalicoExporter.resources | indent 12 }}
volumeMounts:
- name: var-run-calico
mountPath: /var/run/calico
{{- end }}

{{/*
# Volumes for the calico-exporter daemonset.
*/}}
{{- define "calico-exporter.daemonset.volumes" -}}
- name: var-run-calico
hostPath:
path: /var/run/calico
{{- end }}
Loading

0 comments on commit 460c2ce

Please sign in to comment.