Skip to content

Commit

Permalink
feat: add VictoriaMetrics addon (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
ButterBright authored May 29, 2024
1 parent 38effb0 commit 053db17
Show file tree
Hide file tree
Showing 16 changed files with 6,898 additions and 0 deletions.
23 changes: 23 additions & 0 deletions addons/victoria-metrics-cluster/.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/
9 changes: 9 additions & 0 deletions addons/victoria-metrics-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: victoria-metrics-cluster
description: A VictoriaMetrics cluster Helm chart for KubeBlocks.

type: application

version: 0.1.0

appVersion: "v1.100.1"
Empty file.
66 changes: 66 additions & 0 deletions addons/victoria-metrics-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "victoria-metrics-cluster.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 "victoria-metrics-cluster.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 "victoria-metrics-cluster.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "victoria-metrics-cluster.labels" -}}
helm.sh/chart: {{ include "victoria-metrics-cluster.chart" . }}
{{ include "victoria-metrics-cluster.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "victoria-metrics-cluster.selectorLabels" -}}
app.kubernetes.io/name: {{ include "victoria-metrics-cluster.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "victoria-metrics-cluster.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "victoria-metrics-cluster.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "clustername" -}}
{{ include "victoria-metrics-cluster.fullname" .}}
{{- end}}
68 changes: 68 additions & 0 deletions addons/victoria-metrics-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
name: {{ include "clustername" . }}
labels:
{{- include "victoria-metrics-cluster.labels" . | nindent 4 }}
spec:
clusterDefinitionRef: victoria-metrics
clusterVersionRef: victoria-metrics-{{ default .Chart.AppVersion .Values.clusterVersionOverride }}
terminationPolicy: {{ .Values.terminationPolicy }}
componentSpecs:
- name: vminsert
componentDefRef: vminsert
replicas: {{ .Values.vminsert.replicas | default 1 }}
{{- with .Values.vminsert.resources }}
resources:
{{- with .limits }}
limits:
cpu: {{ .cpu | quote }}
memory: {{ .memory | quote }}
{{- end }}
{{- with .requests }}
requests:
cpu: {{ .cpu | quote }}
memory: {{ .memory | quote }}
{{- end }}
{{- end }}
- name: vmselect
componentDefRef: vmselect
replicas: {{ .Values.vmselect.replicas | default 1 }}
{{- with .Values.vmselect.resources }}
resources:
{{- with .limits }}
limits:
cpu: {{ .cpu | quote }}
memory: {{ .memory | quote }}
{{- end }}
{{- with .requests }}
requests:
cpu: {{ .cpu | quote }}
memory: {{ .memory | quote }}
{{- end }}
{{- end }}
- name: vmstorage
componentDefRef: vmstorage
replicas: {{ .Values.vmstorage.replicas | default 1 }}
{{- with .Values.vmstorage.resources }}
resources:
{{- with .limits }}
limits:
cpu: {{ .cpu | quote }}
memory: {{ .memory | quote }}
{{- end }}
{{- with .requests }}
requests:
cpu: {{ .cpu | quote }}
memory: {{ .memory | quote }}
{{- end }}
{{- end }}
volumeClaimTemplates:
- name: vmstorage-volume
spec:
storageClassName: {{ .Values.storageClassName }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.vmstorage.volume.storage | default "10Gi" }}
Loading

0 comments on commit 053db17

Please sign in to comment.