Skip to content

Commit

Permalink
feat: adding monitoring for main-nats and leaf nats, refactored repo (#…
Browse files Browse the repository at this point in the history
…18)

Signed-off-by: Armin Schlegel <armin.schlegel@gmx.de>
  • Loading branch information
siredmar authored Nov 23, 2022
1 parent dcf5983 commit e892c0a
Show file tree
Hide file tree
Showing 28 changed files with 951 additions and 386 deletions.
8 changes: 6 additions & 2 deletions .mdl_style.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
all

rule 'MD013', :line_length => 120
exclude_rule "MD033"
exclude_rule "MD034"
exclude_rule "MD041"
exclude_rule "MD010"
rule "MD013", line_length: 120, code_blocks: false, tables: false, stern: true
rule "MD029", style: "ordered"
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ repos:

# markdown
- repo: https://github.com/markdownlint/markdownlint.git
rev: master
rev: v0.12.0
hooks:
- id: markdownlint_docker
862 changes: 661 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
[stars-url]: https://github.com/edgefarm/edgefarm.monitor/stargazers
[issues-shield]: https://img.shields.io/github/issues/edgefarm/edgefarm.monitor.svg?style=for-the-badge
[issues-url]: https://github.com/edgefarm/edgefarm.monitor/issues
[license-shield]: https://img.shields.io/github/license/edgefarm/semantic-release-helm-oci?logo=mit&style=for-the-badge
[license-url]: https://opensource.org/licenses/MIT

[license-shield]: https://img.shields.io/github/license/edgefarm/edgefarm.monitor?logo=mit&style=for-the-badge
[license-url]: https://opensource.org/licenses/AGPL-3.0

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![AGPL 3.0 License][license-shield]][license-url]

<!-- PROJECT LOGO -->
<br />
Expand All @@ -31,11 +30,11 @@
<hr />
</p>

## About The Project
# About The Project

TODO

### Features
## Features

- feature 1
- feature 2
Expand All @@ -44,45 +43,45 @@ TODO

<!-- GETTING STARTED -->

## Getting Started
# Getting Started

Follow those simple steps, to install edgefarm.monitor in your cluster.

### ✔️ Prerequisites
## ✔️ Prerequisites

TODO

### 💡 [Do not skip] Mandatory step
## 💡 [Do not skip] Mandatory step

TODO, maybe eliiminate this section

### 🎯 Installation
## 🎯 Installation

TODO

It will take around 5 minutes to complete, ...

## Usage
# Usage

TODO

## Examples
# Examples

TODO

## Debugging
# Debugging

TODO

## Takedown
# Takedown

TODO

## History
# History

TODO

## Contributing
# Contributing

TODO

Expand All @@ -96,6 +95,6 @@ Code contributions are very much **welcome**.

<!-- ACKNOWLEDGEMENTS -->

## Acknowledgements
# Acknowledgements

TODO
1 change: 0 additions & 1 deletion charts/cadvisor/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

1 change: 0 additions & 1 deletion charts/grafana-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

