Skip to content

Commit

Permalink
Add more options for service monitor (#97)
Browse files Browse the repository at this point in the history
Signed-off-by: m.nabokikh <[email protected]>
  • Loading branch information
nabokihms authored Jan 2, 2024
1 parent 30fe350 commit f768816
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 12 deletions.
5 changes: 4 additions & 1 deletion charts/k8s-image-availability-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ apiVersion: v1
appVersion: "v0.5.1"
description: Application for monitoring the cluster workloads image presence in a container registry.
name: k8s-image-availability-exporter
version: "0.8.0"
version: "0.9.0"
kubeVersion: ">=1.14.0-0"
maintainers:
- name: nabokihms
email: [email protected]
22 changes: 19 additions & 3 deletions charts/k8s-image-availability-exporter/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# k8s-image-availability-exporter

![Version: 0.8.0](https://img.shields.io/badge/Version-0.8.0-informational?style=flat-square) ![AppVersion: v0.5.1](https://img.shields.io/badge/AppVersion-v0.5.1-informational?style=flat-square)
![Version: 0.9.0](https://img.shields.io/badge/Version-0.9.0-informational?style=flat-square) ![AppVersion: v0.5.1](https://img.shields.io/badge/AppVersion-v0.5.1-informational?style=flat-square)

Application for monitoring the cluster workloads image presence in a container registry.

Expand All @@ -12,6 +12,12 @@ Kubernetes: `>=1.14.0-0`

This chart bootstraps a [k8s-image-availability-exporter](https://github.com/flant/k8s-image-availability-exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| nabokihms | <[email protected]> | |

## Values

| Key | Type | Default | Description |
Expand All @@ -34,8 +40,18 @@ This chart bootstraps a [k8s-image-availability-exporter](https://github.com/fla
| podDisruptionBudget.maxUnavailable | int/percentage | `nil` | Number or percentage of pods that can be unavailable. |
| priorityClassName | string | `""` | Specify a priority class name to set [pod priority](https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#pod-priority). |
| resources | object | No requests or limits. | Container resource [requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/). See the [API reference](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#resources) for details. |
| serviceMonitor.enabled | bool | `false` | Create [Prometheus Operator](https://github.com/coreos/prometheus-operator) serviceMonitor resource |
| serviceMonitor.interval | string | `"15s"` | Scrape interval for serviceMonitor |
| serviceMonitor.enabled | bool | `false` | Enable Prometheus ServiceMonitor. See the [documentation](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/design.md#servicemonitor) and the [API reference](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitor) for details. |
| serviceMonitor.namespace | string | Release namespace. | Namespace where the ServiceMonitor resource should be deployed. |
| serviceMonitor.interval | duration | `"15s"` | Prometheus scrape interval. |
| serviceMonitor.scrapeTimeout | duration | `nil` | Prometheus scrape timeout. |
| serviceMonitor.labels | object | `{}` | Labels to be added to the ServiceMonitor. # ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec |
| serviceMonitor.annotations | object | `{}` | Annotations to be added to the ServiceMonitor. # ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec |
| serviceMonitor.scheme | string | `""` | HTTP scheme to use for scraping. Can be used with `tlsConfig` for example if using istio mTLS. |
| serviceMonitor.path | string | `"/metrics"` | HTTP path to scrape for metrics. |
| serviceMonitor.tlsConfig | object | `{}` | 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 |
| serviceMonitor.honorLabels | bool | `false` | HonorLabels chooses the metric's labels on collisions with target labels. |
| serviceMonitor.metricRelabelings | list | `[]` | Prometheus scrape metric relabel configs to apply to samples before ingestion. # [Metric Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#metric_relabel_configs) |
| serviceMonitor.relabelings | list | `[]` | Relabel configs to apply to samples before ingestion. # [Relabeling](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config) |
| prometheusRule.enabled | bool | `false` | Create [Prometheus Operator](https://github.com/coreos/prometheus-operator) prometheusRule resource |
| prometheusRule.defaultGroupsEnabled | bool | `true` | Setup default alerts (works only if prometheusRule.enabled is set to true) |
| prometheusRule.additionalGroups | list | `[]` | Additional PrometheusRule groups |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ spec:
ports:
- containerPort: 8080
name: http
image: {{ .Values.k8sImageAvailabilityExporter.image.repository }}:{{ .Values.image.tag | default (printf "v%s" .Chart.AppVersion) }}"
image: {{ .Values.k8sImageAvailabilityExporter.image.repository }}:{{ .Values.k8sImageAvailabilityExporter.image.tag | default (printf "v%s" .Chart.AppVersion) }}"
imagePullPolicy: {{ .Values.k8sImageAvailabilityExporter.image.imagePullPolicy }}
securityContext:
{{ - toYaml .Values.securityContext | nindent 12 }}
{{- toYaml .Values.securityContext | nindent 12 }}
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,52 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
{{- with .Values.serviceMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ template "k8s-image-availability-exporter.fullname" . }}
namespace: {{ . }}
{{- end }}
labels:
app: {{ template "k8s-image-availability-exporter.fullname" . }}
app: {{ template "k8s-image-availability-exporter.fullname" . }} {{- with .Values.serviceMonitor.namespace }}
{{- with .Values.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
endpoints:
- port: http
{{- with .Values.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.serviceMonitor.scheme }}
scheme: {{ . }}
{{- end }}
{{- with .Values.serviceMonitor.bearerTokenFile }}
bearerTokenFile: {{ . }}
{{- end }}
{{- with .Values.serviceMonitor.tlsConfig }}
tlsConfig:
{{- toYaml .| nindent 6 }}
{{- end }}
{{- with .Values.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
path: {{ .Values.serviceMonitor.path }}
honorLabels: {{ .Values.serviceMonitor.honorLabels }}
{{- with .Values.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- tpl (toYaml . | nindent 6) $ }}
{{- end }}
{{- with .Values.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
jobLabel: {{ template "k8s-image-availability-exporter.fullname" . }}
selector:
matchLabels:
app: {{ template "k8s-image-availability-exporter.fullname" . }}
endpoints:
- port: http
interval: {{ .Values.serviceMonitor.interval }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
55 changes: 53 additions & 2 deletions charts/k8s-image-availability-exporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,62 @@ resources: {}
# memory: 128Mi

serviceMonitor:
# -- Create [Prometheus Operator](https://github.com/coreos/prometheus-operator) serviceMonitor resource
# -- Enable Prometheus ServiceMonitor.
# See the [documentation](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/design.md#servicemonitor) and the [API reference](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitor) for details.
enabled: false
# -- Scrape interval for serviceMonitor

# -- Namespace where the ServiceMonitor resource should be deployed.
# @default -- Release namespace.
namespace: ""

# -- (duration) Prometheus scrape interval.
interval: 15s

# -- (duration) Prometheus scrape timeout.
scrapeTimeout:

# -- Labels to be added to the ServiceMonitor.
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
labels: {}

# -- Annotations to be added to the ServiceMonitor.
## ref: https://github.com/coreos/prometheus-operator/blob/master/Documentation/api.md#prometheusspec
annotations: {}

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

# -- HTTP path to scrape for metrics.
path: /metrics

# -- 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: {}

# -- HonorLabels chooses the metric's labels on collisions with target labels.
honorLabels: false

# -- Prometheus scrape 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

prometheusRule:
# -- Create [Prometheus Operator](https://github.com/coreos/prometheus-operator) prometheusRule resource
enabled: false
Expand Down

0 comments on commit f768816

Please sign in to comment.