From 340bc8da492312852c61eb0b6fa5e8095faf4ed2 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Sun, 3 Sep 2023 23:15:50 +0800 Subject: [PATCH 1/2] add hertzbeat helm chart in test module --- src/test/hertzbeat/.helmignore | 23 ++ src/test/hertzbeat/Chart.yaml | 21 ++ src/test/hertzbeat/README.md | 157 +++++++++++ src/test/hertzbeat/templates/NOTES.txt | 26 ++ src/test/hertzbeat/templates/_helpers.tpl | 67 +++++ .../templates/collector/configmap.yaml | 47 ++++ .../templates/collector/deployment.yaml | 67 +++++ .../hertzbeat/templates/collector/hpa.yaml | 28 ++ .../templates/database/configmap.yaml | 13 + .../hertzbeat/templates/database/pvc.yaml | 29 +++ .../hertzbeat/templates/database/service.yaml | 15 ++ .../templates/database/statefulset.yaml | 99 +++++++ .../templates/manager/configmap.yaml | 246 ++++++++++++++++++ .../templates/manager/deployment.yaml | 72 +++++ .../templates/manager/service-cluster.yaml | 16 ++ .../templates/manager/service-expose.yaml | 44 ++++ .../hertzbeat/templates/tsdb/configmap.yaml | 8 + src/test/hertzbeat/templates/tsdb/pvc.yaml | 29 +++ .../hertzbeat/templates/tsdb/service.yaml | 15 ++ .../hertzbeat/templates/tsdb/statefulset.yaml | 70 +++++ src/test/hertzbeat/values.yaml | 127 +++++++++ 21 files changed, 1219 insertions(+) create mode 100644 src/test/hertzbeat/.helmignore create mode 100644 src/test/hertzbeat/Chart.yaml create mode 100644 src/test/hertzbeat/README.md create mode 100644 src/test/hertzbeat/templates/NOTES.txt create mode 100644 src/test/hertzbeat/templates/_helpers.tpl create mode 100644 src/test/hertzbeat/templates/collector/configmap.yaml create mode 100644 src/test/hertzbeat/templates/collector/deployment.yaml create mode 100644 src/test/hertzbeat/templates/collector/hpa.yaml create mode 100644 src/test/hertzbeat/templates/database/configmap.yaml create mode 100644 src/test/hertzbeat/templates/database/pvc.yaml create mode 100644 src/test/hertzbeat/templates/database/service.yaml create mode 100644 src/test/hertzbeat/templates/database/statefulset.yaml create mode 100644 src/test/hertzbeat/templates/manager/configmap.yaml create mode 100644 src/test/hertzbeat/templates/manager/deployment.yaml create mode 100644 src/test/hertzbeat/templates/manager/service-cluster.yaml create mode 100644 src/test/hertzbeat/templates/manager/service-expose.yaml create mode 100644 src/test/hertzbeat/templates/tsdb/configmap.yaml create mode 100644 src/test/hertzbeat/templates/tsdb/pvc.yaml create mode 100644 src/test/hertzbeat/templates/tsdb/service.yaml create mode 100644 src/test/hertzbeat/templates/tsdb/statefulset.yaml create mode 100644 src/test/hertzbeat/values.yaml diff --git a/src/test/hertzbeat/.helmignore b/src/test/hertzbeat/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/src/test/hertzbeat/.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/src/test/hertzbeat/Chart.yaml b/src/test/hertzbeat/Chart.yaml new file mode 100644 index 00000000..32658db0 --- /dev/null +++ b/src/test/hertzbeat/Chart.yaml @@ -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: tomsun28@outlook.com +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" diff --git a/src/test/hertzbeat/README.md b/src/test/hertzbeat/README.md new file mode 100644 index 00000000..a19bcb07 --- /dev/null +++ b/src/test/hertzbeat/README.md @@ -0,0 +1,157 @@ +# Helm Chart for HertzBeat + +[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/hertzbeat)](https://artifacthub.io/packages/search?repo=hertzbeat) + +

hertzbeat: An open-source, real-time monitoring system with custom monitoring, high performance cluster and agentless capabilities.

