Skip to content

Commit

Permalink
Merge pull request #289 from dysnix/servicemonitorchart
Browse files Browse the repository at this point in the history
Add simple chart
  • Loading branch information
plejik authored Feb 24, 2024
2 parents 7cbae57 + 6403231 commit d2d28b2
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dysnix/servicemonitor-apps/.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/
16 changes: 16 additions & 0 deletions dysnix/servicemonitor-apps/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v2
name: servicemonitor-apps
description: A Helm chart for creating a ServiceMonitor for the apps
version: 0.1.0
appVersion: "1.16.0"

keywords:
- prometheus
- servicemonitor

sources:
- https://github.com/dysnix/charts

maintainers:
- name: tony
email: ar@dysnix.com
49 changes: 49 additions & 0 deletions dysnix/servicemonitor-apps/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "servicemonitor-apps.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 "servicemonitor-apps.fullname" -}}
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Common labels
*/}}
{{- define "servicemonitor-apps.labels" -}}
helm.sh/chart: {{ include "servicemonitor-apps.chart" . }}
{{ include "servicemonitor-apps.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

{{/*
Create the name of the service account to use
*/}}
{{- define "servicemonitor-apps.serviceAccountName" -}}
{{- default (include "servicemonitor-apps.fullname" .) .Values.serviceAccount.name }}
{{- end }}
80 changes: 80 additions & 0 deletions dysnix/servicemonitor-apps/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{{- if not .Values.containers }}
{{ fail ".Values.containers is empty" }}
{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "servicemonitor-apps.fullname" . }}
labels:
{{- include "servicemonitor-apps.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "servicemonitor-apps.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "servicemonitor-apps.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "servicemonitor-apps.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
# Range by containers
containers:
{{- range $container := .Values.containers }}
{{- with $container }}
- name: {{ .name }}
securityContext:
{{- toYaml .securityContext | nindent 12 }}
image: "{{ .image.repository }}:{{ .image.tag }}"
imagePullPolicy: {{ .image.pullPolicy }}
{{- if .command -}}
command:
{{- toYaml .command | nindent 12 }}
{{- end }}
{{- if .args }}
args:
{{- toYaml .args | nindent 12 }}
{{- end }}
ports:
{{- range $name, $port := .ports}}
- name: {{ $name}}
containerPort: {{ $port }}
protocol: TCP
{{- end }}
env:
{{- toYaml .env | nindent 12 -}}
{{- if .livenessProbe }}
livenessProbe:
{{- toYaml .livenessProbe | nindent 12 }}
{{- end }}
{{- if .readinessProbe }}
readinessProbe:
{{- toYaml .readinessProbe | nindent 12 }}
{{- end }}
resources:
{{- toYaml .resources | nindent 12 }}
{{- end }}
{{- end }}
# End containers range
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
19 changes: 19 additions & 0 deletions dysnix/servicemonitor-apps/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "servicemonitor-apps.fullname" . }}
labels:
{{- include "servicemonitor-apps.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
{{- range $container := .Values.containers }}
{{- with $container }}
- port: {{ .metric_port }}
targetPort: {{ .metric_port_name }}
protocol: TCP
name: {{ .metric_port_name }}
{{- end }}
{{- end }}
selector:
{{- include "servicemonitor-apps.selectorLabels" . | nindent 4 }}
10 changes: 10 additions & 0 deletions dysnix/servicemonitor-apps/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "servicemonitor-apps.serviceAccountName" . }}
labels:
{{- include "servicemonitor-apps.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
27 changes: 27 additions & 0 deletions dysnix/servicemonitor-apps/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{ if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "servicemonitor-apps.fullname" . }}
labels:
{{- include "servicemonitor-apps.labels" . | nindent 4 }}
spec:
endpoints:
{{- range $container := .Values.containers }}
{{- with $container }}
- interval: {{ .metric_scrape_interval }}
scrapeTimeout: {{ .scrapeTimeout | default "30s" }}
honorLabels: true
port: {{ .metric_port_name }}
path: {{ .metric_endpoint }}
scheme: http
{{- end }}
{{- end }}
jobLabel: {{ include "servicemonitor-apps.fullname" . }}
selector:
matchLabels:
{{- include "servicemonitor-apps.selectorLabels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
89 changes: 89 additions & 0 deletions dysnix/servicemonitor-apps/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
containers:
- name: ethereum-metrics-exporter
metric_port_name: "http"
metric_port: "9000"
metric_endpoint: "/metrics"
metric_scrape_interval: "15s"
securityContext: {}
image:
repository: ethpandaops/ethereum-metrics-exporter
tag: 0.21.0
pullPolicy: IfNotPresent
args:
- --execution-url
- "http://127.0.0.1:8545"
- --metrics-port
- "9000"
- --execution-modules
- eth,net,rpc,web3,txpool
env: []
ports:
http: "9000"
livenessProbe: null
readinessProbe: null
resources:
requests:
cpu: 0m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
# - name: timestamp-monitor
# metric_port: "timestamp"
# metric_endpoint: "/metrics"
# metric_scrape_interval: "3s"
# securityContext: {}
# image:
# repository: us-docker.pkg.dev/rpcfast/geth-timestamp-diff-exporter/geth
# tag: v0.1.0
# pullPolicy: IfNotPresent
# env:
# - name: GETH_PORT
# value: "8575"
# - name: GETH_HOST
# value: "localhost"
# - name: LISTENER_PORT
# value: "9001"
# ports:
# http: "9001"
# livenessProbe:
# httpGet:
# path: /
# port: timestamp
# readinessProbe:
# httpGet:
# path: /
# port: timestamp
# resources:
# requests:
# cpu: 0m
# memory: 64Mi
# limits:
# cpu: 0m
# memory: 128Mi

serviceAccount:
name: ""
# image:
# repository: nginx
# pullPolicy: IfNotPresent
# # Overrides the image tag whose default is the chart appVersion.
# tag: ""

service:
type: ClusterIP

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit d2d28b2

Please sign in to comment.