7 changes: 7 additions & 0 deletions charts/grafana-agent/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ data:
regex: '(.*cpu.*)|(.*memory.*)|(.*network.*)|container_last_seen'
action: keep
{{- end }}
- job_name: leaf-nats
static_configs:
- targets: {{ .Values.configmap.agent_yaml.config.job.leaf_nats.targets }}
relabel_configs:
- source_labels: [__address__]
target_label: instance
replacement: ${NODE_NAME}
remote_write:
- url: {{ .Values.configmap.agent_yaml.config.remote_write.url }}
basic_auth:
Expand Down
8 changes: 4 additions & 4 deletions charts/grafana-agent/templates/operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps.kubeedge.io/v1alpha1
kind: EdgeApplication
metadata:
name: grafana-agent
labels:
labels:
app.kubernetes.io/name: grafana-agent
namespace: {{ .Values.namespace | default .Release.Namespace }}
spec:
Expand Down Expand Up @@ -58,7 +58,7 @@ spec:
{{- toYaml . | nindent 18 }}
{{- end }}
{{- if or (and .Values.kubeletService.namespace .Values.kubeletService.serviceName) (.Values.extraArgs) }}
volumeMounts:
volumeMounts:
- name: agent-yaml
mountPath: /etc/agent/
args:
Expand All @@ -79,7 +79,7 @@ spec:
{{- with .Values.tolerations }}
volumes:
- name: agent-yaml
configMap:
configMap:
name: grafana-agent-yml
tolerations:
{{- toYaml . | nindent 16 }}
Expand All @@ -93,4 +93,4 @@ spec:
- matchLabels:
{{- with .Values.targetNodeGroupSelectors }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
9 changes: 7 additions & 2 deletions charts/grafana-agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ configmap:
config:
job:
node_exporter:
targets: ["edgeapplication-node-exporter-prometheus-node-exporter.nodegroup.svc:9100"]
targets:
- "edge-node-exporter-prometheus-node-exporter.edge-monitoring.svc:9100"
cadvisor:
targets: ["edgeapplication-cadvisor.nodegroup.svc:8080"]
targets:
- "edge-cadvisor.edge-monitoring.svc:8080"
leaf_nats:
targets:
- "leaf-nats.nats.svc:7777"
remote_write:
url: http://grafana-mimir-nginx.monitoring.svc:80/api/v1/push
basic_auth:
Expand Down
11 changes: 11 additions & 0 deletions charts/main-nats-monitoring/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
appVersion: 0.1.0
description: A Helm chart for main-nats-monitoring components
maintainers:
- email: armin.schlegel@gmx.de
name: siredmar
name: main-nats-monitoring
sources:
- https://github.com/prometheus/node_exporter/
type: application
version: 0.1.0
3 changes: 3 additions & 0 deletions charts/main-nats-monitoring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Main nats monitoring

This helm chart deploys everything that is needed to monitor the main nats cluster.
66 changes: 66 additions & 0 deletions charts/main-nats-monitoring/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "main-nats-monitoring.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "main-nats-monitoring.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "main-nats-monitoring.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "main-nats-monitoring.labels" -}}
{{ include "main-nats-monitoring.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: operator
helm.sh/chart: {{ include "main-nats-monitoring.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "main-nats-monitoring.selectorLabels" -}}
app.kubernetes.io/name: {{ include "main-nats-monitoring.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "main-nats-monitoring.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "main-nats-monitoring.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
apiVersion: monitoring.grafana.com/v1alpha1
kind: GrafanaAgent
metadata:
name: grafana-agent
namespace: monitoring
labels:
app.kubernetes.io/instance: grafana-agent
name: {{ include "main-nats-monitoring.fullname" . }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
spec:
image: grafana/agent:v0.28.0
logLevel: info
serviceAccountName: grafana-agent
serviceAccountName: {{ include "main-nats-monitoring.name" . }}
metrics:
instanceSelector:
matchLabels:
app.kubernetes.io/component: meta-monitoring
app.kubernetes.io/instance: grafana-mimir
app.kubernetes.io/instance: {{ include "main-nats-monitoring.name" . }}
app.kubernetes.io/name: mimir
externalLabels:
cluster: cloud
logs:
instanceSelector:
matchLabels:
agent: grafana-agent-logs
agent: grafana-agent-logs
21 changes: 21 additions & 0 deletions charts/main-nats-monitoring/templates/nats_metric_instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: monitoring.grafana.com/v1alpha1
kind: MetricsInstance
metadata:
name: main-nats
namespace: {{ .Values.namespace | default .Release.Namespace }}
labels:
app.kubernetes.io/component: meta-monitoring
app.kubernetes.io/instance: {{ include "main-nats-monitoring.name" . }}
app.kubernetes.io/name: mimir
spec:
remoteWrite:
- url: http://grafana-mimir-nginx.monitoring.svc:80/api/v1/push
basicAuth:
username:
name: main-nats-monitoring-grafana-creds
key: username
password:
name: main-nats-monitoring-grafana-creds
key: password
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector: {}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: grafana-agent
namespace: monitoring
name: {{ include "main-nats-monitoring.name" . }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: grafana-agent
name: {{ include "main-nats-monitoring.name" . }}
rules:
- apiGroups:
- ""
Expand Down Expand Up @@ -40,12 +40,12 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: grafana-agent
name: {{ include "main-nats-monitoring.name" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: grafana-agent
name: {{ include "main-nats-monitoring.name" . }}
subjects:
- kind: ServiceAccount
name: grafana-agent
namespace: monitoring
name: {{ include "main-nats-monitoring.name" . }}
namespace: {{ .Values.namespace | default .Release.Namespace }}
11 changes: 11 additions & 0 deletions charts/main-nats-monitoring/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: Secret
apiVersion: v1
metadata:
name: main-nats-monitoring-grafana-creds
namespace: {{ .Values.namespace | default .Release.Namespace }}
labels:
app.kubernetes.io/instance: {{ include "main-nats-monitoring.name" . }}
data:
username: {{ .Values.mimir.user | b64enc }}
password: {{ .Values.mimir.password | b64enc }}
type: Opaque
6 changes: 6 additions & 0 deletions charts/main-nats-monitoring/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mimir:
username: user
password: password

agent:
image: grafana/agent:v0.28.0
Loading

0 comments on commit e892c0a

Please sign in to comment.