Skip to content

Commit

Permalink
Merge pull request #336 from tomsun28/hertzbeat
Browse files Browse the repository at this point in the history
add hertzbeat helm chart in test module
  • Loading branch information
ks-ci-bot authored Sep 5, 2023
2 parents 4b50b80 + 1c2e413 commit 0ee47e5
Show file tree
Hide file tree
Showing 21 changed files with 1,225 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/hertzbeat/.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/
21 changes: 21 additions & 0 deletions src/test/hertzbeat/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: hertzbeat
description: An open-source, real-time monitoring system with custom monitoring, high performance cluster and agentless capabilities.
type: application
home: https://hertzbeat.com/
sources:
- https://github.com/dromara/hertzbeat
- https://charts.hertzbeat.com
maintainers:
- name: tom
email: [email protected]
icon: https://raw.githubusercontent.com/dromara/hertzbeat/master/home/static/img/hertzbeat-logo.png
# 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.4.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: "v1.4.0"
160 changes: 160 additions & 0 deletions src/test/hertzbeat/README.md

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions src/test/hertzbeat/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
1. Get the application URL by running these commands:
{{- if (eq .Values.expose.type "ingress")}}
{{- range $host := .Values.expose.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.expose.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}

{{- else if contains "NodePort" .Values.expose.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "hertzbeat.fullname" . }}-http)
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.expose.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 "hertzbeat.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "hertzbeat.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.expose.loadBalancer.ports.port }}

{{- else if contains "ClusterIP" .Values.expose.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "hertzbeat.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 }}
67 changes: 67 additions & 0 deletions src/test/hertzbeat/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "hertzbeat.name" -}}
{{- default .Chart.Name | 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 "hertzbeat.fullname" -}}
{{- $name := default .Chart.Name }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{- define "hertzbeat.manager" -}}
{{- printf "%s" (include "hertzbeat.fullname" .) -}}
{{- end -}}

{{- define "hertzbeat.manager.host" -}}
{{- printf "%s-cluster" (include "hertzbeat.manager" .) -}}
{{- end -}}

{{- define "hertzbeat.collector" -}}
{{- printf "%s-collector" (include "hertzbeat.fullname" .) -}}
{{- end -}}

{{- define "hertzbeat.database" -}}
{{- printf "%s-database" (include "hertzbeat.fullname" .) -}}
{{- end -}}

{{- define "hertzbeat.tsdb" -}}
{{- printf "%s-tsdb" (include "hertzbeat.fullname" .) -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "hertzbeat.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "hertzbeat.selectorLabels" -}}
app.kubernetes.io/name: {{ include "hertzbeat.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
47 changes: 47 additions & 0 deletions src/test/hertzbeat/templates/collector/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ include "hertzbeat.collector" . }}"
labels:
{{- include "hertzbeat.labels" . | nindent 4 }}
data:
IDENTITY: ""
MANAGER_IP: "{{ include "hertzbeat.manager.host" . }}"
MANAGER_PORT: "1158"
application.yml: |+
server:
port: 1159
spring:
application:
name: ${HOSTNAME:@hertzbeat-collector@}${PID}
profiles:
active: cluster
jackson:
default-property-inclusion: ALWAYS
# need to disable spring boot mongodb auto config, or default mongodb connection tried and failed...
autoconfigure:
exclude: org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration
---
spring:
config:
activate:
on-profile: cluster
collector:
dispatch:
entrance:
netty:
enabled: true
identity: ${IDENTITY:}
manager-ip: ${MANAGER_IP:127.0.0.1}
manager-port: ${MANAGER_PORT:1158}
common:
queue:
# memory or kafka
type: ${QUEUE_TYPE:netty}
# properties when queue type is kafka
kafka:
servers: ${KAFKA_SERVERS:127.0.0.1:9092}
metrics-data-topic: ${KAFKA_TOPIC:async-metrics-data}
67 changes: 67 additions & 0 deletions src/test/hertzbeat/templates/collector/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "hertzbeat.collector" . }}
labels:
{{- include "hertzbeat.labels" . | nindent 4 }}
component: collector
spec:
{{- if not .Values.collector.autoscaling.enabled }}
replicas: {{ .Values.collector.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "hertzbeat.selectorLabels" . | nindent 6 }}
component: collector
template:
metadata:
{{- with .Values.collector.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "hertzbeat.selectorLabels" . | nindent 8 }}
component: collector
spec:
securityContext:
{{- toYaml .Values.collector.podSecurityContext | nindent 8 }}
containers:
- name: hertzbeat-collector
securityContext:
{{- toYaml .Values.collector.securityContext | nindent 12 }}
image: "{{ .Values.collector.image.repository }}:{{ .Values.collector.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.collector.image.pullPolicy }}
ports:
- containerPort: 1159
protocol: TCP
livenessProbe:
tcpSocket:
port: 1159
readinessProbe:
tcpSocket:
port: 1159
envFrom:
- configMapRef:
name: "{{ include "hertzbeat.collector" . }}"
volumeMounts:
- mountPath: /opt/hertzbeat-collector/config/application.yml
subPath: application.yml
name: application
resources:
{{- toYaml .Values.collector.resources | nindent 12 }}
volumes:
- name: application
configMap:
name: {{ include "hertzbeat.collector" . }}
{{- with .Values.collector.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.collector.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.collector.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions src/test/hertzbeat/templates/collector/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.collector.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "hertzbeat.collector" . }}
labels:
{{- include "hertzbeat.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "hertzbeat.collector" . }}
minReplicas: {{ .Values.collector.autoscaling.minReplicas }}
maxReplicas: {{ .Values.collector.autoscaling.maxReplicas }}
metrics:
{{- if .Values.collector.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.collector.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.collector.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.collector.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions src/test/hertzbeat/templates/database/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ include "hertzbeat.database" . }}"
labels:
{{- include "hertzbeat.labels" . | nindent 4 }}
data:
TZ: "{{ .Values.database.timezone }}"
MYSQL_ROOT_PASSWORD: "{{ .Values.database.rootPassword }}"
schema.sql: |+
set names utf8mb4;
create database if not exists hertzbeat default charset utf8mb4 collate utf8mb4_general_ci;
commit;
29 changes: 29 additions & 0 deletions src/test/hertzbeat/templates/database/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if .Values.database.persistence.enabled }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "hertzbeat.database" . }}
annotations:
{{- range $key, $value := .Values.database.persistence.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if eq .Values.database.persistence.resourcePolicy "keep" }}
helm.sh/resource-policy: keep
{{- end }}
labels:
{{- include "hertzbeat.labels" . | nindent 4 }}
component: database
spec:
accessModes:
- {{ .Values.database.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.database.persistence.size }}
{{- if .Values.database.persistence.storageClass }}
{{- if eq "-" .Values.database.persistence.storageClass }}
storageClassName: ""
{{- else }}
storageClassName: {{ .Values.database.persistence.storageClass }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions src/test/hertzbeat/templates/database/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "hertzbeat.database" . }}
labels:
{{- include "hertzbeat.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: 3306
targetPort: 3306
protocol: TCP
selector:
{{- include "hertzbeat.selectorLabels" . | nindent 4 }}
component: database
Loading

0 comments on commit 0ee47e5

Please sign in to comment.