Skip to content

Commit

Permalink
feat: support deploy ros with s3 and mysql in cluster
Browse files Browse the repository at this point in the history
Signed-off-by: wangxye <xuanyewang.cs@gmail.com>
  • Loading branch information
wangxye committed Oct 28, 2023
1 parent a2ac4fc commit e451110
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 192 deletions.
54 changes: 54 additions & 0 deletions distribution/docker/Dockerfile-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# 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:17-jdk-alpine

MAINTAINER automq

USER root

# Install dependency
# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add --no-cache bash gettext nmap-ncat openssl busybox-extras libc6-compat libgcc libstdc++


ARG version

# Rocketmq version
ENV ROCKETMQ_VERSION ${version}

ARG ROCKETMQ_DIR

ENV ROCKETMQ_NAME rocketmq-on-s3
ENV ROCKETMQ_HOME /home/rocketmq/${ROCKETMQ_NAME}-${ROCKETMQ_VERSION}

WORKDIR ${ROCKETMQ_HOME}

# Install
COPY rocketmq/ ${ROCKETMQ_HOME}/dist

RUN mv ${ROCKETMQ_HOME}/dist/* ${ROCKETMQ_HOME}/ && \
rm -rf ${ROCKETMQ_HOME}/dist

EXPOSE 8081

RUN chmod a+x ${ROCKETMQ_HOME}/bin/run-server.sh

# Export Java options
RUN export JAVA_OPT=" -Duser.home=/opt"

WORKDIR ${ROCKETMQ_HOME}/bin
25 changes: 25 additions & 0 deletions distribution/docker/build-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env 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.


ROCKETMQ_VERSION=$1
ROCKETMQ_REPO=$2

cp -r ../../rocketmq ./


docker build --no-cache -f Dockerfile -t ${ROCKETMQ_REPO}:${ROCKETMQ_VERSION} --build-arg version=${ROCKETMQ_VERSION} . --progress=plain
24 changes: 24 additions & 0 deletions distribution/helm/clean-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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.

helm uninstall s3-localstack
helm uninstall mysql
helm uninstall rocketmq-on-s3

kubectl delete -f deploy/init-db-configmap.yaml
rm deploy/init-db-configmap.yaml
rm deploy/ddl.sql
47 changes: 41 additions & 6 deletions distribution/helm/deploy-ci.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,53 @@
#!/bin/bash
# echo $KUBE_CONFIG_DATA | base64 -d > ./config

# DB_SCRIPTS=$1
# 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.

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
REPO_DIR=$(dirname "$(dirname "$SCRIPT_DIR")")
export $REPO_DIR
cd "$SCRIPT_DIR" || exit 1
if [ ! -f "deploy/ddl.sql" ]
then
cp "$REPO_DIR/controller/src/main/resources/ddl.sql" deploy/
fi

# make ddl to configmap
if [ ! -f "deploy/init-db-configmap.yaml" ]
then
cp deploy/configmap-template.yaml deploy/init-db-configmap.yaml
sed 's/^/ /' deploy/ddl.sql >> deploy/init-db-configmap.yaml
fi

kubectl apply -f deploy/init-db-configmap.yaml

echo "Deploying s3-localstack..."
# deploy s3-localstack
helm repo add localstack-charts https://localstack.github.io/helm-charts
helm install s3-localstack localstack-charts/localstack -f deploy/localstack_s3.yaml
# --kubeconfig ./config
helm install s3-localstack localstack-charts/localstack -f deploy/localstack_s3.yaml

sleep 10

echo "Deploying MySQL..."
# deploy mysql
helm repo add bitnami https://charts.bitnami.com/bitnami

helm install mysql bitnami/mysql -f deploy/mysql.yaml

sleep 10
echo "Deploying rocketmq..."
# deploy rocketmq-on-s3
helm install rocketmq-on-s3 ../rocketmq-k8s-helm/ -f deploy/helm_sample_values.yaml
helm install rocketmq-on-s3 . -f deploy/helm_sample_values.yaml


22 changes: 22 additions & 0 deletions distribution/helm/deploy/configmap-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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: v1
kind: ConfigMap
metadata:
name: mysql-initdb-config
data:
initdb.sql: |
use metadata;
177 changes: 0 additions & 177 deletions distribution/helm/deploy/ddl.sql

This file was deleted.

4 changes: 2 additions & 2 deletions distribution/helm/deploy/helm_sample_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ broker:


db:
url: "jdbc:mysql://10.1.0.119:3306/metadata"
url: "jdbc:mysql://mysql:3306/metadata"
userName: "root"
password: "root"
password: "passward"
Loading

0 comments on commit e451110

Please # to comment.