Skip to content

Commit

Permalink
Merge branch 'nlamirault-feat/servicemonitor'
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaakin committed Jul 21, 2023
2 parents 8f201cb + 97b3256 commit 1532ef0
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 143 deletions.
5 changes: 5 additions & 0 deletions charts/kubernetes-event-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ helm.sh/chart: {{ include "kubernetes-event-exporter.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/component: metrics
app.kubernetes.io/part-of: {{ template "kubernetes-event-exporter.name" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- if .Values.additionalLabels }}
{{ toYaml .Values.additionalLabels }}
{{- end }}
{{- end }}

{{/*
Expand Down
2 changes: 2 additions & 0 deletions charts/kubernetes-event-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
name: {{ include "kubernetes-event-exporter.fullname" . }}-cfg
namespace: {{ template "kubernetes-event-exporter.namespace" . }}
labels:
Expand Down
40 changes: 11 additions & 29 deletions charts/kubernetes-event-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ include "kubernetes-event-exporter.fullname" . }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
{{- with .Values.deploymentLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ include "kubernetes-event-exporter.fullname" . }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "kubernetes-event-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "kubernetes-event-exporter.selectorLabels" . | nindent 8 }}
{{- include "kubernetes-event-exporter.labels" . | nindent 8 }}
spec:
{{- with .Values.global.imagePullSecrets }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
Expand All @@ -38,28 +30,25 @@ spec:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.global.imageRegistry | default .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
- name: metrics
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /-/healthy
port: http
path: /metrics
port: metrics
readinessProbe:
httpGet:
path: /-/ready
port: http
path: /metrics
port: metrics
args:
- -conf=/data/config.yaml
volumeMounts:
- mountPath: /data
name: cfg
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
Expand All @@ -74,14 +63,7 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: cfg
configMap:
name: {{ include "kubernetes-event-exporter.fullname" . }}-cfg
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/kubernetes-event-exporter/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: {{ .Values.rbac.namespaced | ternary "Role" "ClusterRole" }}
metadata:
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
name: {{ include "kubernetes-event-exporter.fullname" . }}
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/kubernetes-event-exporter/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{- if .Values.rbac.create }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: {{ .Values.rbac.namespaced | ternary "RoleBinding" "ClusterRoleBinding" }}
kind: ClusterRoleBinding
metadata:
name: {{ include "kubernetes-event-exporter.fullname" . }}
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
name: {{ include "kubernetes-event-exporter.fullname" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
name: {{ include "kubernetes-event-exporter.serviceAccountName" . }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
labels:
Expand Down
46 changes: 12 additions & 34 deletions charts/kubernetes-event-exporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
{{- if .Values.serviceMonitor.enabled }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "kubernetes-event-exporter.fullname" . }}
{{- if .Values.serviceMonitor.namespace }}
namespace: {{ . }}
{{- else }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
{{- end }}
labels:
{{- include "kubernetes-event-exporter.labels" . | nindent 4 }}
{{- if .Values.serviceMonitor.additionalLabels }}
{{ toYaml .Values.serviceMonitor.additionalLabels }}
{{- end }}
name: {{ include "kubernetes-event-exporter.fullname" . }}
namespace: {{ include "kubernetes-event-exporter.namespace" . }}
spec:
jobLabel: {{ template "kubernetes-event-exporter.fullname" . }}
endpoints:
- port: metrics
{{- if .Values.serviceMonitor.interval }}
- port: http
interval: {{ .Values.serviceMonitor.interval }}
{{- end }}
{{- if .Values.serviceMonitor.scheme }}
scheme: {{ .Values.serviceMonitor.scheme }}
{{- end }}
{{- if .Values.serviceMonitor.bearerTokenFile }}
bearerTokenFile: {{ .Values.serviceMonitor.bearerTokenFile }}
{{- end }}
{{- if .Values.serviceMonitor.tlsConfig }}
tlsConfig: {{ toYaml .Values.serviceMonitor.tlsConfig | nindent 6 }}
{{- end }}
{{- if .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
{{- end }}
path: /metrics
honorLabels: {{ .Values.serviceMonitor.honorLabels }}
{{- if .Values.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- tpl (toYaml .Values.serviceMonitor.metricRelabelings | nindent 4) . }}
{{- end }}
{{- if .Values.serviceMonitor.relabelings }}
relabelings:
{{ toYaml .Values.serviceMonitor.relabelings | nindent 4 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ template "kubernetes-event-exporter.namespace" . }}
{{- if .Values.serviceMonitor.honorLabels }}
honorLabels: true
{{- end }}
selector:
matchLabels:
{{- include "kubernetes-event-exporter.selectorLabels" . | nindent 6 }}
{{- end -}}
{{- end }}
113 changes: 35 additions & 78 deletions charts/kubernetes-event-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
global:
imagePullSecrets: []

# Default values for event-exporter.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
registry: ghcr.io
repository: resmoio/kubernetes-event-exporter
repository: ghcr.io/resmoio/kubernetes-event-exporter
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
tag: latest

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

## Override the deployment namespace
namespaceOverride: ""
# -- Additional labels to add to all resources
additionalLabels: {}
# app: kubernetes-events-exporter

serviceAccount:
# Specifies whether a service account should be created
Expand All @@ -30,28 +27,21 @@ serviceAccount:
# If not set and create is true, a name is generated using the fullname template
name: ""

deploymentAnnotations: { }
deploymentLabels: {}

podAnnotations: {}
# prometheus.io/scrape: 'true'
# prometheus.io/port: '2112'
# prometheus.io/path: '/metrics'

podLabels: {}

podSecurityContext:
runAsNonRoot: true
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsUser: 65530
runAsGroup: 65530
seccompProfile:
type: RuntimeDefault
podAnnotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '2112'
prometheus.io/path: '/metrics'

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
Expand All @@ -73,20 +63,12 @@ ingress:
# hosts:
# - chart-example.local

# -- Additional Volume mounts
extraVolumeMounts: []

# -- Additional Volumes
extraVolumes: []
## Override the deployment namespace
namespaceOverride: "monitoring"

rbac:
# If true, create & use RBAC resources
create: true
namespaced: false
rules:
- apiGroups: [ "*" ]
resources: [ "*" ]
verbs: [ "get", "watch", "list" ]

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
Expand Down Expand Up @@ -117,47 +99,22 @@ config: |
- name: "dump"
stdout: {}
# Enable this if you're using https://github.com/coreos/prometheus-operator
serviceMonitor:
# -- Enable this if you're using https://github.com/coreos/prometheus-operator
enabled: false
# namespace: monitoring

# Fallback to the prometheus default unless specified
# interval: 10s

## scheme: HTTP scheme to use for scraping. Can be used with `tlsConfig` for example if using istio mTLS.
# scheme: ""
# -- Namespace to deploy the ServiceMonitor
namespace: ""

## tlsConfig: TLS configuration to use when scraping the endpoint. For example if using istio mTLS.
## Of type: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#tlsconfig
# tlsConfig: {}
# -- Fallback to the prometheus default unless specified
interval: 30s

# bearerTokenFile:
# Fallback to the prometheus default unless specified
# scrapeTimeout: 30s

## Used to pass Labels that are used by the Prometheus installed in your cluster to select Service Monitors to work with
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
# -- Add custom labels to the ServiceMonitor resource
additionalLabels: {}
# prometheus: kube-prometheus

honorLabels: false

# Retain the job and instance labels of the metrics pushed to the Pushgateway
# [Scraping Pushgateway](https://github.com/prometheus/pushgateway#configure-the-pushgateway-as-a-target-to-scrape)
honorLabels: true

## Metric relabel configs to apply to samples before ingestion.
## [Metric Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs)
metricRelabelings: []
# - action: keep
# regex: 'kube_(daemonset|deployment|pod|namespace|node|statefulset).+'
# sourceLabels: [__name__]

## Relabel configs to apply to samples before ingestion.
## [Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config)
relabelings: []
# - sourceLabels: [__meta_kubernetes_pod_node_name]
# separator: ;
# regex: ^(.*)$
# targetLabel: nodename
# replacement: $1
# action: replace
# -- Path to scrape metrics
path: /metrics
# -- Timeout for scrape metrics request
scrapeTimeout: 10s

0 comments on commit 1532ef0

Please sign in to comment.