diff --git a/charts/nats-blackbox-exporter/.helmignore b/charts/nats-blackbox-exporter/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/nats-blackbox-exporter/.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/charts/nats-blackbox-exporter/Chart.yaml b/charts/nats-blackbox-exporter/Chart.yaml new file mode 100644 index 0000000..597d5c0 --- /dev/null +++ b/charts/nats-blackbox-exporter/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: nats-blackbox-exporter +description: A Helm chart for SnappCloud/Platform NATS BlackBox Exporter +type: application +version: 0.0.0 +appVersion: latest diff --git a/charts/nats-blackbox-exporter/templates/_helpers.tpl b/charts/nats-blackbox-exporter/templates/_helpers.tpl new file mode 100644 index 0000000..0ee1738 --- /dev/null +++ b/charts/nats-blackbox-exporter/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "blackbox-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 "blackbox-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 "blackbox-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "blackbox-exporter.labels" -}} +helm.sh/chart: {{ include "blackbox-exporter.chart" . }} +{{ include "blackbox-exporter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "blackbox-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "blackbox-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "blackbox-exporter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "blackbox-exporter.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/nats-blackbox-exporter/templates/configmap.yaml b/charts/nats-blackbox-exporter/templates/configmap.yaml new file mode 100644 index 0000000..72d2fb7 --- /dev/null +++ b/charts/nats-blackbox-exporter/templates/configmap.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "blackbox-exporter.fullname" . }} +data: + config.yaml: | + logger: + level: {{ .Values.logLevel | quote}} + nats: + streams: {{ .Values.nats.streams | toYaml | nindent 8 }} + url: nats://{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local:4222 + publish_interval: {{ .Values.nats.publish_interval | quote }} + request_timeout: {{ .Values.nats.request_timeout | quote }} + max_pub_acks_inflight: {{ .Values.nats.rmax_pub_acks_inflight | quote }} + queue_subscription_group: {{ .Values.nats.queue_subscription_group | quote }} + flush_timeout: {{ .Values.nats.flush_timeout | quote }} + new_stream_allow: {{ .Values.nats.new_stream_allow }} + metric: + server: + address: ":8080" + enabled: true \ No newline at end of file diff --git a/charts/nats-blackbox-exporter/templates/deployment.yaml b/charts/nats-blackbox-exporter/templates/deployment.yaml new file mode 100644 index 0000000..ecd390f --- /dev/null +++ b/charts/nats-blackbox-exporter/templates/deployment.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "blackbox-exporter.fullname" . }} + labels: + {{- include "blackbox-exporter.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "blackbox-exporter.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "blackbox-exporter.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + 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 }}" + args: + - --configPath + - /app/setting/config.yaml + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: metrics + containerPort: {{ .Values.metrics.port }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: config + mountPath: /app/setting + volumes: + - name: config + configMap: + name: {{ include "blackbox-exporter.fullname" . }} diff --git a/charts/nats-blackbox-exporter/templates/pod-monitor.yaml b/charts/nats-blackbox-exporter/templates/pod-monitor.yaml new file mode 100644 index 0000000..412052a --- /dev/null +++ b/charts/nats-blackbox-exporter/templates/pod-monitor.yaml @@ -0,0 +1,12 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ include "blackbox-exporter.fullname" . }} + labels: + {{- include "blackbox-exporter.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "blackbox-exporter.selectorLabels" . | nindent 6 }} + podMetricsEndpoints: + - port: metrics \ No newline at end of file diff --git a/charts/nats-blackbox-exporter/values.yaml b/charts/nats-blackbox-exporter/values.yaml new file mode 100644 index 0000000..02d56d5 --- /dev/null +++ b/charts/nats-blackbox-exporter/values.yaml @@ -0,0 +1,60 @@ +# Default values for blackbox-exporter. +# to disable exporter just set replicaCount to 0 +replicaCount: 1 + +image: + repository: ghcr.io/snapp-incubator/nats-blackbox-exporter + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + +metrics: + port: 8080 +livenessProbe: + httpGet: + path: /metrics + port: metrics +readinessProbe: + httpGet: + path: /metrics + port: metrics + +logLevel: debug + +nats: + streams: + - name: "stream" + subject: "test" + url: "localhost:4222" + publish_interval: 2s + request_timeout: 50ms + max_pub_acks_inflight: 1000 + queue_subscription_group: "group" + flush_timeout: 2s + new_stream_allow: false