Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ endif

.PHONY: install
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
kubectl apply -f deploy/crds/rocketmq.apache.org_controllers.yaml
kubectl create -f deploy/crds/rocketmq.apache.org_brokers.yaml
kubectl create -f deploy/crds/rocketmq.apache.org_nameservices.yaml
kubectl create -f deploy/crds/rocketmq.apache.org_consoles.yaml
Expand All @@ -132,6 +133,7 @@ install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~
.PHONY: uninstall
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
kubectl delete --ignore-not-found=$(ignore-not-found) -f deploy/crds/rocketmq.apache.org_brokers.yaml
kubectl delete --ignore-not-found=$(ignore-not-found) -f deploy/crds/rocketmq.apache.org_controllers.yaml
kubectl delete --ignore-not-found=$(ignore-not-found) -f deploy/crds/rocketmq.apache.org_nameservices.yaml
kubectl delete --ignore-not-found=$(ignore-not-found) -f deploy/crds/rocketmq.apache.org_consoles.yaml
kubectl delete --ignore-not-found=$(ignore-not-found) -f deploy/crds/rocketmq.apache.org_topictransfers.yaml
Expand Down
8 changes: 7 additions & 1 deletion deploy/crds/rocketmq.apache.org_brokers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,11 @@ spec:
brokerImage:
description: BaseImage is the broker image to use for the Pods
type: string
clusterMode:
description: 'ClusterMode defines the way to be a broker cluster,
valid values can be one of the following: STATIC(default), CONTROLLER,
CONTAINER'
type: string
containerSecurityContext:
description: Container Security Context
properties:
Expand Down Expand Up @@ -1360,7 +1365,8 @@ spec:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "operator-sdk generate k8s" to regenerate code after
modifying this file Add custom validation using kubebuilder tags:
https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html'
https://book-v1.book.kubebuilder.io/beyond_basics/generating_crd.html
Size of broker clusters'
type: integer
storageMode:
description: StorageMode can be EmptyDir, HostPath, StorageClass
Expand Down
1,684 changes: 1,684 additions & 0 deletions deploy/crds/rocketmq.apache.org_controllers.yaml

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions deploy/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- ""
resources:
- services
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
Expand Down Expand Up @@ -151,6 +163,32 @@ rules:
- get
- patch
- update
- apiGroups:
- rocketmq.apache.org
resources:
- controllers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- rocketmq.apache.org
resources:
- controllers/finalizers
verbs:
- update
- apiGroups:
- rocketmq.apache.org
resources:
- controllers/status
verbs:
- get
- patch
- update
- apiGroups:
- rocketmq.apache.org
resources:
Expand Down
5 changes: 4 additions & 1 deletion deploy/storage/hostpath/prepare-host-path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
NAME_SERVER_DATA_PATH=/data/rocketmq/nameserver
# BROKER_DATA_PATH should be the same with the hostPath field in rocketmq_v1alpha1_broker_cr.yaml
BROKER_DATA_PATH=/data/rocketmq/broker
# CONTROLLER_DATA_PATH should be the same with the hostPath field in rocketmq_v1alpha1_controller_cr.yaml
CONTROLLER_DATA_PATH=/data/rocketmq/controller
# ROCKETMQ_UID and ROCKETMQ_GID should be the same with docker image settings
ROCKETMQ_UID=3000
ROCKETMQ_GID=3000
Expand All @@ -40,7 +42,8 @@ prepare_dir()

prepare_dir $BROKER_DATA_PATH $ROCKETMQ_UID $ROCKETMQ_GID
prepare_dir $NAME_SERVER_DATA_PATH $ROCKETMQ_UID $ROCKETMQ_GID
prepare_dir $CONTROLLER_DATA_PATH $ROCKETMQ_UID $ROCKETMQ_GID

echo "Changed hostPath $NAME_SERVER_DATA_PATH uid to $ROCKETMQ_UID, gid to $ROCKETMQ_GID"
echo "Changed hostPath $BROKER_DATA_PATH uid to $ROCKETMQ_UID, gid to $ROCKETMQ_GID"

