Skip to content

Commit

Permalink
feat: add cluster.yaml to support kubeblock
Browse files Browse the repository at this point in the history
Signed-off-by: wangxye <[email protected]>
  • Loading branch information
wangxye authored and wangxye committed Oct 23, 2023
1 parent 5480cc1 commit 5357877
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rocketmq-k8s-helm/templates/broker/_brokerconfig.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.
{{- $replicaCount := .Values.broker.replicaCount | int }}
{{- range $index := until $replicaCount }}
{{ $clusterName }}-{{ $name }}-{{ $index }}: |
name: {{ $clusterName }}-{{ $brokerNamePrefix }}
name: {{ $clusterName }}-{{ $brokerNamePrefix }}-{{ $index }}
instanceId: {{ $brokerNamePrefix }}-{{ $index }}
bindAddress: "0.0.0.0:{{ $bindAddress.port }}"
s3Stream:
Expand Down
89 changes: 89 additions & 0 deletions rocketmq-k8s-helm/templates/broker/clusterdefinition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterDefinition
metadata:
name: {{ .Release.Name }}
labels:
{{- include "rocketmq-broker.selectorLabels" . | nindent 8 }}
spec:
type: rocketmq-on-s3
componentDefs:
- name: rocketmq-on-s3
description: |-
Rocketmq broker that act as both brokers and controllers are referred to as "combined" servers.
workloadType: Stateful # Consensus
characterType: rocketmq-broker
probes:
monitor:
configSpecs:
{{/* - name: broker-config*/}}
{{/* configMap:*/}}
{{/* name: broker-conf*/}}
{{/* - name: broker-storage*/}}
{{/* hostPath:*/}}
{{/* path: /root/logs/rocketmqlogs*/}}
{{/* type: DirectoryOrCreate*/}}
scriptSpecs:
service:
ports:
- name: rocketmq-broker
targetPort: rocketmq-broker
port: 8081
podSpec:
securityContext:
fsGroup: 1001
containers:
- name: rocketmq
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)" ]
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: CLUSTER_NAME
valueFrom:
fieldRef:
fieldPath: metadata.labels['app.kubernetes.io/cluster']
- name: INSTANCE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.labels['app.kubernetes.io/name']
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: BROKER_MEM
value: {{ .Values.broker.jvmMemory }}
ports:
- name: rocketmq-broker
containerPort: 8081
protocol: TCP
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 60
periodSeconds: 15
successThreshold: 1
tcpSocket:
port: rocketmq-broker
timeoutSeconds: 1
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 60
periodSeconds: 15
successThreshold: 1
timeoutSeconds: 5
tcpSocket:
port: rocketmq-broker
startupProbe:
failureThreshold: 30
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
tcpSocket:
port: rocketmq-broker
volumeMounts:
- mountPath: /home/rocketmq/rocketmq-on-s3-5.1.3/conf/broker
name: broker-config
- mountPath: /root/logs/rocketmqlogs
name: broker-storage
19 changes: 19 additions & 0 deletions rocketmq-k8s-helm/templates/broker/clusterversion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterVersion
metadata:
name: {{ include "rocketmq-broker.fullname" . }}-{{ default .Chart.AppVersion .Values.clusterVersionOverride }}
labels:
{{- include "rocketmq-broker.selectorLabels" . | nindent 8 }}
spec:
clusterDefinitionRef: {{ .Release.Name }}
componentVersions:
- componentDefRef: rocketmq-on-s3
versionsContext:
containers:
- name: rocketmq-on-s3
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
6 changes: 3 additions & 3 deletions rocketmq-k8s-helm/templates/broker/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ spec:
value: {{ .Values.broker.jvmMemory }}
ports:
- name: broker
containerPort: 8081
containerPort: {{ .Values.broker.service.port }}
protocol: TCP
readinessProbe:
failureThreshold: 3
initialDelaySeconds: 60
periodSeconds: 15
successThreshold: 1
tcpSocket:
port: 8081
port: {{ .Values.broker.service.port }}
timeoutSeconds: 1
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 60
periodSeconds: 15
successThreshold: 1
tcpSocket:
port: 8081
port: {{ .Values.broker.service.port }}
timeoutSeconds: 1
resources:
{{- toYaml .Values.broker.resources | nindent 12 }}
Expand Down

0 comments on commit 5357877

Please sign in to comment.