From dc62491d30caae04a2e9e0fb0a56994359b163d2 Mon Sep 17 00:00:00 2001 From: wangxye Date: Mon, 23 Oct 2023 15:04:06 +0800 Subject: [PATCH] feat: support deploy in kubeblock Signed-off-by: wangxye --- .../templates/broker/_brokerconfig.tpl | 2 +- .../templates/broker/clusterdefinition.yaml | 45 ++++++++++++------- .../templates/broker/clusterversion.yaml | 27 +++++++---- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/rocketmq-k8s-helm/templates/broker/_brokerconfig.tpl b/rocketmq-k8s-helm/templates/broker/_brokerconfig.tpl index 0a967a9..335586c 100644 --- a/rocketmq-k8s-helm/templates/broker/_brokerconfig.tpl +++ b/rocketmq-k8s-helm/templates/broker/_brokerconfig.tpl @@ -28,7 +28,7 @@ limitations under the License. {{- $replicaCount := .Values.broker.replicaCount | int }} {{- range $index := until $replicaCount }} {{ $clusterName }}-{{ $name }}-{{ $index }}: | - name: {{ $clusterName }}-{{ $brokerNamePrefix }}-{{ $index }} + name: {{ $clusterName }}-{{ $name }}-{{ $index }} instanceId: {{ $brokerNamePrefix }}-{{ $index }} bindAddress: "0.0.0.0:{{ $bindAddress.port }}" innerAccessKey: {{ $innerKey.accessKey }} diff --git a/rocketmq-k8s-helm/templates/broker/clusterdefinition.yaml b/rocketmq-k8s-helm/templates/broker/clusterdefinition.yaml index 185c62e..a453858 100644 --- a/rocketmq-k8s-helm/templates/broker/clusterdefinition.yaml +++ b/rocketmq-k8s-helm/templates/broker/clusterdefinition.yaml @@ -1,3 +1,18 @@ +# 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. + apiVersion: apps.kubeblocks.io/v1alpha1 kind: ClusterDefinition metadata: @@ -7,21 +22,18 @@ metadata: spec: type: rocketmq-on-s3 componentDefs: - - name: rocketmq-on-s3 + - name: rocketmq-on-s3-broker description: |- Rocketmq broker that act as both brokers and controllers are referred to as "combined" servers. - workloadType: Stateful # Consensus + workloadType: Stateful characterType: rocketmq-broker probes: monitor: configSpecs: -{{/* - name: broker-config*/}} -{{/* configMap:*/}} -{{/* name: broker-conf*/}} -{{/* - name: broker-storage*/}} -{{/* hostPath:*/}} -{{/* path: /root/logs/rocketmqlogs*/}} -{{/* type: DirectoryOrCreate*/}} + - name: broker-conf + templateRef: broker-conf + volumeName: broker-conf + namespace: {{ .Release.Namespace }} scriptSpecs: service: ports: @@ -29,12 +41,10 @@ spec: targetPort: rocketmq-broker port: 8081 podSpec: - securityContext: - fsGroup: 1001 containers: - - name: rocketmq + - name: broker command: [ "/bin/sh" ] - args: [ "-c", "./run-server.sh com.automq.rocketmq.broker.BrokerStartup -c /home/rocketmq/rocketmq-on-s3-5.1.3/conf/broker/$(CLUSTER_NAME)-$(POD_NAME)" ] + args: [ "-c", "./run-server.sh com.automq.rocketmq.broker.BrokerStartup -c /home/rocketmq/rocketmq-on-s3-5.1.3/conf/broker/$(POD_NAME)" ] env: - name: POD_NAME valueFrom: @@ -84,6 +94,11 @@ spec: port: rocketmq-broker volumeMounts: - mountPath: /home/rocketmq/rocketmq-on-s3-5.1.3/conf/broker - name: broker-config + name: broker-conf - mountPath: /root/logs/rocketmqlogs - name: broker-storage \ No newline at end of file + name: broker-storage + volumes: + - name: broker-storage + hostPath: + path: /root/logs/rocketmqlogs + type: DirectoryOrCreate diff --git a/rocketmq-k8s-helm/templates/broker/clusterversion.yaml b/rocketmq-k8s-helm/templates/broker/clusterversion.yaml index 76686cd..6adc912 100644 --- a/rocketmq-k8s-helm/templates/broker/clusterversion.yaml +++ b/rocketmq-k8s-helm/templates/broker/clusterversion.yaml @@ -1,19 +1,30 @@ +# 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. + apiVersion: apps.kubeblocks.io/v1alpha1 kind: ClusterVersion metadata: - name: {{ include "rocketmq-broker.fullname" . }}-{{ default .Chart.AppVersion .Values.clusterVersionOverride }} + name: {{ .Release.Name }}-{{ default .Chart.AppVersion .Values.broker.image.tag }} labels: {{- include "rocketmq-broker.selectorLabels" . | nindent 8 }} spec: clusterDefinitionRef: {{ .Release.Name }} componentVersions: - - componentDefRef: rocketmq-on-s3 + - componentDefRef: rocketmq-on-s3-broker versionsContext: containers: - - name: rocketmq-on-s3 + - name: broker image: {{ .Values.broker.image.repository }}:{{ .Values.broker.image.tag | default .Chart.AppVersion }} - imagePullPolicy: {{ default "IfNotPresent" .Values.broker.image.pullPolicy }} - securityContext: - allowPrivilegeEscalation: false - runAsNonRoot: true - runAsUser: 1001 \ No newline at end of file + imagePullPolicy: {{ default "IfNotPresent" .Values.broker.image.pullPolicy }} \ No newline at end of file