diff --git a/broker/src/main/java/com/automq/rocketmq/broker/MetricsExporter.java b/broker/src/main/java/com/automq/rocketmq/broker/MetricsExporter.java index 603a6909f..b2e8ed138 100644 --- a/broker/src/main/java/com/automq/rocketmq/broker/MetricsExporter.java +++ b/broker/src/main/java/com/automq/rocketmq/broker/MetricsExporter.java @@ -286,8 +286,8 @@ public void start() { MetricsExporterType metricsExporterType = MetricsExporterType.valueOf(metricsConfig.exporterType()); if (metricsExporterType != MetricsExporterType.DISABLE) { initDynamicMetrics(); + this.started = true; } - this.started = true; } private void registerMetricsView(SdkMeterProviderBuilder providerBuilder) { diff --git a/distribution/helm/charts/automq-for-rocketmq/templates/broker/_brokerconfig.tpl b/distribution/helm/charts/automq-for-rocketmq/templates/broker/_brokerconfig.tpl deleted file mode 100644 index 6e2d3b12e..000000000 --- a/distribution/helm/charts/automq-for-rocketmq/templates/broker/_brokerconfig.tpl +++ /dev/null @@ -1,68 +0,0 @@ -{{/* -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -*/}} - -{{- define "rocketmq-broker.config" -}} -{{- $name := include "rocketmq-broker.fullname" . }} -{{- $clusterName := include "rocketmq-broker.clusterName" . }} -{{- $brokerNamePrefix := include "rocketmq-broker.brokerNamePrefix" . }} -{{- $config := .Values.broker.conf.name }} -{{- $s3stream := .Values.broker.conf.s3Stream }} -{{- $bindAddress := .Values.broker.service }} -{{- $innerKey := .Values.broker.conf.inner }} -{{- $db := .Values.broker.conf.db }} -{{- $controller := .Values.broker.conf.controller }} -{{- $metrics := .Values.broker.conf.metrics }} -{{- $store := .Values.broker.conf.store }} -{{- $replicaCount := .Values.broker.replicaCount | int }} -{{- range $index := until $replicaCount }} - {{ $clusterName }}-{{ $name }}-{{ $index }}: | - name: {{ $clusterName }}-{{ $name }}-{{ $index }} - instanceId: {{ $brokerNamePrefix }}-{{ $index }} - bindAddress: "0.0.0.0:{{ $bindAddress.port }}" - innerAccessKey: {{ $innerKey.accessKey }} - innerSecretKey: {{ $innerKey.secretKey }} - s3Stream: - s3WALPath: {{ $s3stream.s3WALPath }} - s3Endpoint: {{ $s3stream.s3Endpoint }} - s3Bucket: {{ $s3stream.s3Bucket }} - s3Region: {{ $s3stream.s3Region }} - s3ForcePathStyle: {{ $s3stream.s3ForcePathStyle }} - s3AccessKey: {{ $s3stream.s3AccessKey }} - s3SecretKey: {{ $s3stream.s3SecretKey }} - db: - url: {{ $db.url }} - userName: {{ $db.userName }} - password: {{ $db.password }} - store: - kvPath: {{ $store.kvPath }} - controller: - recycleS3IntervalInSecs: {{ $controller.recycleS3IntervalInSecs }} - dumpHeapOnError: {{ $controller.dumpHeapOnError }} - metrics: - exporterType: {{ $metrics.exporterType }} - grpcExporterTarget: {{ $metrics.grpcExporterTarget }} - grpcExporterHeader: {{ $metrics.grpcExporterHeader }} - grpcExporterTimeOutInMills: {{ $metrics.grpcExporterTimeOutInMills }} - periodicExporterIntervalInMills: {{ $metrics.periodicExporterIntervalInMills }} - promExporterPort: {{ $metrics.promExporterPort }} - promExporterHost: {{ $metrics.promExporterHost }} - labels: {{ $metrics.labels }} - exportInDelta: {{ $metrics.exportInDelta }} -{{ $config | indent 4 }} -{{- end }} -{{- end }} \ No newline at end of file diff --git a/distribution/helm/charts/automq-for-rocketmq/templates/broker/_helpers.tpl b/distribution/helm/charts/automq-for-rocketmq/templates/broker/_helpers.tpl index 946fdb217..911a39e4c 100644 --- a/distribution/helm/charts/automq-for-rocketmq/templates/broker/_helpers.tpl +++ b/distribution/helm/charts/automq-for-rocketmq/templates/broker/_helpers.tpl @@ -57,21 +57,13 @@ app.kubernetes.io/cluster: {{ include "rocketmq-broker.clusterName" . }} {{- end }} {{- define "rocketmq-broker.clusterName" -}} -{{- if .Values.broker.conf.clusterNameOverride }} -{{- .Values.broker.conf.clusterNameOverride | trunc 63 | trimSuffix "-" }} +{{- if .Values.broker.clusterNameOverride }} +{{- .Values.broker.clusterNameOverride | trunc 63 | trimSuffix "-" }} {{- else -}} {{ .Release.Name }} {{- end }} {{- end }} -{{- define "rocketmq-broker.brokerNamePrefix" -}} -{{- if .Values.broker.conf.brokerNamePrefixOverride }} -{{- .Values.broker.conf.brokerNamePrefixOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- include "rocketmq-broker.fullname" . }} -{{- end }} -{{- end }} - {{- define "rocketmq-broker.brokerImage" -}} {{ .Values.broker.image.repository }}:{{ .Values.broker.image.tag | default .Chart.AppVersion }} {{- end }} \ No newline at end of file diff --git a/distribution/helm/charts/automq-for-rocketmq/templates/broker/configmap.yaml b/distribution/helm/charts/automq-for-rocketmq/templates/broker/configmap.yaml index 1bb8a21f9..167983eeb 100644 --- a/distribution/helm/charts/automq-for-rocketmq/templates/broker/configmap.yaml +++ b/distribution/helm/charts/automq-for-rocketmq/templates/broker/configmap.yaml @@ -16,11 +16,56 @@ apiVersion: v1 kind: ConfigMap metadata: - name: broker-conf + name: {{ include "rocketmq-broker.clusterName" . }}-broker-conf labels: {{- include "rocketmq-broker.labels" . | nindent 4 }} data: -{{- include "rocketmq-broker.config" . }} + broker.conf: | + instanceId: "{{- include "rocketmq-broker.clusterName" . }}" + bindAddress: 0.0.0.0:8081 + + innerAccessKey: "" + innerSecretKey: "" + + s3Stream: + s3WALPath: "/root/logs/wal" + s3Endpoint: "{{- if .Values.localstack.enabled }}http://{{ .Release.Name }}-localstack:4566{{- else }}{{- .Values.broker.storage.s3.endpoint }}{{- end }}" + s3Bucket: "{{ .Values.broker.storage.s3.bucket }}" + s3Region: "{{ .Values.broker.storage.s3.region }}" + s3ForcePathStyle: {{ .Values.broker.storage.s3.forcePathStyle }} + s3AccessKey: "{{ .Values.broker.storage.s3.accessKey }}" + s3SecretKey: "{{ .Values.broker.storage.s3.secretKey }}" + networkBaselineBandwidth: {{ int .Values.broker.storage.s3.networkBaselineBandwidth }} + refillPeriodMs: {{ .Values.broker.storage.s3.refillPeriodMs }} + + db: + url: "{{- if .Values.mysql.enabled }}jdbc:mysql://{{ .Release.Name }}-mysql:3306/{{ .Values.mysql.auth.database }}{{- else }}{{- .Values.broker.db.url }}{{- end }}" + userName: "{{ .Values.broker.db.userName }}" + password: "{{ .Values.broker.db.password }}" + + store: + kvPath: "/root/logs/kvstore" + + controller: + recycleS3IntervalInSecs: 360 + dumpHeapOnError: true + + {{- if .Values.broker.metrics.enabled }} + metrics: + exporterType: "OTLP_GRPC" + grpcExporterTarget: "http://localhost:4317" + grpcExporterHeader: "" + grpcExporterTimeOutInMills: 31000 + periodicExporterIntervalInMills: 30000 + promExporterPort: 5557 + promExporterHost: "localhost" + labels: "" + exportInDelta: false + {{- else }} + metrics: + exporterType: "DISABLE" + {{- end }} + --- {{- if .Values.mysql.enabled }} diff --git a/distribution/helm/charts/automq-for-rocketmq/templates/broker/statefulset.yaml b/distribution/helm/charts/automq-for-rocketmq/templates/broker/statefulset.yaml index e4f8b3e80..75fa302e6 100644 --- a/distribution/helm/charts/automq-for-rocketmq/templates/broker/statefulset.yaml +++ b/distribution/helm/charts/automq-for-rocketmq/templates/broker/statefulset.yaml @@ -38,8 +38,12 @@ spec: imagePullPolicy: {{ $.Values.broker.image.pullPolicy }} {{- end }} command: [ "/bin/sh" ] - args: [ "-c", "./run-server.sh com.automq.rocketmq.broker.BrokerStartup -c /home/rocketmq/automq-for-rocketmq/conf/broker/$(POD_NAME)" ] + args: [ "-c", "./run-server.sh com.automq.rocketmq.broker.BrokerStartup -c /etc/automq-for-rocketmq/broker.conf" ] env: + - name: ROCKETMQ_NODE_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name - name: POD_NAME valueFrom: fieldRef: @@ -56,24 +60,22 @@ spec: valueFrom: fieldRef: fieldPath: status.podIP - - name: BROKER_MEM - value: {{ .Values.broker.jvmMemory }} ports: - name: broker containerPort: {{ .Values.broker.service.port }} protocol: TCP readinessProbe: - failureThreshold: 3 - initialDelaySeconds: 60 - periodSeconds: 15 + failureThreshold: 10 + initialDelaySeconds: 5 + periodSeconds: 5 successThreshold: 1 tcpSocket: port: {{ .Values.broker.service.port }} timeoutSeconds: 1 livenessProbe: - failureThreshold: 3 - initialDelaySeconds: 60 - periodSeconds: 15 + failureThreshold: 10 + initialDelaySeconds: 5 + periodSeconds: 5 successThreshold: 1 tcpSocket: port: {{ .Values.broker.service.port }} @@ -81,10 +83,12 @@ spec: resources: {{- toYaml .Values.broker.resources | nindent 12 }} volumeMounts: - - mountPath: /home/rocketmq/automq-for-rocketmq/conf/broker + - mountPath: /etc/automq-for-rocketmq name: broker-config - - mountPath: /root/logs/rocketmqlogs + {{- if .Values.broker.storage.local.persistence.enabled }} + - mountPath: /root/logs name: broker-storage + {{- end }} {{- with .Values.broker.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -92,8 +96,18 @@ spec: volumes: - name: broker-config configMap: - name: broker-conf - - name: broker-storage - hostPath: - path: /root/logs/rocketmqlogs - type: DirectoryOrCreate + name: {{ include "rocketmq-broker.clusterName" . }}-broker-conf +{{- if .Values.broker.storage.local.persistence.enabled }} + volumeClaimTemplates: + - metadata: + name: broker-storage + spec: + accessModes: + - ReadWriteOnce + {{- if .Values.broker.storage.local.persistence.storageClass }} + storageClassName: {{ .Values.broker.storage.local.persistence.storageClass }} + {{- end }} + resources: + requests: + storage: {{ .Values.broker.storage.local.persistence.size }} +{{- end }} \ No newline at end of file diff --git a/distribution/helm/charts/automq-for-rocketmq/values.yaml b/distribution/helm/charts/automq-for-rocketmq/values.yaml index 89cf7d372..a357315ea 100644 --- a/distribution/helm/charts/automq-for-rocketmq/values.yaml +++ b/distribution/helm/charts/automq-for-rocketmq/values.yaml @@ -24,55 +24,36 @@ broker: repository: "automqinc/automq-for-rocketmq" tag: "v0.0.3-alpha" - persistence: + db: + url: "" + userName: "root" + password: "automq" + + storage: + local: + persistence: + enabled: true + storageClass: "" + size: 10Gi + s3: + endpoint: "" + bucket: "automq-for-rocketmq" + region: "eu-west-2" + forcePathStyle: true + accessKey: "access-key" + secretKey: "secret-key" + networkBaselineBandwidth: 5242880 + refillPeriodMs: 100 + + metrics: enabled: false - size: 8Gi fullnameOverride: "" - - conf: - name: "" - clusterNameOverride: "" - brokerNamePrefixOverride: "" - - inner: - accessKey: "automq" - secretKey: "rocketmq" - - s3Stream: - s3WALPath: "/root/logs/rocketmqlogs/s3rocketmq/wal" - s3Endpoint: "http://automq-for-rocketmq-localstack:4566" - s3Bucket: "automq-for-rocketmq" - s3Region: "eu-west-2" - s3ForcePathStyle: true - s3AccessKey: "access-key" - s3SecretKey: "secret-key" - networkBaselineBandwidth: 5242880 - refillPeriodMs: 100 - db: - url: "jdbc:mysql://automq-for-rocketmq-mysql:3306/metadata" - userName: "root" - password: "automq" - store: - kvPath: "/root/logs/rocketmqlogs/s3rocketmq/kvstore" - controller: - recycleS3IntervalInSecs: 360 - dumpHeapOnError: true - metrics: - exporterType: "OTLP_GRPC" - grpcExporterTarget: "http://localhost:4317" - grpcExporterHeader: "" - grpcExporterTimeOutInMills: 31000 - periodicExporterIntervalInMills: 30000 - promExporterPort: 5557 - promExporterHost: "localhost" - labels: "" - exportInDelta: false + clusterNameOverride: "" service: port: 8081 - jvmMemory: " -Xms4g -Xmx4g -Xmn2g -XX:MaxDirectMemorySize=8g " resources: limits: cpu: 4 @@ -106,11 +87,20 @@ mysql: - name: init configMap: name: mysql-initdb-config + persistence: + enabled: true + storageClass: "" + size: 10Gi localstack: enabled: true enableStartupScripts: true + persistence: + enabled: true + storageClass: "" + size: 10Gi + service: type: ClusterIP diff --git a/distribution/helm/deploy/helm_sample_values.yaml b/distribution/helm/deploy/helm_sample_values.yaml index c921d2e5d..4ee66ae83 100644 --- a/distribution/helm/deploy/helm_sample_values.yaml +++ b/distribution/helm/deploy/helm_sample_values.yaml @@ -15,27 +15,18 @@ broker: replicaCount: 1 - conf: - s3Stream: - s3WALPath: "/root/logs/rocketmqlogs/s3rocketmq/wal" - s3Endpoint: "http://s3-localstack:4566" - s3Bucket: "ros" - s3Region: "eu-west-2" - s3ForcePathStyle: true - s3AccessKey: "foot" - s3SecretKey: "bar" - networkBaselineBandwidth: 5242880 - refillPeriodMs: 100 + db: + url: "jdbc:mysql://mysql:3306/metadata" + userName: "root" + password: "passward" - store: - kvPath: "/root/logs/rocketmqlogs/s3rocketmq/kvstore" - db: - url: "jdbc:mysql://mysql:3306/metadata" - userName: "root" - password: "passward" - controller: - recycleS3IntervalInSecs: 360 - dumpHeapOnError: true + storage: + s3: + endpoint: "http://s3-localstack:4566" + bucket: "ros" + region: "eu-west-2" + accessKey: "foot" + secretKey: "bar" mysql: enabled: false