Skip to content

Commit

Permalink
feat: add helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Jul 28, 2024
1 parent 84af7fc commit d9d5e36
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/nats-blackbox-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
6 changes: 6 additions & 0 deletions charts/nats-blackbox-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions charts/nats-blackbox-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
21 changes: 21 additions & 0 deletions charts/nats-blackbox-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 55 additions & 0 deletions charts/nats-blackbox-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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" . }}
12 changes: 12 additions & 0 deletions charts/nats-blackbox-exporter/templates/pod-monitor.yaml
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions charts/nats-blackbox-exporter/values.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d9d5e36

Please sign in to comment.