diff --git a/README.md b/README.md index 9080bf34..1b893991 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ You can then run `helm search repo christianhuth` to see the current list of ava | [argocd-metrics-server](./charts/argocd-metrics-server) | [argoprojlabs/argocd-extension-metrics](https://quay.io/argoprojlabs/argocd-extension-metrics) | [The ArgoCD Metrics Server connects to Prometheus and displays Metrics in the ArgoCD UI.](https://github.com/argoproj-labs/argocd-extension-metrics) | | [baserow](./charts/baserow) | [baserow/backend](https://hub.docker.com/r/baserow/backend), [baserow/web-frontend](https://hub.docker.com/r/baserow/web-frontend) | [Baserow is an open source no-code database and Airtable alternative.](https://baserow.io) | | [cluster-api-visualizer](./charts/cluster-api-visualizer) | [jont828/cluster-api-visualizer](https://ghcr.io/jont828/cluster-api-visualizer) | [Multicluster resource visualization tool for Cluster API.](https://github.com/Jont828/cluster-api-visualizer) | +| [dns-exporter](./charts/dns-exporter) | [tykling/dns_exporter](https://hub.docker.com/r/tykling/dns_exporter) | [A multi-target Prometheus exporter with an exclusive focus on DNS monitoring.](https://github.com/tykling/dns_exporter) | | [etcd-defrag](./charts/etcd-defrag) | [bitnami/etcd](https://hub.docker.com/r/bitnami/etcd) | [Runs a defragmentation CronJob for ETCD](https://etcd.io/docs/latest/op-guide/maintenance/#defragmentation) | | [github-exporter](./charts/github-exporter) | [githubexporter/github-exporter](https://hub.docker.com/r/githubexporter/github-exporter) | [Prometheus Exporter for generating GitHub Metrics](https://github.com/githubexporter/github-exporter) | | [headwind-mdm](./charts/headwind-mdm) | [headwindmdm/hmdm](https://hub.docker.com/r/headwindmdm/hmdm) | [Headwind MDM is an open source mobile device management software for Android](https://h-mdm.com) | diff --git a/charts/dns-exporter/.helmignore b/charts/dns-exporter/.helmignore new file mode 100644 index 00000000..ca5b4331 --- /dev/null +++ b/charts/dns-exporter/.helmignore @@ -0,0 +1,29 @@ +# 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/ + +# Chart-Testing Files +ci/ + +# Additional Helm Values for Development or Testing +values-*.yaml diff --git a/charts/dns-exporter/CHANGELOG.md b/charts/dns-exporter/CHANGELOG.md new file mode 100644 index 00000000..faf4829d --- /dev/null +++ b/charts/dns-exporter/CHANGELOG.md @@ -0,0 +1,7 @@ +# dns-exporter + +## 1.0.0 + +### Added + +- Changelog diff --git a/charts/dns-exporter/Chart.yaml b/charts/dns-exporter/Chart.yaml new file mode 100644 index 00000000..cf6c0dfb --- /dev/null +++ b/charts/dns-exporter/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: dns-exporter +description: A multi-target Prometheus exporter with an exclusive focus on DNS monitoring +type: application +version: 1.0.0 +appVersion: "v1.1.0" +home: https://github.com/christianhuth/helm-charts +maintainers: + - name: christianhuth + email: christian@knell.it +sources: + - https://github.com/tykling/dns_exporter +annotations: + artifacthub.io/category: monitoring-logging + artifacthub.io/changes: | + - kind: added + description: Changelog + artifacthub.io/screenshots: | + - title: Display DNS exporter results using Grafana + url: https://grafana.com/api/dashboards/20617/images/15803/image + artifacthub.io/signKey: | + fingerprint: EE24F8BB6D099E78FD704F83B5ECDBCDDD485D0E + url: https://charts.christianhuth.de/public.key diff --git a/charts/dns-exporter/README.md b/charts/dns-exporter/README.md new file mode 100644 index 00000000..c2b28777 --- /dev/null +++ b/charts/dns-exporter/README.md @@ -0,0 +1,158 @@ +# dns-exporter + +A multi-target Prometheus exporter with an exclusive focus on DNS monitoring + +## TL;DR; + +```console +helm repo add christianhuth https://charts.christianhuth.de +helm repo update +helm install my-release christianhuth/dns-exporter +``` + +## Introduction + +This chart bootstraps the [Prometheus DNS-Exporter](https://github.com/tykling/dns_exporter) using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.19+ + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +helm repo add christianhuth https://charts.christianhuth.de +helm repo update +helm install my-release christianhuth/dns-exporter +``` + +These commands deploy the DNS-Exporter on the Kubernetes cluster in the default configuration. The [Values](#values) section lists the values that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +### Defining Scrape Targets + +This Helm Charts allows you to create two ServiceMonitors: + +- One for the metrics of the DNS-Exporter itself +- One for the DNS metrics of the targets + +The Scrape Targets can be configured using `.serviceMonitor.targetsMonitor.targets`. +For each Scrape Target we need to define at least the DNS server and ip family (`ipv4` or `ipv6`). +You also have to define the family if you are scraping DNS records unrelated to the ip address type like NS. + +A basic example would look like this: + +```yaml +serviceMonitor: + targetsMonitor: + targets: + - query_name: + - christianhuth.de + family: + - ipv4 + server: + - dns.google +``` + +While this looks like you can define multiple values for the attributes, this is sadly not supported by the DNS-Exporter. +Defining multiple values will result in only the first value taking affect. + +There are more attributes you can define for each target. +A complete list can be found [https://dns-exporter.readthedocs.io/latest/configuration.html#settings](in the official documentation). + +Instead of defining all the attributes (like family, server, ...) for each target again, you can use pre-defined modules or define your own ones using .Values.serviceMonitor.modules. + +```yaml +serviceMonitor: + targetsMonitor: + modules: + google_udp: + family: ipv4 + protocol: udp + server: dns.google + query_type: NS + targets: + - query_name: + - christianhuth.de + module: + - google_udp +``` + +This will result in a query for the NS records of christianhuth.de using the DNS server dns.google with the UDP protocol. +In this example, the ip family is only defined, because DNS-Exporter won't work without defining one. + +## Uninstalling the Chart + +To uninstall the `my-release` deployment: + +```console +helm uninstall my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | Affinity settings for pod assignment | +| autoscaling.enabled | bool | `false` | | +| autoscaling.maxReplicas | int | `100` | | +| autoscaling.minReplicas | int | `1` | | +| autoscaling.targetCPUUtilizationPercentage | int | `80` | | +| extraEnv | list | `[]` | Additional environment variables that will be added to the deployment | +| fullnameOverride | string | `""` | String to fully override `"netcupscp-exporter.fullname"` | +| image.pullPolicy | string | `"Always"` | image pull policy | +| image.registry | string | `"docker.io"` | image registry | +| image.repository | string | `"tykling/dns_exporter"` | image repository | +| image.tag | string | `"v1.1.0"` | Overrides the image tag | +| imagePullSecrets | list | `[]` | If defined, uses a Secret to pull an image from a private Docker registry or repository. | +| ingress.annotations | object | `{}` | | +| ingress.className | string | `""` | | +| ingress.enabled | bool | `false` | | +| ingress.hosts[0].host | string | `"chart-example.local"` | | +| ingress.hosts[0].paths[0].path | string | `"/"` | | +| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | +| ingress.tls | list | `[]` | | +| nameOverride | string | `""` | Provide a name in place of `netcupscp-exporter` | +| nodeSelector | object | `{}` | Node labels for pod assignment | +| podAnnotations | object | `{}` | Annotations to be added to pods | +| podSecurityContext | object | `{}` | pod-level security context | +| replicaCount | int | `1` | Number of replicas | +| resources | object | `{}` | Resource limits and requests for the headwind pods. | +| revisionHistoryLimit | int | `0` | The number of old ReplicaSets to retain | +| securityContext | object | `{}` | container-level security context | +| service.port | int | `80` | Kubernetes port where service is exposed | +| service.type | string | `"ClusterIP"` | Kubernetes service type | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.create | bool | `true` | Specifies whether a service account should be created | +| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| serviceMonitor.enabled | bool | `false` | Enable a prometheus ServiceMonitor | +| serviceMonitor.modules | object | `{}` | Define modules that can be used inside your targets | +| serviceMonitor.selfMonitor.additionalLabels | object | `{}` | Prometheus ServiceMonitor labels | +| serviceMonitor.selfMonitor.enabled | bool | `true` | Enable a prometheus ServiceMonitor to monitor the DNS Exporter | +| serviceMonitor.selfMonitor.interval | string | `"30s"` | Prometheus ServiceMonitor interval | +| serviceMonitor.selfMonitor.metricRelabelings | list | `[]` | Prometheus [MetricRelabelConfigs] to apply to samples before ingestion | +| serviceMonitor.selfMonitor.namespace | string | `""` | Prometheus ServiceMonitor namespace | +| serviceMonitor.selfMonitor.relabelings | list | `[]` | Prometheus [RelabelConfigs] to apply to samples before scraping | +| serviceMonitor.selfMonitor.selector | object | `{}` | Prometheus ServiceMonitor selector | +| serviceMonitor.targetsMonitor.additionalLabels | object | `{}` | Prometheus ServiceMonitor labels | +| serviceMonitor.targetsMonitor.enabled | bool | `true` | Enable a prometheus ServiceMonitor to monitor the Targets of the DNS Exporter | +| serviceMonitor.targetsMonitor.interval | string | `"30s"` | Prometheus ServiceMonitor interval | +| serviceMonitor.targetsMonitor.metricRelabelings | list | `[]` | Prometheus [MetricRelabelConfigs] to apply to samples before ingestion | +| serviceMonitor.targetsMonitor.namespace | string | `""` | Prometheus ServiceMonitor namespace | +| serviceMonitor.targetsMonitor.relabelings | list | `[]` | Prometheus [RelabelConfigs] to apply to samples before scraping | +| serviceMonitor.targetsMonitor.selector | object | `{}` | Prometheus ServiceMonitor selector | +| serviceMonitor.targetsMonitor.targets | list | `[]` | Targets that should be scraped by the DNS-Exporter | +| tolerations | list | `[]` | Toleration labels for pod assignment | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```console +helm install my-release -f values.yaml christianhuth/dns-exporter +``` diff --git a/charts/dns-exporter/README.md.gotmpl b/charts/dns-exporter/README.md.gotmpl new file mode 100644 index 00000000..a082a88a --- /dev/null +++ b/charts/dns-exporter/README.md.gotmpl @@ -0,0 +1,104 @@ +{{ template "chart.header" . }} +{{ template "chart.description" . }} + +## TL;DR; + +```console +helm repo add christianhuth https://charts.christianhuth.de +helm repo update +helm install my-release christianhuth/dns-exporter +``` + +## Introduction + +This chart bootstraps the [Prometheus DNS-Exporter](https://github.com/tykling/dns_exporter) using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.19+ + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +helm repo add christianhuth https://charts.christianhuth.de +helm repo update +helm install my-release christianhuth/dns-exporter +``` + +These commands deploy the DNS-Exporter on the Kubernetes cluster in the default configuration. The [Values](#values) section lists the values that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +### Defining Scrape Targets + +This Helm Charts allows you to create two ServiceMonitors: + +- One for the metrics of the DNS-Exporter itself +- One for the DNS metrics of the targets + +The Scrape Targets can be configured using `.serviceMonitor.targetsMonitor.targets`. +For each Scrape Target we need to define at least the DNS server and ip family (`ipv4` or `ipv6`). +You also have to define the family if you are scraping DNS records unrelated to the ip address type like NS. + +A basic example would look like this: + +```yaml +serviceMonitor: + targetsMonitor: + targets: + - query_name: + - christianhuth.de + family: + - ipv4 + server: + - dns.google +``` + +While this looks like you can define multiple values for the attributes, this is sadly not supported by the DNS-Exporter. +Defining multiple values will result in only the first value taking affect. + +There are more attributes you can define for each target. +A complete list can be found [https://dns-exporter.readthedocs.io/latest/configuration.html#settings](in the official documentation). + +Instead of defining all the attributes (like family, server, ...) for each target again, you can use pre-defined modules or define your own ones using .Values.serviceMonitor.modules. + +```yaml +serviceMonitor: + targetsMonitor: + modules: + google_udp: + family: ipv4 + protocol: udp + server: dns.google + query_type: NS + targets: + - query_name: + - christianhuth.de + module: + - google_udp +``` + +This will result in a query for the NS records of christianhuth.de using the DNS server dns.google with the UDP protocol. +In this example, the ip family is only defined, because DNS-Exporter won't work without defining one. + +## Uninstalling the Chart + +To uninstall the `my-release` deployment: + +```console +helm uninstall my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +{{ template "chart.valuesSection" . }} + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example, + +```console +helm install my-release -f values.yaml christianhuth/dns-exporter +``` diff --git a/charts/dns-exporter/templates/NOTES.txt b/charts/dns-exporter/templates/NOTES.txt new file mode 100644 index 00000000..dfa1cd7e --- /dev/null +++ b/charts/dns-exporter/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dns-exporter.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dns-exporter.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dns-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dns-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/dns-exporter/templates/_helpers.tpl b/charts/dns-exporter/templates/_helpers.tpl new file mode 100644 index 00000000..a9c9a762 --- /dev/null +++ b/charts/dns-exporter/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "dns-exporter.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 "dns-exporter.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 "dns-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "dns-exporter.labels" -}} +helm.sh/chart: {{ include "dns-exporter.chart" . }} +{{ include "dns-exporter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "dns-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dns-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "dns-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "dns-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/dns-exporter/templates/configmap.yaml b/charts/dns-exporter/templates/configmap.yaml new file mode 100644 index 00000000..263dbadc --- /dev/null +++ b/charts/dns-exporter/templates/configmap.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceMonitor.modules }} +apiVersion: v1 +kind: ConfigMap +metadata: + labels: + {{- include "dns-exporter.labels" . | nindent 4 }} + name: {{ include "dns-exporter.fullname" . }} +data: + dns_exporter.yml: | + modules: + {{- .Values.serviceMonitor.modules | toYaml | nindent 6 }} +{{- end }} diff --git a/charts/dns-exporter/templates/deployment.yaml b/charts/dns-exporter/templates/deployment.yaml new file mode 100644 index 00000000..ca8894eb --- /dev/null +++ b/charts/dns-exporter/templates/deployment.yaml @@ -0,0 +1,77 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + {{- include "dns-exporter.labels" . | nindent 4 }} + name: {{ include "dns-exporter.fullname" . }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + revisionHistoryLimit: {{ .Values.revisionHistoryLimit }} + selector: + matchLabels: + {{- include "dns-exporter.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "dns-exporter.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "dns-exporter.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.extraEnv }} + env: + # Additional Settings + {{- .Values.extraEnv | toYaml | nindent 12 }} + {{- end }} + ports: + - name: http + containerPort: 15353 + protocol: TCP + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- if .Values.serviceMonitor.modules }} + volumeMounts: + - name: modules + mountPath: /home/nonroot/dns_exporter.yml + subPath: dns_exporter.yml + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.serviceMonitor.modules }} + volumes: + - name: modules + configMap: + name: {{ include "dns-exporter.fullname" . }} + {{- end }} diff --git a/charts/dns-exporter/templates/hpa.yaml b/charts/dns-exporter/templates/hpa.yaml new file mode 100644 index 00000000..23f0084e --- /dev/null +++ b/charts/dns-exporter/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: autoscaling/v2 +{{- else -}} +apiVersion: autoscaling/v2beta1 +{{- end }} +kind: HorizontalPodAutoscaler +metadata: + labels: + {{- include "dns-exporter.labels" . | nindent 4 }} + name: {{ include "dns-exporter.fullname" . }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "dns-exporter.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/dns-exporter/templates/ingress.yaml b/charts/dns-exporter/templates/ingress.yaml new file mode 100644 index 00000000..0f72da75 --- /dev/null +++ b/charts/dns-exporter/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "dns-exporter.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{- include "dns-exporter.labels" . | nindent 4 }} + name: {{ $fullName }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/dns-exporter/templates/service.yaml b/charts/dns-exporter/templates/service.yaml new file mode 100644 index 00000000..ca52bf7e --- /dev/null +++ b/charts/dns-exporter/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "dns-exporter.fullname" . }} + labels: + {{- include "dns-exporter.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "dns-exporter.selectorLabels" . | nindent 4 }} diff --git a/charts/dns-exporter/templates/serviceaccount.yaml b/charts/dns-exporter/templates/serviceaccount.yaml new file mode 100644 index 00000000..cecdbdaa --- /dev/null +++ b/charts/dns-exporter/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "dns-exporter.serviceAccountName" . }} + labels: + {{- include "dns-exporter.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/dns-exporter/templates/servicemonitor-self.yaml b/charts/dns-exporter/templates/servicemonitor-self.yaml new file mode 100644 index 00000000..7cd2e8a7 --- /dev/null +++ b/charts/dns-exporter/templates/servicemonitor-self.yaml @@ -0,0 +1,38 @@ +{{- if and .Values.serviceMonitor.enabled .Values.serviceMonitor.selfMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "dns-exporter.fullname" . }} + {{- with .Values.serviceMonitor.selfMonitor.namespace }} + namespace: {{ . }} + {{- end }} + labels: + {{- include "dns-exporter.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.selfMonitor.selector }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.serviceMonitor.selfMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: http + {{- with .Values.serviceMonitor.selfMonitor.interval }} + interval: {{ . }} + {{- end }} + path: /metrics + {{- with .Values.serviceMonitor.selfMonitor.relabelings }} + relabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.serviceMonitor.selfMonitor.metricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "dns-exporter.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/dns-exporter/templates/servicemonitor-targets.yaml b/charts/dns-exporter/templates/servicemonitor-targets.yaml new file mode 100644 index 00000000..239739cd --- /dev/null +++ b/charts/dns-exporter/templates/servicemonitor-targets.yaml @@ -0,0 +1,42 @@ +{{- if and .Values.serviceMonitor.enabled .Values.serviceMonitor.targetsMonitor.enabled .Values.serviceMonitor.targetsMonitor.targets }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "dns-exporter.fullname" . }}-for-targets + {{- with .Values.serviceMonitor.targetsMonitor.namespace }} + namespace: {{ . }} + {{- end }} + labels: + {{- include "dns-exporter.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.targetsMonitor.selector }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.serviceMonitor.targetsMonitor.additionalLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + endpoints: + {{- range .Values.serviceMonitor.targetsMonitor.targets }} + - port: http + {{- with $.Values.serviceMonitor.targetsMonitor.interval }} + interval: {{ . }} + {{- end }} + params: + {{- toYaml . | nindent 8 }} + path: /query + {{- with $.Values.serviceMonitor.targetsMonitor.relabelings }} + relabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with $.Values.serviceMonitor.targetsMonitor.metricRelabelings }} + metricRelabelings: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "dns-exporter.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/dns-exporter/values-dev.yaml b/charts/dns-exporter/values-dev.yaml new file mode 100644 index 00000000..f688bf9c --- /dev/null +++ b/charts/dns-exporter/values-dev.yaml @@ -0,0 +1,23 @@ +--- +serviceMonitor: + enabled: true + selfMonitor: + additionalLabels: + release: prometheus + targetsMonitor: + additionalLabels: + release: prometheus + targets: + - query_name: + - christianhuth.de + family: + - ipv4 + server: + - dns.google + query_type: + - a + - aaaa + - mx + - ns + - srv + - txt diff --git a/charts/dns-exporter/values.schema.json b/charts/dns-exporter/values.schema.json new file mode 100644 index 00000000..ea1d5cf3 --- /dev/null +++ b/charts/dns-exporter/values.schema.json @@ -0,0 +1,518 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "properties": { + "affinity": { + "description": "Affinity settings for pod assignment", + "required": [], + "title": "affinity", + "type": "object" + }, + "autoscaling": { + "properties": { + "enabled": { + "default": false, + "required": [], + "title": "enabled", + "type": "boolean" + }, + "maxReplicas": { + "default": 100, + "required": [], + "title": "maxReplicas", + "type": "integer" + }, + "minReplicas": { + "default": 1, + "required": [], + "title": "minReplicas", + "type": "integer" + }, + "targetCPUUtilizationPercentage": { + "default": 80, + "required": [], + "title": "targetCPUUtilizationPercentage", + "type": "integer" + } + }, + "required": [ + "enabled", + "minReplicas", + "maxReplicas", + "targetCPUUtilizationPercentage" + ], + "title": "autoscaling", + "type": "object" + }, + "extraEnv": { + "description": "Additional environment variables that will be added to the deployment", + "items": { + "required": [] + }, + "required": [], + "title": "extraEnv", + "type": "array" + }, + "fullnameOverride": { + "default": "", + "description": "String to fully override `\"netcupscp-exporter.fullname\"`", + "required": [], + "title": "fullnameOverride", + "type": "string" + }, + "global": { + "description": "Global values are values that can be accessed from any chart or subchart by exactly the same name.", + "required": [], + "title": "global", + "type": "object" + }, + "image": { + "properties": { + "pullPolicy": { + "default": "Always", + "description": "image pull policy", + "required": [], + "title": "pullPolicy", + "type": "string" + }, + "registry": { + "default": "docker.io", + "description": "image registry", + "required": [], + "title": "registry", + "type": "string" + }, + "repository": { + "default": "tykling/dns_exporter", + "description": "image repository", + "required": [], + "title": "repository", + "type": "string" + }, + "tag": { + "default": "v1.1.0", + "description": "Overrides the image tag", + "required": [], + "title": "tag", + "type": "string" + } + }, + "required": [ + "registry", + "repository", + "pullPolicy", + "tag" + ], + "title": "image", + "type": "object" + }, + "imagePullSecrets": { + "description": "If defined, uses a Secret to pull an image from a private Docker registry or repository.", + "items": { + "required": [] + }, + "required": [], + "title": "imagePullSecrets", + "type": "array" + }, + "ingress": { + "properties": { + "annotations": { + "required": [], + "title": "annotations", + "type": "object" + }, + "className": { + "default": "", + "required": [], + "title": "className", + "type": "string" + }, + "enabled": { + "default": false, + "required": [], + "title": "enabled", + "type": "boolean" + }, + "hosts": { + "description": "kubernetes.io/ingress.class: nginx\nkubernetes.io/tls-acme: \"true\"", + "items": { + "anyOf": [ + { + "properties": { + "host": { + "default": "chart-example.local", + "required": [], + "title": "host", + "type": "string" + }, + "paths": { + "items": { + "anyOf": [ + { + "properties": { + "path": { + "default": "/", + "required": [], + "title": "path", + "type": "string" + }, + "pathType": { + "default": "ImplementationSpecific", + "required": [], + "title": "pathType", + "type": "string" + } + }, + "required": [ + "path", + "pathType" + ], + "type": "object" + } + ], + "required": [] + }, + "required": [], + "title": "paths", + "type": "array" + } + }, + "required": [ + "host", + "paths" + ], + "type": "object" + } + ], + "required": [] + }, + "required": [], + "title": "hosts", + "type": "array" + }, + "tls": { + "items": { + "required": [] + }, + "required": [], + "title": "tls", + "type": "array" + } + }, + "required": [ + "enabled", + "className", + "annotations", + "hosts", + "tls" + ], + "title": "ingress", + "type": "object" + }, + "nameOverride": { + "default": "", + "description": "Provide a name in place of `netcupscp-exporter`", + "required": [], + "title": "nameOverride", + "type": "string" + }, + "nodeSelector": { + "description": "Node labels for pod assignment", + "required": [], + "title": "nodeSelector", + "type": "object" + }, + "podAnnotations": { + "description": "Annotations to be added to pods", + "required": [], + "title": "podAnnotations", + "type": "object" + }, + "podSecurityContext": { + "description": "pod-level security context", + "required": [], + "title": "podSecurityContext", + "type": "object" + }, + "replicaCount": { + "default": 1, + "description": "Number of replicas", + "required": [], + "title": "replicaCount", + "type": "integer" + }, + "resources": { + "description": "Resource limits and requests for the headwind pods.", + "required": [], + "title": "resources", + "type": "object" + }, + "revisionHistoryLimit": { + "default": 0, + "description": "The number of old ReplicaSets to retain", + "required": [], + "title": "revisionHistoryLimit", + "type": "integer" + }, + "securityContext": { + "description": "container-level security context", + "required": [], + "title": "securityContext", + "type": "object" + }, + "service": { + "properties": { + "port": { + "default": 80, + "description": "Kubernetes port where service is exposed", + "required": [], + "title": "port", + "type": "integer" + }, + "type": { + "default": "ClusterIP", + "description": "Kubernetes service type", + "required": [], + "title": "type", + "type": "string" + } + }, + "required": [ + "type", + "port" + ], + "title": "service", + "type": "object" + }, + "serviceAccount": { + "properties": { + "annotations": { + "description": "Annotations to add to the service account", + "required": [], + "title": "annotations", + "type": "object" + }, + "create": { + "default": true, + "description": "Specifies whether a service account should be created", + "required": [], + "title": "create", + "type": "boolean" + }, + "name": { + "default": "", + "description": "The name of the service account to use.\nIf not set and create is true, a name is generated using the fullname template", + "required": [], + "title": "name", + "type": "string" + } + }, + "required": [ + "create", + "annotations", + "name" + ], + "title": "serviceAccount", + "type": "object" + }, + "serviceMonitor": { + "properties": { + "enabled": { + "default": false, + "description": "Enable a prometheus ServiceMonitor", + "required": [], + "title": "enabled", + "type": "boolean" + }, + "modules": { + "description": "Define modules that can be used inside your targets", + "required": [], + "title": "modules", + "type": "object" + }, + "selfMonitor": { + "description": "google_udp:\n family: ipv4\n protocol: udp\n server: dns.google\n query_type: NS", + "properties": { + "additionalLabels": { + "description": "Prometheus ServiceMonitor labels", + "required": [], + "title": "additionalLabels", + "type": "object" + }, + "enabled": { + "default": true, + "description": "Enable a prometheus ServiceMonitor to monitor the DNS Exporter", + "required": [], + "title": "enabled", + "type": "boolean" + }, + "interval": { + "default": "30s", + "description": "prometheus: kube-prometheus\nPrometheus ServiceMonitor interval", + "required": [], + "title": "interval", + "type": "string" + }, + "metricRelabelings": { + "description": "Prometheus [MetricRelabelConfigs] to apply to samples before ingestion", + "items": { + "required": [] + }, + "required": [], + "title": "metricRelabelings", + "type": "array" + }, + "namespace": { + "default": "", + "description": "Prometheus ServiceMonitor namespace", + "required": [], + "title": "namespace", + "type": "string" + }, + "relabelings": { + "description": "Prometheus [RelabelConfigs] to apply to samples before scraping", + "items": { + "required": [] + }, + "required": [], + "title": "relabelings", + "type": "array" + }, + "selector": { + "description": "release: prometheus\nPrometheus ServiceMonitor selector", + "required": [], + "title": "selector", + "type": "object" + } + }, + "required": [ + "enabled", + "additionalLabels", + "selector", + "interval", + "namespace", + "metricRelabelings", + "relabelings" + ], + "title": "selfMonitor", + "type": "object" + }, + "targetsMonitor": { + "properties": { + "additionalLabels": { + "description": "Prometheus ServiceMonitor labels", + "required": [], + "title": "additionalLabels", + "type": "object" + }, + "enabled": { + "default": true, + "description": "Enable a prometheus ServiceMonitor to monitor the Targets of the DNS Exporter", + "required": [], + "title": "enabled", + "type": "boolean" + }, + "interval": { + "default": "30s", + "description": "prometheus: kube-prometheus\nPrometheus ServiceMonitor interval", + "required": [], + "title": "interval", + "type": "string" + }, + "metricRelabelings": { + "description": "Prometheus [MetricRelabelConfigs] to apply to samples before ingestion", + "items": { + "required": [] + }, + "required": [], + "title": "metricRelabelings", + "type": "array" + }, + "namespace": { + "default": "", + "description": "Prometheus ServiceMonitor namespace", + "required": [], + "title": "namespace", + "type": "string" + }, + "relabelings": { + "description": "Prometheus [RelabelConfigs] to apply to samples before scraping", + "items": { + "required": [] + }, + "required": [], + "title": "relabelings", + "type": "array" + }, + "selector": { + "description": "release: prometheus\nPrometheus ServiceMonitor selector", + "required": [], + "title": "selector", + "type": "object" + }, + "targets": { + "description": "Targets that should be scraped by the DNS-Exporter", + "items": { + "required": [] + }, + "required": [], + "title": "targets", + "type": "array" + } + }, + "required": [ + "enabled", + "additionalLabels", + "selector", + "interval", + "namespace", + "metricRelabelings", + "relabelings", + "targets" + ], + "title": "targetsMonitor", + "type": "object" + } + }, + "required": [ + "enabled", + "modules", + "selfMonitor", + "targetsMonitor" + ], + "title": "serviceMonitor", + "type": "object" + }, + "tolerations": { + "description": "Toleration labels for pod assignment", + "items": { + "required": [] + }, + "required": [], + "title": "tolerations", + "type": "array" + } + }, + "required": [ + "nameOverride", + "fullnameOverride", + "image", + "imagePullSecrets", + "replicaCount", + "revisionHistoryLimit", + "serviceAccount", + "podAnnotations", + "podSecurityContext", + "securityContext", + "service", + "ingress", + "resources", + "autoscaling", + "nodeSelector", + "tolerations", + "affinity", + "extraEnv", + "serviceMonitor" + ], + "type": "object" +} diff --git a/charts/dns-exporter/values.yaml b/charts/dns-exporter/values.yaml new file mode 100644 index 00000000..7df2124b --- /dev/null +++ b/charts/dns-exporter/values.yaml @@ -0,0 +1,149 @@ +# -- Provide a name in place of `netcupscp-exporter` +nameOverride: "" +# -- String to fully override `"netcupscp-exporter.fullname"` +fullnameOverride: "" + +image: + # -- image registry + registry: docker.io + # -- image repository + repository: tykling/dns_exporter + # -- image pull policy + pullPolicy: Always + # -- Overrides the image tag + tag: "v1.1.0" + +# -- If defined, uses a Secret to pull an image from a private Docker registry or repository. +imagePullSecrets: [] + +# -- Number of replicas +replicaCount: 1 + +# -- The number of old ReplicaSets to retain +revisionHistoryLimit: 0 + +serviceAccount: + # -- Specifies whether a service account should be created + create: true + # -- Annotations to add to the service account + annotations: {} + # -- The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +# -- Annotations to be added to pods +podAnnotations: {} + +# -- pod-level security context +podSecurityContext: {} + # fsGroup: 2000 + +# -- container-level security context +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + # -- Kubernetes service type + type: ClusterIP + # -- Kubernetes port where service is exposed + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +# -- Resource limits and requests for the headwind pods. +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# -- Node labels for pod assignment +nodeSelector: {} + +# -- Toleration labels for pod assignment +tolerations: [] + +# -- Affinity settings for pod assignment +affinity: {} + +# -- Additional environment variables that will be added to the deployment +extraEnv: [] + +serviceMonitor: + # -- Enable a prometheus ServiceMonitor + enabled: false + # -- Define modules that can be used inside your targets + modules: {} + # google_udp: + # family: ipv4 + # protocol: udp + # server: dns.google + # query_type: NS + selfMonitor: + # -- Enable a prometheus ServiceMonitor to monitor the DNS Exporter + enabled: true + # -- Prometheus ServiceMonitor labels + additionalLabels: {} + # release: prometheus + # -- Prometheus ServiceMonitor selector + selector: {} + # prometheus: kube-prometheus + # -- Prometheus ServiceMonitor interval + interval: 30s + # -- Prometheus ServiceMonitor namespace + namespace: "" + # -- Prometheus [MetricRelabelConfigs] to apply to samples before ingestion + metricRelabelings: [] + # -- Prometheus [RelabelConfigs] to apply to samples before scraping + relabelings: [] + targetsMonitor: + # -- Enable a prometheus ServiceMonitor to monitor the Targets of the DNS Exporter + enabled: true + # -- Prometheus ServiceMonitor labels + additionalLabels: {} + # release: prometheus + # -- Prometheus ServiceMonitor selector + selector: {} + # prometheus: kube-prometheus + # -- Prometheus ServiceMonitor interval + interval: 30s + # -- Prometheus ServiceMonitor namespace + namespace: "" + # -- Prometheus [MetricRelabelConfigs] to apply to samples before ingestion + metricRelabelings: [] + # -- Prometheus [RelabelConfigs] to apply to samples before scraping + relabelings: [] + # -- Targets that should be scraped by the DNS-Exporter + targets: []