— Open in Artifact Hub
+ + +## What is HertzBeat? + +> An open-source, real-time monitoring system with custom monitoring, high performance cluster and agentless capabilities. | 易用友好的开源实时监控告警系统,无需Agent,高性能集群,强大自定义监控能力. + +### Features + +* Combines **monitoring, alarm, and notification** features into one platform, and supports monitoring for web service, database, os, middleware, cloud-native, network and more. +* Easy to use and agentless, offering full web-based operations for monitoring and alerting with just a click of a mouse, all at zero learning cost. +* Makes protocols such as `Http, Jmx, Ssh, Snmp, Jdbc` configurable, allowing you to collect any metrics by simply configuring the template `YML` file online. Imagine being able to quickly adapt to a new monitoring type like K8s or Docker simply by configuring online with HertzBeat. +* High performance, supports horizontal expansion of multi-collector clusters, multi-isolated network monitoring and cloud-edge collaboration. +* Provides flexible alarm threshold rules and timely notifications delivered via `Discord` `Slack` `Telegram` `Email` `Dingtalk` `WeChat` `FeiShu` `Webhook` `SMS` `ServerChan`. + + +> HertzBeat's powerful customization, multi-type support, high performance, easy expansion, and low coupling, aims to help developers and teams quickly build their own monitoring system. +> We also provide **[SaaS Monitoring Cloud](https://console.tancloud.cn)**, users no longer need to deploy a cumbersome monitoring system to monitor their resources. **[Get started online for free](https://console.tancloud.cn)**. + +## Helm Chart for HertzBeat + +This [Helm](https://github.com/kubernetes/helm) chart installs [HertzBeat](https://github.com/dromara/hertzbeat) in a Kubernetes cluster. Welcome to [contribute](https://github.com/dromara/hertzbeat/tree/master/script/helm) to Helm Chart for HertzBeat. + +## Prerequisites + +- Kubernetes cluster 1.20+ +- Helm v3.2.0+ + +## Installation + +### Add Helm repository + +```bash +helm repo add hertzbeat https://charts.hertzbeat.com/ +helm repo update +``` + +### Configure the chart + +The following items can be set via `--set` flag during installation or configured by editing the `values.yaml` directly (need to download the chart first). + +#### Configure how to expose HertzBeat service + +- **Ingress**: The ingress controller must be installed in the Kubernetes cluster. +- **ClusterIP**: Exposes the service on a cluster-internal IP. Choosing this value makes the service only reachable from within the cluster. +- **NodePort**: Exposes the service on each Node’s IP at a static port (the NodePort). You’ll be able to contact the NodePort service, from outside the cluster, by requesting `NodeIP:NodePort`. +- **LoadBalancer**: Exposes the service externally using a cloud provider’s load balancer. + +#### Configure the external URL + +The external URL for HertzBeat core service is used to: + +1. populate the docker/helm commands showed on portal +2. populate the token service URL returned to docker client + +Format: `protocol://domain[:port]`. Usually: + +- if service exposed via `Ingress`, the `domain` should be the value of `expose.ingress.hosts.core` +- if service exposed via `ClusterIP`, the `domain` should be the value of `expose.clusterIP.name` +- if service exposed via `NodePort`, the `domain` should be the IP address of one Kubernetes node +- if service exposed via `LoadBalancer`, set the `domain` as your own domain name and add a CNAME record to map the domain name to the one you got from the cloud provider + +If HertzBeat is deployed behind the proxy, set it as the URL of proxy. + +#### Configure how to persist data + +- **Disable**: The data does not survive the termination of a pod. +- **Persistent Volume Claim(default)**: A default `StorageClass` is needed in the Kubernetes cluster to dynamically provision the volumes. Specify another StorageClass in the `storageClass` or set `existingClaim` if you already have existing persistent volumes to use. + +#### Configure the other items listed in [configuration](#configuration) section + +### Install the chart + +Install the HertzBeat helm chart with a release name `my-release`: +```bash +helm install hertzbeat hertzbeat/hertzbeat +``` + +## Uninstallation + +To uninstall/delete the `hertzbeat` deployment: +```bash +helm uninstall hertzbeat +``` + +## Configuration + +The following table lists the configurable parameters of the HertzBeat chart and the default values. + +| Parameter | Description | Default | +|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------| +| **Expose** | | | +| `expose.type` | How to expose the service: `ingress`, `clusterIP`, `nodePort` or `loadBalancer`, other values will be ignored and the creation of service will be skipped. | `ingress` | +| `expose.clusterIP.name` | The name of ClusterIP service | `hertzbeat` | +| `expose.clusterIP.annotations` | The annotations attached to the ClusterIP service | {} | +| `expose.clusterIP.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | +| `expose.nodePort.name` | The name of NodePort service | `hertzbeat` | +| `expose.nodePort.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | +| `expose.nodePort.ports.nodePort` | The node port HertzBeat listens on when serving HTTP | `30002` | +| `expose.loadBalancer.IP` | The IP of the loadBalancer. It only works when loadBalancer supports assigning IP | `""` | +| `expose.loadBalancer.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | +| `expose.loadBalancer.sourceRanges` | List of IP address ranges to assign to loadBalancerSourceRanges | [] | +| **Manager** | | | +| `manager.resources` | The [resources] to allocate for container | undefined | +| `manager.nodeSelector` | Node labels for pod assignment | `{}` | +| `manager.tolerations` | Tolerations for pod assignment | `[]` | +| `manager.affinity` | Node/Pod affinities | `{}` | +| `manager.podAnnotations` | Annotations to add to the nginx pod | `{}` | +| **Collector** | | | +| `collector.replicaCount` | The replica count | `1` | +| `collector.autoscaling.enable` | Is enable auto scaling collector replicas | `1` | +| `collector.resources` | The [resources] to allocate for container | undefined | +| `collector.nodeSelector` | Node labels for pod assignment | `{}` | +| `collector.tolerations` | Tolerations for pod assignment | `[]` | +| `collector.affinity` | Node/Pod affinities | `{}` | +| `collector.podAnnotations` | Annotations to add to the nginx pod | `{}` | +| **Database** | | | +| `database.timezone` | The database system timezone | `1` | +| `database.rootPassword` | The database root user password | `1` | +| `database.persistence.enabled` | Enable the data persistence or not | `true` | +| `database.persistence.resourcePolicy` | Setting it to `keep` to avoid removing PVCs during a helm delete operation. Leaving it empty will delete PVCs after the chart deleted. Does not affect PVCs created for internal database and redis components. | `keep` | +| `database.persistence.existingClaim` | Use the existing PVC which must be created manually before bound, and specify the `subPath` if the PVC is shared with other components | | +| `database.persistence.storageClass` | Specify the `storageClass` used to provision the volume. Or the default StorageClass will be used (the default). Set it to `-` to disable dynamic provisioning | | +| `database.persistence.subPath` | The sub path used in the volume | | +| `database.persistence.accessMode` | The access mode of the volume | `ReadWriteOnce` | +| `database.persistence.size` | The size of the volume | `5Gi` | +| `database.persistence.annotations` | The annotations of the volume | | +| `database.resources` | The [resources] to allocate for container | undefined | +| `database.nodeSelector` | Node labels for pod assignment | `{}` | +| `database.tolerations` | Tolerations for pod assignment | `[]` | +| `database.affinity` | Node/Pod affinities | `{}` | +| `database.podAnnotations` | Annotations to add to the nginx pod | `{}` | +| **TSDB** | | | +| `tsdb.timezone` | The database system timezone | `1` | +| `tsdb.persistence.enabled` | Enable the data persistence or not | `true` | +| `tsdb.persistence.resourcePolicy` | Setting it to `keep` to avoid removing PVCs during a helm delete operation. Leaving it empty will delete PVCs after the chart deleted. Does not affect PVCs created for internal database and redis components. | `keep` | +| `tsdb.persistence.existingClaim` | Use the existing PVC which must be created manually before bound, and specify the `subPath` if the PVC is shared with other components | | +| `tsdb.persistence.storageClass` | Specify the `storageClass` used to provision the volume. Or the default StorageClass will be used (the default). Set it to `-` to disable dynamic provisioning | | +| `tsdb.persistence.subPath` | The sub path used in the volume | | +| `tsdb.persistence.accessMode` | The access mode of the volume | `ReadWriteOnce` | +| `tsdb.persistence.size` | The size of the volume | `5Gi` | +| `tsdb.persistence.annotations` | The annotations of the volume | | +| `tsdb.resources` | The [resources] to allocate for container | undefined | +| `tsdb.nodeSelector` | Node labels for pod assignment | `{}` | +| `tsdb.tolerations` | Tolerations for pod assignment | `[]` | +| `tsdb.affinity` | Node/Pod affinities | `{}` | +| `tsdb.podAnnotations` | Annotations to add to the nginx pod | `{}` | + + +[resources]: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ +[hertzbeat]: https://github.com/dromara/hertzbeat/ +[artifacthub]: https://artifacthub.io/ +[helm]: https://helm.sh/ diff --git a/src/test/hertzbeat/templates/NOTES.txt b/src/test/hertzbeat/templates/NOTES.txt new file mode 100644 index 00000000..da6b52a0 --- /dev/null +++ b/src/test/hertzbeat/templates/NOTES.txt @@ -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 }} diff --git a/src/test/hertzbeat/templates/_helpers.tpl b/src/test/hertzbeat/templates/_helpers.tpl new file mode 100644 index 00000000..4b64c3a0 --- /dev/null +++ b/src/test/hertzbeat/templates/_helpers.tpl @@ -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 }} diff --git a/src/test/hertzbeat/templates/collector/configmap.yaml b/src/test/hertzbeat/templates/collector/configmap.yaml new file mode 100644 index 00000000..5ef8e73a --- /dev/null +++ b/src/test/hertzbeat/templates/collector/configmap.yaml @@ -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} diff --git a/src/test/hertzbeat/templates/collector/deployment.yaml b/src/test/hertzbeat/templates/collector/deployment.yaml new file mode 100644 index 00000000..5b1de1c5 --- /dev/null +++ b/src/test/hertzbeat/templates/collector/deployment.yaml @@ -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 }} diff --git a/src/test/hertzbeat/templates/collector/hpa.yaml b/src/test/hertzbeat/templates/collector/hpa.yaml new file mode 100644 index 00000000..6a4457c6 --- /dev/null +++ b/src/test/hertzbeat/templates/collector/hpa.yaml @@ -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 }} diff --git a/src/test/hertzbeat/templates/database/configmap.yaml b/src/test/hertzbeat/templates/database/configmap.yaml new file mode 100644 index 00000000..edbc03a6 --- /dev/null +++ b/src/test/hertzbeat/templates/database/configmap.yaml @@ -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; diff --git a/src/test/hertzbeat/templates/database/pvc.yaml b/src/test/hertzbeat/templates/database/pvc.yaml new file mode 100644 index 00000000..279fd278 --- /dev/null +++ b/src/test/hertzbeat/templates/database/pvc.yaml @@ -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 }} diff --git a/src/test/hertzbeat/templates/database/service.yaml b/src/test/hertzbeat/templates/database/service.yaml new file mode 100644 index 00000000..946049be --- /dev/null +++ b/src/test/hertzbeat/templates/database/service.yaml @@ -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 diff --git a/src/test/hertzbeat/templates/database/statefulset.yaml b/src/test/hertzbeat/templates/database/statefulset.yaml new file mode 100644 index 00000000..ea97e6cc --- /dev/null +++ b/src/test/hertzbeat/templates/database/statefulset.yaml @@ -0,0 +1,99 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "hertzbeat.database" . }} + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} + component: database +spec: + replicas: 1 + serviceName: {{ include "hertzbeat.database" . }} + selector: + matchLabels: + {{- include "hertzbeat.selectorLabels" . | nindent 6 }} + component: database + template: + metadata: + {{- with .Values.database.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "hertzbeat.selectorLabels" . | nindent 8 }} + component: database + spec: + securityContext: + {{- toYaml .Values.database.podSecurityContext | nindent 8 }} + containers: + - name: database + image: {{ .Values.database.image.repository }}:{{ .Values.database.image.tag }} + imagePullPolicy: {{ .Values.database.image.pullPolicy }} + livenessProbe: + tcpSocket: + port: 3306 + initialDelaySeconds: 300 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: 3306 + initialDelaySeconds: 1 + periodSeconds: 10 + resources: + {{- toYaml .Values.database.resources | nindent 12 }} + envFrom: + - configMapRef: + name: "{{ include "hertzbeat.database" . }}" + volumeMounts: + - name: data + mountPath: /var/lib/mysql + subPath: "" + - mountPath: /docker-entrypoint-initdb.d/schema.sql + subPath: schema.sql + name: schema + volumes: + - name: schema + configMap: + name: {{ include "hertzbeat.database" . }} + {{- if not .Values.database.persistence.enabled }} + - name: data + emptyDir: {} + {{- else }} + - name: data + persistentVolumeClaim: + claimName: {{ .Values.database.persistence.existingClaim | default (include "hertzbeat.database" .) }} + {{- end }} + {{- with .Values.database.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.database.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.database.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{/* {{- if and .Values.database.persistence.enabled (not .Values.database.persistence.existingClaim) }}*/}} +{{/* volumeClaimTemplates:*/}} +{{/* - metadata:*/}} +{{/* name: data*/}} +{{/* labels:*/}} +{{/* {{- include "hertzbeat.labels" . | indent 10 }}*/}} +{{/* annotations:*/}} +{{/* {{- range $key, $value := .Values.database.persistence.annotations }}*/}} +{{/* {{ $key }}: {{ $value | quote }}*/}} +{{/* {{- end }}*/}} +{{/* spec:*/}} +{{/* accessModes: [{{ .Values.database.persistence.accessMode | quote }}]*/}} +{{/* {{- if .Values.database.persistence.storageClass }}*/}} +{{/* {{- if (eq "-" .Values.database.persistence.storageClass) }}*/}} +{{/* storageClassName: ""*/}} +{{/* {{- else }}*/}} +{{/* storageClassName: "{{ .Values.database.persistence.storageClass }}"*/}} +{{/* {{- end }}*/}} +{{/* {{- end }}*/}} +{{/* resources:*/}} +{{/* requests:*/}} +{{/* storage: {{ .Values.database.persistence.size | quote }}*/}} +{{/* {{- end -}}*/}} diff --git a/src/test/hertzbeat/templates/manager/configmap.yaml b/src/test/hertzbeat/templates/manager/configmap.yaml new file mode 100644 index 00000000..60a9ce52 --- /dev/null +++ b/src/test/hertzbeat/templates/manager/configmap.yaml @@ -0,0 +1,246 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "{{ include "hertzbeat.manager" . }}" + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} +data: + application.yml: |+ + server: + port: 1157 + spring: + application: + name: ${HOSTNAME:@hertzbeat@}${PID} + profiles: + active: prod + mvc: + static-path-pattern: /** + jackson: + default-property-inclusion: ALWAYS + web: + resources: + static-locations: + - classpath:/dist/ + - classpath:../dist/ + # 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 + thymeleaf: + prefix: classpath:/templates/ + check-template-location: true + cache: true + suffix: .html + mode: HTML + template-resolver-order: 1 + + management: + health: + mail: + enabled: off + endpoints: + web: + exposure: + include: + - 'metrics' + - 'health' + - 'env' + enabled-by-default: on + + sureness: + auths: + - digest + - basic + - jwt + jwt: + secret: 'CyaFv0bwq2Eik0jdrKUtsA6bx3sDJeFV643R + LnfKefTjsIfJLBa2YkhEqEGtcHDTNe4CU6+9 + 8tVt4bisXQ13rbN0oxhUZR73M6EByXIO+SV5 + dKhaX0csgOCTlCxq20yhmUea6H6JIpSE2Rwp' + + --- + spring: + config: + activate: + on-profile: prod + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: {{ .Values.database.rootPassword }} + url: jdbc:mysql://{{ include "hertzbeat.database" . }}:3306/hertzbeat?useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&useSSL=false + hikari: + max-lifetime: 120000 + + jpa: + hibernate: + ddl-auto: update + + mail: + # Attention: this is mail server address. + # 请注意此为邮件服务器地址:qq邮箱为 smtp.qq.com qq 企业邮箱为 smtp.exmail.qq.com + host: smtp.qq.com + username: tancloud@qq.com + # Attention: this is not email account password, this requires an email authorization code + # 请注意此非邮箱账户密码 此需填写邮箱授权码 + password: your-password + #Attention: Tencent mail smtps 465,smtp 587 + #请注意腾讯邮箱465为smtps,587为smtp + port: 587 + properties: + mail: + smtp: + socketFactoryClass: javax.net.ssl.SSLSocketFactory + ssl: + enable: true + + common: + queue: + # memory or kafka + type: memory + # properties when queue type is kafka + kafka: + servers: 127.0.0.1:9092 + metrics-data-topic: async-metrics-data + alerts-data-topic: async-alerts-data + + warehouse: + store: + # store history metrics data, enable only one below + # 存储历史数据方式, 下方只能enabled启用一种方式 + jpa: + enabled: false + # The maximum retention time for history records, after which records will be deleted + expire-time: 1h + # The maximum number of history records retained, if this number is exceeded, half of the data in this configuration item will be deleted + # (please set this configuration reasonably as history records can affect performance when it is large) + # 历史数据的最大保留条数,超过此数量时,将会删除一半于此配量的数据(由于历史数据较大时会影响性能,请合理设置此配置) + max-history-record-num: 6000 + td-engine: + enabled: false + driver-class-name: com.taosdata.jdbc.rs.RestfulDriver + url: jdbc:TAOS-RS://localhost:6041/hertzbeat + username: root + password: taosdata + greptime: + enabled: false + endpoint: localhost:4001 + iot-db: + enabled: true + host: {{ include "hertzbeat.tsdb" . }} + rpc-port: 6667 + username: root + password: root + # org.dromara.hertzbeat.warehouse.config.IotDbVersion: V_0_13 || V_1_0 + version: V_0_13 + query-timeout-in-ms: -1 + # 数据存储时间:默认'7776000000'(90天,单位为毫秒,-1代表永不过期) + # data expire time, unit:ms, default '7776000000'(90 days, -1:never expire) + expire-time: '7776000000' + influxdb: + enabled: false + server-url: http://127.0.0.1:8086 + username: root + password: root + expire-time: '30d' + replication: 1 + + # store real-time metrics data, enable only one below + # 存储实时数据方式, 下方只能enabled启用一种方式 + memory: + enabled: true + init-size: 1024 + redis: + enabled: false + host: 127.0.0.1 + port: 6379 + password: 123456 + db: 0 + + alerter: + # custom console url + console-url: https://console.tancloud.cn + + scheduler: + server: + enabled: true + port: 1158 + + + sureness.yml: |+ + resourceRole: + - /api/account/auth/refresh===post===[admin,user,guest] + - /api/apps/**===get===[admin,user,guest] + - /api/monitor/**===get===[admin,user,guest] + - /api/monitor/**===post===[admin,user] + - /api/monitor/**===put===[admin,user] + - /api/monitor/**===delete==[admin] + - /api/monitors/**===get===[admin,user,guest] + - /api/monitors/**===post===[admin,user] + - /api/monitors/**===put===[admin,user] + - /api/monitors/**===delete===[admin] + - /api/alert/**===get===[admin,user,guest] + - /api/alert/**===post===[admin,user] + - /api/alert/**===put===[admin,user] + - /api/alert/**===delete===[admin] + - /api/alerts/**===get===[admin,user,guest] + - /api/alerts/**===post===[admin,user] + - /api/alerts/**===put===[admin,user] + - /api/alerts/**===delete===[admin] + - /api/notice/**===get===[admin,user,guest] + - /api/notice/**===post===[admin,user] + - /api/notice/**===put===[admin,user] + - /api/notice/**===delete===[admin] + - /api/tag/**===get===[admin,user,guest] + - /api/tag/**===post===[admin,user] + - /api/tag/**===put===[admin,user] + - /api/tag/**===delete===[admin] + - /api/summary/**===get===[admin,user,guest] + - /api/summary/**===post===[admin,user] + - /api/summary/**===put===[admin,user] + - /api/summary/**===delete===[admin] + + excludedResource: + - /api/account/auth/**===* + - /api/i18n/**===get + - /api/metrics===get + - /api/apps/hierarchy===get + - /actuator/**===get + # web ui + - /===get + - /dashboard/**===get + - /monitors/**===get + - /alert/**===get + - /account/**===get + - /setting/**===get + - /passport/**===get + - /**/*.html===get + - /**/*.js===get + - /**/*.css===get + - /**/*.ico===get + - /**/*.ttf===get + - /**/*.png===get + - /**/*.gif===get + - /**/*.jpg===get + - /**/*.svg===get + - /**/*.json===get + # swagger ui + - /swagger-resources/**===get + - /v2/api-docs===get + - /v3/api-docs===get + # h2 database + - /h2-console/**===* + + account: + - appId: admin + credential: hertzbeat + role: [admin,user] + - appId: tom + credential: hertzbeat + role: [user] + - appId: guest + credential: hertzbeat + role: [guest] + - appId: lili + credential: 1A676730B0C7F54654B0E09184448289 + salt: 123 + role: [guest] diff --git a/src/test/hertzbeat/templates/manager/deployment.yaml b/src/test/hertzbeat/templates/manager/deployment.yaml new file mode 100644 index 00000000..fe966bbc --- /dev/null +++ b/src/test/hertzbeat/templates/manager/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "hertzbeat.manager" . }} + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} + component: manager +spec: + replicas: 1 + selector: + matchLabels: + {{- include "hertzbeat.selectorLabels" . | nindent 6 }} + component: manager + template: + metadata: + {{- with .Values.manager.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "hertzbeat.selectorLabels" . | nindent 8 }} + component: manager + spec: + securityContext: + {{- toYaml .Values.manager.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.manager.securityContext | nindent 12 }} + image: "{{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.manager.image.pullPolicy }} + ports: + - name: http + containerPort: 1157 + protocol: TCP + - name: cluster + containerPort: 1158 + protocol: TCP + livenessProbe: + tcpSocket: + port: 1157 + readinessProbe: + tcpSocket: + port: 1157 + volumeMounts: + - mountPath: /opt/hertzbeat/config/application.yml + subPath: application.yml + name: application + - mountPath: /opt/hertzbeat/config/sureness.yml + subPath: sureness.yml + name: sureness + resources: + {{- toYaml .Values.manager.resources | nindent 12 }} + volumes: + - name: application + configMap: + name: {{ include "hertzbeat.manager" . }} + - name: sureness + configMap: + name: {{ include "hertzbeat.manager" . }} + {{- with .Values.manager.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.manager.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.manager.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/src/test/hertzbeat/templates/manager/service-cluster.yaml b/src/test/hertzbeat/templates/manager/service-cluster.yaml new file mode 100644 index 00000000..c52298b1 --- /dev/null +++ b/src/test/hertzbeat/templates/manager/service-cluster.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: "{{ include "hertzbeat.manager" . }}-cluster" + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 1158 + targetPort: 1158 + protocol: TCP + name: cluster + selector: + {{- include "hertzbeat.selectorLabels" . | nindent 4 }} + component: manager diff --git a/src/test/hertzbeat/templates/manager/service-expose.yaml b/src/test/hertzbeat/templates/manager/service-expose.yaml new file mode 100644 index 00000000..c890f1e8 --- /dev/null +++ b/src/test/hertzbeat/templates/manager/service-expose.yaml @@ -0,0 +1,44 @@ +{{- if or (eq .Values.expose.type "ClusterIP") (eq .Values.expose.type "NodePort") (eq .Values.expose.type "LoadBalancer") }} +apiVersion: v1 +kind: Service +metadata: + name: "{{ include "hertzbeat.manager" . }}-http" + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} +{{- if eq .Values.expose.type "ClusterIP" }} +spec: + type: ClusterIP + ports: + - name: http + port: {{ .Values.expose.clusterIP.ports.port }} + targetPort: 1157 +{{- else if eq .Values.expose.type "NodePort" }} +spec: + type: NodePort + ports: + - port: {{ .Values.expose.nodePort.ports.port }} + targetPort: 1157 + protocol: TCP + name: http + {{- if .Values.expose.nodePort.ports.nodePort }} + nodePort: {{ .Values.expose.nodePort.ports.nodePort }} + {{- end }} + selector: + {{- include "hertzbeat.selectorLabels" . | nindent 4 }} + component: manager +{{- else if eq .Values.expose.type "LoadBalancer" }} +spec: + type: LoadBalancer + {{- with .Values.expose.loadBalancer.sourceRanges }} + loadBalancerSourceRanges: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- if .Values.expose.loadBalancer.ip }} + loadBalancerIP: {{ .Values.expose.loadBalancer.ip }} + {{- end }} + ports: + - name: http + port: {{ .Values.expose.loadBalancer.ports.port }} + targetPort: 1157 +{{- end }} +{{- end }} diff --git a/src/test/hertzbeat/templates/tsdb/configmap.yaml b/src/test/hertzbeat/templates/tsdb/configmap.yaml new file mode 100644 index 00000000..af0ee8cf --- /dev/null +++ b/src/test/hertzbeat/templates/tsdb/configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "{{ include "hertzbeat.tsdb" . }}" + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} +data: + TZ: "{{ .Values.database.timezone }}" diff --git a/src/test/hertzbeat/templates/tsdb/pvc.yaml b/src/test/hertzbeat/templates/tsdb/pvc.yaml new file mode 100644 index 00000000..0115090f --- /dev/null +++ b/src/test/hertzbeat/templates/tsdb/pvc.yaml @@ -0,0 +1,29 @@ +{{- if .Values.tsdb.persistence.enabled }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "hertzbeat.tsdb" . }} + annotations: + {{- range $key, $value := .Values.tsdb.persistence.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- if eq .Values.tsdb.persistence.resourcePolicy "keep" }} + helm.sh/resource-policy: keep + {{- end }} + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} + component: tsdb +spec: + accessModes: + - {{ .Values.tsdb.persistence.accessMode }} + resources: + requests: + storage: {{ .Values.tsdb.persistence.size }} + {{- if .Values.tsdb.persistence.storageClass }} + {{- if eq "-" .Values.tsdb.persistence.storageClass }} + storageClassName: "" + {{- else }} + storageClassName: {{ .Values.tsdb.persistence.storageClass }} + {{- end }} + {{- end }} +{{- end }} diff --git a/src/test/hertzbeat/templates/tsdb/service.yaml b/src/test/hertzbeat/templates/tsdb/service.yaml new file mode 100644 index 00000000..73f93b14 --- /dev/null +++ b/src/test/hertzbeat/templates/tsdb/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "hertzbeat.tsdb" . }} + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 6667 + targetPort: 6667 + protocol: TCP + selector: + {{- include "hertzbeat.selectorLabels" . | nindent 4 }} + component: tsdb diff --git a/src/test/hertzbeat/templates/tsdb/statefulset.yaml b/src/test/hertzbeat/templates/tsdb/statefulset.yaml new file mode 100644 index 00000000..ba2aec09 --- /dev/null +++ b/src/test/hertzbeat/templates/tsdb/statefulset.yaml @@ -0,0 +1,70 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "hertzbeat.tsdb" . }} + labels: + {{- include "hertzbeat.labels" . | nindent 4 }} + component: tsdb +spec: + replicas: 1 + serviceName: {{ include "hertzbeat.tsdb" . }} + selector: + matchLabels: + {{- include "hertzbeat.selectorLabels" . | nindent 6 }} + component: tsdb + template: + metadata: + {{- with .Values.tsdb.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "hertzbeat.selectorLabels" . | nindent 8 }} + component: tsdb + spec: + securityContext: + {{- toYaml .Values.tsdb.podSecurityContext | nindent 8 }} + containers: + - name: tsdb + image: {{ .Values.tsdb.image.repository }}:{{ .Values.tsdb.image.tag }} + imagePullPolicy: {{ .Values.tsdb.image.pullPolicy }} + livenessProbe: + tcpSocket: + port: 6667 + initialDelaySeconds: 300 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: 6667 + initialDelaySeconds: 1 + periodSeconds: 10 + resources: + {{- toYaml .Values.tsdb.resources | nindent 12 }} + envFrom: + - configMapRef: + name: "{{ include "hertzbeat.tsdb" . }}" + volumeMounts: + - name: data + mountPath: /iotdb/data + subPath: "" + volumes: + {{- if not .Values.tsdb.persistence.enabled }} + - name: data + emptyDir: {} + {{- else }} + - name: data + persistentVolumeClaim: + claimName: {{ .Values.tsdb.persistence.existingClaim | default (include "hertzbeat.tsdb" .) }} + {{- end }} + {{- with .Values.tsdb.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tsdb.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tsdb.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/src/test/hertzbeat/values.yaml b/src/test/hertzbeat/values.yaml new file mode 100644 index 00000000..56d4a55a --- /dev/null +++ b/src/test/hertzbeat/values.yaml @@ -0,0 +1,127 @@ +# Default values for hertzbeat. + +manager: + image: + repository: tancloud/hertzbeat + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + + podAnnotations: { } + podSecurityContext: { } + securityContext: { } + resources: { } + nodeSelector: { } + tolerations: [ ] + affinity: { } + +collector: + image: + repository: tancloud/hertzbeat-collector + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + replicaCount: 1 + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 20 + targetCPUUtilizationPercentage: 80 + targetMemoryUtilizationPercentage: 80 + + podAnnotations: { } + podSecurityContext: { } + securityContext: { } + resources: { } + nodeSelector: { } + tolerations: [ ] + affinity: { } + +database: + image: + repository: mysql + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "8" + timezone: "Asia/Shanghai" + rootPassword: "123456" + persistence: + enabled: true + existingClaim: "" + storageClass: "" + subPath: "" + accessMode: ReadWriteOnce + size: 4Gi + annotations: {} + resourcePolicy: "keep" + + podAnnotations: { } + podSecurityContext: { } + securityContext: { } + resources: { } + nodeSelector: { } + tolerations: [ ] + affinity: { } + +tsdb: + image: + repository: apache/iotdb + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "0.13.3-node" + timezone: "Asia/Shanghai" + persistence: + enabled: true + existingClaim: "" + storageClass: "" + subPath: "" + accessMode: ReadWriteOnce + size: 4Gi + annotations: {} + resourcePolicy: "keep" + + podAnnotations: { } + podSecurityContext: { } + securityContext: { } + resources: { } + nodeSelector: { } + tolerations: [ ] + affinity: { } + +# Expose Network +expose: + # Set how to expose the service. Set the type as "ingress", "clusterIP", "nodePort" or "loadBalancer" + # and fill the information in the corresponding section + type: NodePort + clusterIP: + ports: + # The service port Harbor listens on when serving HTTP + port: 1157 + nodePort: + ports: + # The service port Harbor listens on when serving HTTP + port: 1157 + # The node port Harbor listens on when serving HTTP + nodePort: 31157 + loadBalancer: + # Set the IP if the LoadBalancer supports assigning IP + ip: "" + ports: + # The service port Harbor listens on when serving HTTP + port: 1157 + sourceRanges: [ ] + ingress: + className: "" + annotations: { } + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: hertzbeat.domain + paths: + - path: / + pathType: ImplementationSpecific + tls: [ ] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + From 1c2e413df60cf23506792ae3f2d1256f78645e32 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Mon, 4 Sep 2023 15:14:37 +0800 Subject: [PATCH 2/2] add hertzbeat helm chart in test module --- src/test/hertzbeat/README.md | 119 +++++++++--------- .../templates/manager/configmap.yaml | 9 +- src/test/hertzbeat/values.yaml | 8 +- 3 files changed, 71 insertions(+), 65 deletions(-) diff --git a/src/test/hertzbeat/README.md b/src/test/hertzbeat/README.md index a19bcb07..2b871eea 100644 --- a/src/test/hertzbeat/README.md +++ b/src/test/hertzbeat/README.md @@ -91,67 +91,70 @@ helm uninstall hertzbeat The following table lists the configurable parameters of the HertzBeat chart and the default values. -| Parameter | Description | Default | -|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------| -| **Expose** | | | -| `expose.type` | How to expose the service: `ingress`, `clusterIP`, `nodePort` or `loadBalancer`, other values will be ignored and the creation of service will be skipped. | `ingress` | -| `expose.clusterIP.name` | The name of ClusterIP service | `hertzbeat` | -| `expose.clusterIP.annotations` | The annotations attached to the ClusterIP service | {} | -| `expose.clusterIP.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | -| `expose.nodePort.name` | The name of NodePort service | `hertzbeat` | -| `expose.nodePort.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | -| `expose.nodePort.ports.nodePort` | The node port HertzBeat listens on when serving HTTP | `30002` | -| `expose.loadBalancer.IP` | The IP of the loadBalancer. It only works when loadBalancer supports assigning IP | `""` | -| `expose.loadBalancer.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | -| `expose.loadBalancer.sourceRanges` | List of IP address ranges to assign to loadBalancerSourceRanges | [] | -| **Manager** | | | -| `manager.resources` | The [resources] to allocate for container | undefined | -| `manager.nodeSelector` | Node labels for pod assignment | `{}` | -| `manager.tolerations` | Tolerations for pod assignment | `[]` | -| `manager.affinity` | Node/Pod affinities | `{}` | -| `manager.podAnnotations` | Annotations to add to the nginx pod | `{}` | -| **Collector** | | | -| `collector.replicaCount` | The replica count | `1` | -| `collector.autoscaling.enable` | Is enable auto scaling collector replicas | `1` | -| `collector.resources` | The [resources] to allocate for container | undefined | -| `collector.nodeSelector` | Node labels for pod assignment | `{}` | -| `collector.tolerations` | Tolerations for pod assignment | `[]` | -| `collector.affinity` | Node/Pod affinities | `{}` | -| `collector.podAnnotations` | Annotations to add to the nginx pod | `{}` | -| **Database** | | | -| `database.timezone` | The database system timezone | `1` | -| `database.rootPassword` | The database root user password | `1` | -| `database.persistence.enabled` | Enable the data persistence or not | `true` | -| `database.persistence.resourcePolicy` | Setting it to `keep` to avoid removing PVCs during a helm delete operation. Leaving it empty will delete PVCs after the chart deleted. Does not affect PVCs created for internal database and redis components. | `keep` | -| `database.persistence.existingClaim` | Use the existing PVC which must be created manually before bound, and specify the `subPath` if the PVC is shared with other components | | -| `database.persistence.storageClass` | Specify the `storageClass` used to provision the volume. Or the default StorageClass will be used (the default). Set it to `-` to disable dynamic provisioning | | -| `database.persistence.subPath` | The sub path used in the volume | | -| `database.persistence.accessMode` | The access mode of the volume | `ReadWriteOnce` | -| `database.persistence.size` | The size of the volume | `5Gi` | -| `database.persistence.annotations` | The annotations of the volume | | -| `database.resources` | The [resources] to allocate for container | undefined | -| `database.nodeSelector` | Node labels for pod assignment | `{}` | -| `database.tolerations` | Tolerations for pod assignment | `[]` | -| `database.affinity` | Node/Pod affinities | `{}` | -| `database.podAnnotations` | Annotations to add to the nginx pod | `{}` | -| **TSDB** | | | -| `tsdb.timezone` | The database system timezone | `1` | -| `tsdb.persistence.enabled` | Enable the data persistence or not | `true` | -| `tsdb.persistence.resourcePolicy` | Setting it to `keep` to avoid removing PVCs during a helm delete operation. Leaving it empty will delete PVCs after the chart deleted. Does not affect PVCs created for internal database and redis components. | `keep` | -| `tsdb.persistence.existingClaim` | Use the existing PVC which must be created manually before bound, and specify the `subPath` if the PVC is shared with other components | | -| `tsdb.persistence.storageClass` | Specify the `storageClass` used to provision the volume. Or the default StorageClass will be used (the default). Set it to `-` to disable dynamic provisioning | | -| `tsdb.persistence.subPath` | The sub path used in the volume | | -| `tsdb.persistence.accessMode` | The access mode of the volume | `ReadWriteOnce` | -| `tsdb.persistence.size` | The size of the volume | `5Gi` | -| `tsdb.persistence.annotations` | The annotations of the volume | | -| `tsdb.resources` | The [resources] to allocate for container | undefined | -| `tsdb.nodeSelector` | Node labels for pod assignment | `{}` | -| `tsdb.tolerations` | Tolerations for pod assignment | `[]` | -| `tsdb.affinity` | Node/Pod affinities | `{}` | -| `tsdb.podAnnotations` | Annotations to add to the nginx pod | `{}` | +| Parameter | Description | Default | +|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------| +| **Expose** | | | +| `expose.type` | How to expose the service: `ingress`, `clusterIP`, `nodePort` or `loadBalancer`, other values will be ignored and the creation of service will be skipped. | `ingress` | +| `expose.clusterIP.name` | The name of ClusterIP service | `hertzbeat` | +| `expose.clusterIP.annotations` | The annotations attached to the ClusterIP service | {} | +| `expose.clusterIP.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | +| `expose.nodePort.name` | The name of NodePort service | `hertzbeat` | +| `expose.nodePort.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | +| `expose.nodePort.ports.nodePort` | The node port HertzBeat listens on when serving HTTP | `30002` | +| `expose.loadBalancer.IP` | The IP of the loadBalancer. It only works when loadBalancer supports assigning IP | `""` | +| `expose.loadBalancer.ports.port` | The service port HertzBeat listens on when serving HTTP | `80` | +| `expose.loadBalancer.sourceRanges` | List of IP address ranges to assign to loadBalancerSourceRanges | [] | +| **Manager** | | | +| `manager.account.username` | The hertzbeat account username | `admin` | +| `manager.account.password` | The hertzbeat account password | `hertzbeat` | +| `manager.resources` | The [resources] to allocate for container | undefined | +| `manager.nodeSelector` | Node labels for pod assignment | `{}` | +| `manager.tolerations` | Tolerations for pod assignment | `[]` | +| `manager.affinity` | Node/Pod affinities | `{}` | +| `manager.podAnnotations` | Annotations to add to the nginx pod | `{}` | +| **Collector** | | | +| `collector.replicaCount` | The replica count | `1` | +| `collector.autoscaling.enable` | Is enable auto scaling collector replicas | `1` | +| `collector.resources` | The [resources] to allocate for container | undefined | +| `collector.nodeSelector` | Node labels for pod assignment | `{}` | +| `collector.tolerations` | Tolerations for pod assignment | `[]` | +| `collector.affinity` | Node/Pod affinities | `{}` | +| `collector.podAnnotations` | Annotations to add to the nginx pod | `{}` | +| **Database** | | | +| `database.timezone` | The database system timezone | `1` | +| `database.rootPassword` | The database root user password | `1` | +| `database.persistence.enabled` | Enable the data persistence or not | `true` | +| `database.persistence.resourcePolicy` | Setting it to `keep` to avoid removing PVCs during a helm delete operation. Leaving it empty will delete PVCs after the chart deleted. Does not affect PVCs created for internal database and redis components. | `keep` | +| `database.persistence.existingClaim` | Use the existing PVC which must be created manually before bound, and specify the `subPath` if the PVC is shared with other components | | +| `database.persistence.storageClass` | Specify the `storageClass` used to provision the volume. Or the default StorageClass will be used (the default). Set it to `-` to disable dynamic provisioning | | +| `database.persistence.subPath` | The sub path used in the volume | | +| `database.persistence.accessMode` | The access mode of the volume | `ReadWriteOnce` | +| `database.persistence.size` | The size of the volume | `5Gi` | +| `database.persistence.annotations` | The annotations of the volume | | +| `database.resources` | The [resources] to allocate for container | undefined | +| `database.nodeSelector` | Node labels for pod assignment | `{}` | +| `database.tolerations` | Tolerations for pod assignment | `[]` | +| `database.affinity` | Node/Pod affinities | `{}` | +| `database.podAnnotations` | Annotations to add to the nginx pod | `{}` | +| **TSDB** | | | +| `tsdb.timezone` | The database system timezone | `1` | +| `tsdb.persistence.enabled` | Enable the data persistence or not | `true` | +| `tsdb.persistence.resourcePolicy` | Setting it to `keep` to avoid removing PVCs during a helm delete operation. Leaving it empty will delete PVCs after the chart deleted. Does not affect PVCs created for internal database and redis components. | `keep` | +| `tsdb.persistence.existingClaim` | Use the existing PVC which must be created manually before bound, and specify the `subPath` if the PVC is shared with other components | | +| `tsdb.persistence.storageClass` | Specify the `storageClass` used to provision the volume. Or the default StorageClass will be used (the default). Set it to `-` to disable dynamic provisioning | | +| `tsdb.persistence.subPath` | The sub path used in the volume | | +| `tsdb.persistence.accessMode` | The access mode of the volume | `ReadWriteOnce` | +| `tsdb.persistence.size` | The size of the volume | `5Gi` | +| `tsdb.persistence.annotations` | The annotations of the volume | | +| `tsdb.resources` | The [resources] to allocate for container | undefined | +| `tsdb.nodeSelector` | Node labels for pod assignment | `{}` | +| `tsdb.tolerations` | Tolerations for pod assignment | `[]` | +| `tsdb.affinity` | Node/Pod affinities | `{}` | +| `tsdb.podAnnotations` | Annotations to add to the nginx pod | `{}` | [resources]: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ [hertzbeat]: https://github.com/dromara/hertzbeat/ [artifacthub]: https://artifacthub.io/ [helm]: https://helm.sh/ + diff --git a/src/test/hertzbeat/templates/manager/configmap.yaml b/src/test/hertzbeat/templates/manager/configmap.yaml index 60a9ce52..6dccb5ef 100644 --- a/src/test/hertzbeat/templates/manager/configmap.yaml +++ b/src/test/hertzbeat/templates/manager/configmap.yaml @@ -52,10 +52,7 @@ data: - basic - jwt jwt: - secret: 'CyaFv0bwq2Eik0jdrKUtsA6bx3sDJeFV643R - LnfKefTjsIfJLBa2YkhEqEGtcHDTNe4CU6+9 - 8tVt4bisXQ13rbN0oxhUZR73M6EByXIO+SV5 - dKhaX0csgOCTlCxq20yhmUea6H6JIpSE2Rwp' + secret: {{ .Values.manager.jwtSecretKey }} --- spring: @@ -231,8 +228,8 @@ data: - /h2-console/**===* account: - - appId: admin - credential: hertzbeat + - appId: {{ .Values.manager.account.username }} + credential: {{ .Values.manager.account.password }} role: [admin,user] - appId: tom credential: hertzbeat diff --git a/src/test/hertzbeat/values.yaml b/src/test/hertzbeat/values.yaml index 56d4a55a..c99a6c09 100644 --- a/src/test/hertzbeat/values.yaml +++ b/src/test/hertzbeat/values.yaml @@ -6,7 +6,13 @@ manager: pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "" - + account: + username: "admin" + password: "hertzbeat" + jwtSecretKey: "CyaFv0bwq2Eik0jdrKUtsA6bx3sDJeFV143R + LnfKefTjsIfJLBa2YkhEqEGtcHDTNe4CU6+9 + 8tVt4bisXQ13rbN0oxhUZR73M6EByXIO+SV5 + dKhaX0csgOCTlCxq20yhmUea6H6JIpSE2Rwp" podAnnotations: { } podSecurityContext: { } securityContext: { }