diff --git a/node-dns-exporter/values.yaml b/node-dns-exporter/values.yaml index 32a1227..50b8bca 100644 --- a/node-dns-exporter/values.yaml +++ b/node-dns-exporter/values.yaml @@ -74,7 +74,7 @@ nodeDns: #listenAddress: 0.0.0.0:8080 #testInterval: 120 -alertFor: #3m +alertFor: #3m # Sets the alertmanager instance as a label # in case the chart is deployed in an environment with diff --git a/rabbitmq-tester/.helmignore b/rabbitmq-tester/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/rabbitmq-tester/.helmignore @@ -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/ diff --git a/rabbitmq-tester/Chart.yaml b/rabbitmq-tester/Chart.yaml new file mode 100644 index 0000000..462efe2 --- /dev/null +++ b/rabbitmq-tester/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: rabbitmq-tester +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 1.0.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "main-980d6c5d" diff --git a/rabbitmq-tester/templates/_helpers.tpl b/rabbitmq-tester/templates/_helpers.tpl new file mode 100644 index 0000000..8f8e956 --- /dev/null +++ b/rabbitmq-tester/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "rabbitmq-tester.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 "rabbitmq-tester.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 "rabbitmq-tester.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "rabbitmq-tester.labels" -}} +helm.sh/chart: {{ include "rabbitmq-tester.chart" . }} +{{ include "rabbitmq-tester.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "rabbitmq-tester.selectorLabels" -}} +app.kubernetes.io/name: {{ include "rabbitmq-tester.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "rabbitmq-tester.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "rabbitmq-tester.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/rabbitmq-tester/templates/alert-rules.yaml b/rabbitmq-tester/templates/alert-rules.yaml new file mode 100644 index 0000000..92584b2 --- /dev/null +++ b/rabbitmq-tester/templates/alert-rules.yaml @@ -0,0 +1,33 @@ +{{- if .Values.alert.alertmanagerEnabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ template "rabbitmq-tester.name" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "rabbitmq-tester.labels" . | nindent 4 }} + alertmanager: {{ .Values.alert.alertManager | default "default" }} +spec: + groups: + - name: Rabbitmq-tester + rules: + - alert: FailedToConnectProducer + annotations: + message: |- + {{`Producer: {{$labels.pod}}({{$labels.node}}) failed to connect to Rabbitmq`}} + expr: 'sum(rabbitmq_test_produce_consume{status="failed",kind="producer"}>0) BY (pod,node,namespace,job,status)' + for: {{ .Values.alert.for | default "3m" }} + labels: + serverity: error + - alert: FailedToConnectConsumer + annotations: + message: |- + {{`Consumer: {{$labels.pod}}({{$labels.node}}) failed to connect to Rabbitmq`}} + expr: 'sum(rabbitmq_test_produce_consume{status="failed",kind="consumer"}>0) BY (pod,node,namespace,job,status)' + for: {{ .Values.alert.for | default "3m" }} + labels: + serverity: error +{{- if .Values.customAlertRules }} +{{ toYaml .Values.customAlertRules | indent 4 }} +{{- end }} +{{- end }} diff --git a/rabbitmq-tester/templates/consumer.yaml b/rabbitmq-tester/templates/consumer.yaml new file mode 100644 index 0000000..e86b87e --- /dev/null +++ b/rabbitmq-tester/templates/consumer.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: {{ include "rabbitmq-tester.fullname" . }}-consumer + labels: + {{- include "rabbitmq-tester.labels" . | nindent 4 }} + app.kubernetes.io/component: consumer +spec: + selector: + matchLabels: + {{- include "rabbitmq-tester.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: consumer + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "rabbitmq-tester.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: consumer + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "rabbitmq-tester.serviceAccountName" . }}-consumer + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: /metrics + port: http + readinessProbe: + httpGet: + path: /metrics + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + args: + - "--listen-address={{ .Values.rabbitmqTester.listenAddress | default "0.0.0.0:8080" }}" + - "--rabbitmq-address={{ .Values.rabbitmqTester.rabbitmqAddress | default "amqp://guest:guest@localhost:5672/"}}" + - "--exchange-name={{ .Values.rabbitmqTester.exchangeName | default "rabbitmq-test-exchange" }}" + - "--is-producer=false" + - "--test-interval-seconds={{ .Values.rabbitmqTester.testInterval | default "120" }}" + - "--node-name={{ .Values.rabbitmqTester.nodeName | default "$(NODE_NAME)" }}" + env: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/rabbitmq-tester/templates/podmonitor.yaml b/rabbitmq-tester/templates/podmonitor.yaml new file mode 100644 index 0000000..a6387e0 --- /dev/null +++ b/rabbitmq-tester/templates/podmonitor.yaml @@ -0,0 +1,47 @@ +{{- if .Values.metrics.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ template "rabbitmq-tester.fullname" . }}-consumer + labels: + {{- include "rabbitmq-tester.labels" . | nindent 4 }} + app.kubernetes.io/component: consumer +spec: + jobLabel: {{ template "rabbitmq-tester.fullname" . }}-consumer + selector: + matchLabels: + {{- include "rabbitmq-tester.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: consumer + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + podMetricsEndpoints: + - port: http + path: /metrics + interval: {{ .Values.metrics.interval | default "15s"}} +{{- end }} + +--- + +{{- if .Values.metrics.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ template "rabbitmq-tester.fullname" . }}-producer + labels: + {{- include "rabbitmq-tester.labels" . | nindent 4 }} + app.kubernetes.io/component: producer +spec: + jobLabel: {{ template "rabbitmq-tester.fullname" . }}-producer + selector: + matchLabels: + {{- include "rabbitmq-tester.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: producer + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + podMetricsEndpoints: + - port: http + path: /metrics + interval: {{ .Values.metrics.interval | default "15s"}} +{{- end }} diff --git a/rabbitmq-tester/templates/producer.yaml b/rabbitmq-tester/templates/producer.yaml new file mode 100644 index 0000000..a199546 --- /dev/null +++ b/rabbitmq-tester/templates/producer.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "rabbitmq-tester.fullname" .}}-producer + labels: + {{- include "rabbitmq-tester.labels" . | nindent 4 }} + app.kubernetes.io/component: producer +spec: + selector: + matchLabels: + {{- include "rabbitmq-tester.selectorLabels" . | nindent 6 }} + app.kubernetes.io/component: producer + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "rabbitmq-tester.selectorLabels" . | nindent 8 }} + app.kubernetes.io/component: producer + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "rabbitmq-tester.serviceAccountName" . }}-producer + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: /metrics + port: http + readinessProbe: + httpGet: + path: /metrics + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + args: + - "--listen-address={{ .Values.rabbitmqTester.listenAddress | default "0.0.0.0:8080" }}" + - "--rabbitmq-address={{ .Values.rabbitmqTester.rabbitmqAddress | default "amqp://guest:guest@localhost:5672/"}}" + - "--exchange-name={{ .Values.rabbitmqTester.exchangeName | default "rabbitmq-test-exchange" }}" + - "--is-producer=true" + - "--test-interval-seconds={{ .Values.rabbitmqTester.testInterval | default "120" }}" + - "--node-name={{ .Values.rabbitmqTester.nodeName | default "$(NODE_NAME)" }}" + env: + - name: NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/rabbitmq-tester/templates/serviceaccount.yaml b/rabbitmq-tester/templates/serviceaccount.yaml new file mode 100644 index 0000000..71ed184 --- /dev/null +++ b/rabbitmq-tester/templates/serviceaccount.yaml @@ -0,0 +1,29 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "rabbitmq-tester.serviceAccountName" . }}-consumer + labels: + {{- include "rabbitmq-tester.labels" . | nindent 4 }} + app.kubernetes.io/component: consumer + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} + +--- + +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "rabbitmq-tester.serviceAccountName" . }}-producer + labels: + {{- include "rabbitmq-tester.labels" . | nindent 4 }} + app.kubernetes.io/component: producer + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/rabbitmq-tester/values.yaml b/rabbitmq-tester/values.yaml new file mode 100644 index 0000000..b27d240 --- /dev/null +++ b/rabbitmq-tester/values.yaml @@ -0,0 +1,86 @@ +# Default values for rabbitmq-tester. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: ghcr.io/evry-ace/rabbitmq-tester + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +fullnameOverride: "" +nameOverride: "" + +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 + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +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 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# We need to set targetPort (Where metrics are hosted) +metrics: + enabled: true + prometheusInstance: kube-prometheus # Select the default prometheus instance. + # Scrape interval. If not set, the Prometheus default scrape interval is used. + # interval: 15s + +alert: + alertmanagerEnabled: true + # alerttime + for: 3m + + # Sets the alertmanager instance as a label + # in case the chart is deployed in an environment with + # multiple alertmanager instances + alertManager: # default + + customAlertRules: [] + # - alert: something + # annotations: + # message: |- + # {{` something is not working `}} + # expr: '' + # for: 10m + # labels: + # severity: warning + +rabbitmqTester: + testInterval: 120 + # rabbitmqAddress: amqp://guest:guest@localhost:5672/ + # exchangeName: rabbitmq-test-exchange + # listenAdress: 0.0.0.0:8080 + # nodeName: ""