echo "Changed hostPath $CONTROLLER_DATA_PATH uid to $ROCKETMQ_UID, gid to $ROCKETMQ_GID"
47 changes: 47 additions & 0 deletions example/rocketmq_v1alpha1_controller_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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: rocketmq.apache.org/v1alpha1
kind: Controller
metadata:
# name of controller cluster
name: controller
spec:
# size is the number of controllers.
size: 1
# controllerImage is the customized docker image repo of the RocketMQ Controller
controllerImage: apacherocketmq/rocketmq-nameserver:5.0.0-alpine-operator-0.4.0
# imagePullPolicy is the image pull policy
imagePullPolicy: IfNotPresent
# resources describes the compute resource requirements and limits
resources:
requests:
memory: "2Gi"
limits:
memory: "2Gi"
# storageMode can be EmptyDir, HostPath, StorageClass
storageMode: HostPath
# hostPath is the local path to store data
hostPath: /data/rocketmq/controller
# volumeClaimTemplates defines the storageClass
volumeClaimTemplates:
- metadata:
name: controller-storage
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 8Gi
5 changes: 5 additions & 0 deletions images/broker/alpine/brokerGenConfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ function create_config() {
if [ $BROKER_ID != 0 ]; then
sed -i 's/brokerRole=.*/brokerRole=SLAVE/g' $BROKER_CONFIG_FILE
fi

if [ "${enableControllerMode}" = "true" ]; then
echo "enableControllerMode=true" >> $BROKER_CONFIG_FILE
echo "controllerAddr=${controllerAddr}" >> $BROKER_CONFIG_FILE
fi
}

create_config
Expand Down
4 changes: 2 additions & 2 deletions images/broker/alpine/build-broker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ fi

ROCKETMQ_VERSION=$1
DOCKERHUB_REPO=apacherocketmq/rocketmq-broker
IMAGE_NAME=${DOCKERHUB_REPO}:${ROCKETMQ_VERSION}-alpine-operator-0.3.0
IMAGE_NAME=${DOCKERHUB_REPO}:${ROCKETMQ_VERSION}-alpine-operator-0.4.0

checkVersion $ROCKETMQ_VERSION

docker build -t $IMAGE_NAME --build-arg version=${ROCKETMQ_VERSION} .

docker push $IMAGE_NAME
#docker push $IMAGE_NAME
66 changes: 66 additions & 0 deletions images/controller/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# 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.
#

FROM openjdk:8-alpine

RUN apk add --no-cache bash gettext nmap-ncat openssl busybox-extras

ARG version

# Rocketmq version
ENV ROCKETMQ_VERSION ${version}

# Rocketmq home
ENV ROCKETMQ_HOME /root/rocketmq/controller

WORKDIR ${ROCKETMQ_HOME}

# Install
RUN set -eux; \
apk add --virtual .build-deps curl gnupg unzip; \
curl https://archive.apache.org/dist/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip -o rocketmq.zip; \
curl https://archive.apache.org/dist/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip.asc -o rocketmq.zip.asc; \
curl -L https://www.apache.org/dist/rocketmq/KEYS -o KEYS; \
gpg --import KEYS; \
gpg --batch --verify rocketmq.zip.asc rocketmq.zip; \
unzip rocketmq.zip; \
mv rocketmq-all*/* . ; \
rmdir rocketmq-all* ; \
rm rocketmq.zip ; \
rm rocketmq.zip.asc KEYS; \
apk del .build-deps ; \
rm -rf /var/cache/apk/* ; \
rm -rf /tmp/*

# Copy customized scripts
COPY runserver-customize.sh ${ROCKETMQ_HOME}/bin/

# Expose controller port
EXPOSE 9878

# Override customized scripts for controller
# Export Java options
# Add ${JAVA_HOME}/lib/ext as java.ext.dirs
RUN mv ${ROCKETMQ_HOME}/bin/runserver-customize.sh ${ROCKETMQ_HOME}/bin/runserver.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/runserver.sh \
&& chmod a+x ${ROCKETMQ_HOME}/bin/mqnamesrv \
&& export JAVA_OPT=" -Duser.home=/opt" \
&& sed -i 's/${JAVA_HOME}\/jre\/lib\/ext/${JAVA_HOME}\/jre\/lib\/ext:${JAVA_HOME}\/lib\/ext/' ${ROCKETMQ_HOME}/bin/tools.sh

WORKDIR ${ROCKETMQ_HOME}/bin

CMD /bin/bash ./mqcontroller -c ${ROCKETMQ_HOME}/conf/controller/controller.conf
43 changes: 43 additions & 0 deletions images/controller/alpine/build-controller-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# 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.

checkVersion()
{
echo "Version = $1"
echo $1 |grep -E "^[0-9]+\.[0-9]+\.[0-9]+" > /dev/null
if [ $? = 0 ]; then
return 1
fi

echo "Version $1 illegal, it should be X.X.X format(e.g. 4.5.0), please check released versions in 'https://dist.apache.org/repos/dist/release/rocketmq/'"
exit 2
}

if [ $# -lt 1 ]; then
echo -e "Usage: sh $0 Version"
exit 2
fi

ROCKETMQ_VERSION=$1
DOCKERHUB_REPO=apacherocketmq/rocketmq-controller
IMAGE_NAME=${DOCKERHUB_REPO}:${ROCKETMQ_VERSION}-alpine-operator-0.4.0

checkVersion $ROCKETMQ_VERSION

docker build -t $IMAGE_NAME --build-arg version=${ROCKETMQ_VERSION} .

#docker push $IMAGE_NAME
Loading