diff --git a/docs/en/deploy-production.md b/docs/en/deploy-production.md index 85aeb3ba..d2f05183 100644 --- a/docs/en/deploy-production.md +++ b/docs/en/deploy-production.md @@ -2,7 +2,31 @@ > This article will introduce how to deploy Rengine to the production environment, where Rengine ApiServer, Controller, Executor, Jobs are deployed to the Kubernetes platform, and HBase is built using CDH6(including HBase and Kafka (or Flink) Cluster) refer to: [blogs.wl4g.com/archives/3368](https://blogs.wl4g.com/archives/3368) - ## Deploy on Kubernetes - [Deploy Rengine Stack (ApiServer, Executor, Controller, Job) to Kubernetes with helm.](../../tools/deploy/helm/rengine-stack/README.md) + +- Deploy success + +```bash +kubectl -n rengine get pods + +NAME READY STATUS RESTARTS AGE +rengine-redis-cluster-0 2/2 Running 0 5m19s +rengine-redis-cluster-1 2/2 Running 0 5m19s +rengine-redis-cluster-2 2/2 Running 0 5m19s +rengine-redis-cluster-3 2/2 Running 0 5m19s +rengine-redis-cluster-4 2/2 Running 0 5m19s +rengine-redis-cluster-5 2/2 Running 0 5m19s +rengine-zookeeper-0 1/1 Running 0 5m19s +rengine-zookeeper-1 1/1 Running 0 5m19s +rengine-zookeeper-2 1/1 Running 0 5m19s +rengine-mongodb-74bcdbd7b9-926v9 1/1 Running 0 5m19s +rengine-minio-566b978c86-x76qg 1/1 Running 0 5m19s +rengine-apiserver-baseline-5b6c9789d9-sxsf5 1/1 Running 0 5m19s +rengine-controller-baseline-78c568946-bhst6 1/1 Running 0 5m19s +rengine-executor-baseline-74f46464ff-qbtd9 1/1 Running 0 5m19s +rengine-ui-baseline-65d966dccc-j2sb8 1/1 Running 0 5m19s +rengine-init-minio 1/1 Completed 0 5m19s +rengine-init-update-rootpassword 1/1 Completed 0 5m19s +``` diff --git a/docs/en/deploy-standalone.md b/docs/en/deploy-standalone.md index a28baaff..fa5031ca 100644 --- a/docs/en/deploy-standalone.md +++ b/docs/en/deploy-standalone.md @@ -5,7 +5,29 @@ ```bash git clone https://github.com/wl4g/rengine.git cd rengine -./run.sh run-standalone -U --prune-all-volumes + +$ ./run.sh run-standalone -U --prune-all-volumes + +$ ./run.sh run-standalone -S +f0779f017ff1 rengine_controller wl4g/rengine-controller:1.0.0 Up 2 minutes +0e7e01ede490 rengine_ui wl4g/rengine-ui:1.0.0 Up 2 minutes +c62284e09d59 rengine_apiserver wl4g/rengine-apiserver:1.0.0 Up 2 minutes +7dc3d38ca03c rengine_mongodb_express mongo-express:0.54.0 Up 2 minutes +ecccb6bf5bab rengine_executor wl4g/rengine-executor-native:1.0.0 Up 2 minutes +5a85d28db4e0 rengine_mongodb bitnami/mongodb:4.4.6 Up 2 minutes +6bba5cfb1b0c rengine_job_tm_default wl4g/rengine-job:1.0.0 Up 2 minutes +66b5df0e5cd3 rengine_job_jm_default wl4g/rengine-job:1.0.0 Up 2 minutes +935c57e75ea7 rengine_kafka_manager registry.cn-shenzhen.aliyuncs.com/wl4g/kafka-manager:v3.0.0.6-2 Up 2 minutes +74f2e3edaf76 rengine_kafka bitnami/kafka:2.2.0 Up 2 minutes +d5344bed2674 rengine_redis_node_5 bitnami/redis-cluster:7.0 Up 2 minutes +cd48ed90c734 rengine_hbase wl4g/hbase:hbase-2.1.0-phoenix-5.1.1 Up 2 minutes +828cd427c341 rengine_redis_node_3 bitnami/redis-cluster:7.0 Up 2 minutes +9f3fae3d4b15 rengine_zookeeper bitnami/zookeeper:3.6.2 Up 2 minutes +03a0b3f1b15f rengine_redis_node_4 bitnami/redis-cluster:7.0 Up 2 minutes +6341acf3ef3c rengine_minio minio/minio:RELEASE.2022-08-26T19-53-15Z Up 2 minutes +eb0e9192aeb5 rengine_redis_node_0 bitnami/redis-cluster:7.0 Up 2 minutes +f71b4e187d7d rengine_redis_node_2 bitnami/redis-cluster:7.0 Up 2 minutes +16c56797b29c rengine_redis_node_1 bitnami/redis-cluster:7.0 Up 2 minutes ``` ## Initial diff --git a/docs/en/devel.md b/docs/en/devel.md index 05e8a0e8..705e8b02 100644 --- a/docs/en/devel.md +++ b/docs/en/devel.md @@ -49,6 +49,8 @@ Usage: ./run.sh [OPTIONS] [arg1] [arg2] ... --skip-build Skip recompile build before building image. -u,--ui Build image for UI. --skip-build Skip recompile build before building image. + -d,--initdb Build image for initdb. + --skip-build Skip recompile build before building image. -A,--all Build image for all components (but excludes the executor-native). --skip-build Skip recompile build before building image. push-image Push component images. @@ -58,6 +60,7 @@ Usage: ./run.sh [OPTIONS] [arg1] [arg2] ... -e,--executor Push image for executor. -E,--executor-native Push image for executor (native). -u,--ui Push image for UI. + -d,--initdb Push image for initdb. -A,--all Push image for all components. build-push Build with Maven and push images for all components. prune-image Prune unused all images. (tag=none) diff --git a/executor/src/main/resources/application.yaml b/executor/src/main/resources/application.yaml index 726468b6..077702c7 100644 --- a/executor/src/main/resources/application.yaml +++ b/executor/src/main/resources/application.yaml @@ -252,7 +252,8 @@ quarkus: #datasource: {} ## see:https://github.com/quarkusio/quarkus-quickstarts/blob/main/mongodb-quickstart/src/main/resources/application.properties mongodb: - connection-string: mongodb://localhost:27017 + ## see:https://www.mongodb.com/community/forums/t/mongodb-authentication-failed-with-spring-data-uri/109256/13 + connection-string: mongodb://localhost:27017/rengine?authSource=admin health: enabled: true metrics: diff --git a/pom.xml b/pom.xml index 819e078e..17adc70d 100644 --- a/pom.xml +++ b/pom.xml @@ -108,7 +108,7 @@ 11 UTF-8 - 3.1.22 + 3.1.26 0.12.1 2.7.3 2021.0.3 diff --git a/rengine-ui b/rengine-ui index 8ced304b..5955e6c1 160000 --- a/rengine-ui +++ b/rengine-ui @@ -1 +1 @@ -Subproject commit 8ced304ba205c5eeb158a3da63475455cd3dfaf8 +Subproject commit 5955e6c11911ecec7770083918bccca83059e2f5 diff --git a/service/src/main/java/com/wl4g/rengine/service/config/RengineServiceProperties.java b/service/src/main/java/com/wl4g/rengine/service/config/RengineServiceProperties.java index e6277900..6cac548e 100644 --- a/service/src/main/java/com/wl4g/rengine/service/config/RengineServiceProperties.java +++ b/service/src/main/java/com/wl4g/rengine/service/config/RengineServiceProperties.java @@ -44,12 +44,23 @@ public class RengineServiceProperties { @NotBlank URI executorEndpoint = URI.create("http://localhost:28002"); + @NotNull + UploadServiceProperties upload = new UploadServiceProperties(); + @NotNull DictServiceProperties dict = new DictServiceProperties(); @NotNull ControllerLogServiceProperties controllerLog = new ControllerLogServiceProperties(); + @Getter + @Setter + @ToString + @NoArgsConstructor + public static class UploadServiceProperties { + String minioEndpoint = "http://localhost:9000"; + } + /** * @see {@link com.wl4g.rengine.executor.execution.ExecutionConfig.ServiceConfig} */ diff --git a/service/src/main/java/com/wl4g/rengine/service/impl/sys/UploadServiceImpl.java b/service/src/main/java/com/wl4g/rengine/service/impl/sys/UploadServiceImpl.java index d9702cbe..0fdc1df6 100644 --- a/service/src/main/java/com/wl4g/rengine/service/impl/sys/UploadServiceImpl.java +++ b/service/src/main/java/com/wl4g/rengine/service/impl/sys/UploadServiceImpl.java @@ -93,17 +93,20 @@ public UploadApplyResult apply(@NotNull UploadApply model) { // New create temporary STS credentials. try { final Credentials credentials = minioManager.createSTSCredentials(upload.getObjectPrefix()); - final MinioClientProperties config = minioManager.getConfig(); + final MinioClientProperties minioConfig = minioManager.getConfig(); return UploadApplyResult.builder() - .endpoint(config.getEndpoint()) - .region(minioManager.getConfig().getRegion()) - // .bucket(details.getBucket()) + // Note: An independent external endpoint should be used to + // avoid the same address as the internal endpoint used by + // apiserver and executor services. + // .endpoint(config.getEndpoint()) + .endpoint(config.getUpload().getMinioEndpoint()) + .region(minioConfig.getRegion()) .bucket(RengineConstants.DEFAULT_MINIO_BUCKET) .accessKey(credentials.accessKey()) .secretKey(credentials.secretKey()) .sessionToken(credentials.sessionToken()) - .partSize(minioManager.getConfig().getUserUpload().getLibraryPartSize().toBytes()) - .fileLimitSize(minioManager.getConfig().getUserUpload().getLibraryFileLimitSize().toBytes()) + .partSize(minioConfig.getUserUpload().getLibraryPartSize().toBytes()) + .fileLimitSize(minioConfig.getUserUpload().getLibraryFileLimitSize().toBytes()) .objectPrefix(upload.getObjectPrefix()) .extensions(safeList(UploadType.of(upload.getUploadType()).getExtensions()).stream() .map(t -> t.getSuffix()) @@ -156,18 +159,21 @@ public UploadSaveResult save(@NotNull UploadSave model) { // with precise authorized write permissions. try { final Credentials credentials = minioManager.createSTSCredentials(upload.getObjectPrefix()); - final MinioClientProperties config = minioManager.getConfig(); + final MinioClientProperties minioConfig = minioManager.getConfig(); return UploadSaveResult.builder() .id(upload.getId()) - .endpoint(config.getEndpoint()) + // Note: An independent external endpoint should be used to + // avoid the same address as the internal endpoint used by + // apiserver and executor services. + // .endpoint(config.getEndpoint()) + .endpoint(config.getUpload().getMinioEndpoint()) .region(minioManager.getConfig().getRegion()) - // .bucket(details.getBucket()) .bucket(RengineConstants.DEFAULT_MINIO_BUCKET) .accessKey(credentials.accessKey()) .secretKey(credentials.secretKey()) .sessionToken(credentials.sessionToken()) - .partSize(minioManager.getConfig().getUserUpload().getLibraryPartSize().toBytes()) - .fileLimitSize(minioManager.getConfig().getUserUpload().getLibraryFileLimitSize().toBytes()) + .partSize(minioConfig.getUserUpload().getLibraryPartSize().toBytes()) + .fileLimitSize(minioConfig.getUserUpload().getLibraryFileLimitSize().toBytes()) .objectPrefix(upload.getObjectPrefix()) .extensions(safeList(uploadType.getExtensions()).stream().map(t -> t.getSuffix()).collect(toList())) .build(); diff --git a/service/src/main/resources/application-mongo.yaml b/service/src/main/resources/application-mongo.yaml index a7c3fdf6..db218b56 100644 --- a/service/src/main/resources/application-mongo.yaml +++ b/service/src/main/resources/application-mongo.yaml @@ -31,6 +31,7 @@ spring: ## see:org.springframework.boot.autoconfigure.data.mongo.MongoDatabaseFactoryDependentConfiguration ## see:org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration ## see:org.springframework.data.mongodb.config.AbstractMongoClientConfiguration#mongoTemplate + ## see:https://www.mongodb.com/community/forums/t/mongodb-authentication-failed-with-spring-data-uri/109256/13 mongodb: #uri: ${RENGINE_DB_URI:mongodb+srv://rengine:123456@mongo.wl4g.io/rengine} uri: ${RENGINE_DB_URI:mongodb://localhost:27017/rengine} diff --git a/service/src/main/resources/application-services.yaml b/service/src/main/resources/application-services.yaml index f5e348da..e0396ee9 100644 --- a/service/src/main/resources/application-services.yaml +++ b/service/src/main/resources/application-services.yaml @@ -14,6 +14,8 @@ rengine: services: executor-endpoint: http://localhost:28002 + upload: + minio-endpoint: http://localhost:9000 dict: dict-cached-prefix: rengine:services:dict:cache dict-cached-expire: 86400_000 diff --git a/tools/build/docker/Dockerfile.initdb b/tools/build/docker/Dockerfile.initdb new file mode 100644 index 00000000..7b7fc434 --- /dev/null +++ b/tools/build/docker/Dockerfile.initdb @@ -0,0 +1,34 @@ +## Copyright 2017 ~ 2025 the original authors James Wong. +## +## Licensed 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 busybox:1.28 + +LABEL maintainer="James Wong" \ + description="Rengine is a cloud native, distributed, generic rule engine platform." \ + repoName=${REPO_NAME} \ + branch=${BRANCH} \ + pr=${PR} \ + tag=${TAG} \ + commit=${COMMIT_ID} \ + buildTime=${BUILD_TIME} \ + buildURL=${BUILD_URL} + +ARG APP_VERSION +ENV APP_VERSION=${APP_VERSION} + +## Note: It should be placed in the initdb dir, because the standard k8s pod volumeMount is the mount directory by default. +COPY tools/db/rengine_init.js /initdb/rengine_init.js + +ENTRYPOINT [ "/bin/sh", "-c" ] diff --git a/tools/build/run.sh b/tools/build/run.sh index 2a7a38a9..aa7345d8 100755 --- a/tools/build/run.sh +++ b/tools/build/run.sh @@ -81,6 +81,8 @@ Usage: ./$(basename $0) [OPTIONS] [arg1] [arg2] ... --skip-build Skip recompile build before building image. -u,--ui Build image for UI. --skip-build Skip recompile build before building image. + -d,--initdb Build image for initdb. + --skip-build Skip recompile build before building image. -A,--all Build image for all components (but excludes the executor-native). --skip-build Skip recompile build before building image. push-image Push component images. @@ -90,6 +92,7 @@ Usage: ./$(basename $0) [OPTIONS] [arg1] [arg2] ... -e,--executor Push image for executor. -E,--executor-native Push image for executor (native). -u,--ui Push image for UI. + -d,--initdb Push image for initdb. -A,--all Push image for all components. build-push Build with Maven and push images for all components. prune-image Prune unused all images. (tag=none) @@ -282,16 +285,29 @@ function do_build_image_with_npm() { local build_file=$3 log "Docker building for $app_name:$app_version ..." - docker build -t wl4g/rengine-${app_name}:${app_version} -f $build_file \ + docker build --no-cache -t wl4g/rengine-${app_name}:${app_version} -f $build_file \ --build-arg REPO_NAME=rengine-${app_name} \ --build-arg BUILD_TIME=$(date +'%Y%m%dT%H%M%S') \ - --build-arg COMMIT_ID=$(git log | head -1 | awk -F ' ' '{print $2}' | cut -c 1-12) . + --build-arg COMMIT_ID=$(git log | head -1 | awk -F ' ' '{print $2}' | cut -c 1-12) \ + ${BASE_DIR}/rengine-${app_name} +} + +function do_build_initdb() { + POM_VERSION=${POM_VERSION:-$(print_pom_version)} + log "Building rengine initdb image for ${POM_VERSION}" + + docker build --no-cache -t wl4g/rengine-initdb:${POM_VERSION} \ + --build-arg REPO_NAME=$(print_pom_version) \ + --build-arg BUILD_TIME=$(date +'%Y%m%dT%H%M%S') \ + --build-arg COMMIT_ID=$(git log | head -1 | awk -F ' ' '{print $2}' | cut -c 1-12) \ + --build-arg APP_VERSION=${POM_VERSION} \ + -f ${BASE_DIR}/tools/build/docker/Dockerfile.initdb ${BASE_DIR} } function do_push_image() { POM_VERSION=${POM_VERSION:-$(print_pom_version)} local image_registry="$DOCKERHUB_REGISTRY" - local image_name="$2" + local image_name="$1" local image_tag="$POM_VERSION" if [ -z "$image_registry" ]; then @@ -311,6 +327,7 @@ function do_push_image() { logDebug "Pushing image to $image_registry/$image_name:$image_tag ..." docker tag wl4g/$image_name:$image_tag $image_registry/$image_name:$image_tag docker push $image_registry/$image_name:$image_tag + } function do_prune_image() { @@ -388,7 +405,6 @@ function do_prune_all_volumes_with_run_standalone() { fi } - # --- Main. --- case $1 in version) @@ -449,7 +465,7 @@ case $1 in do_build_maven "-T 4C clean install" fi - docker build -t wl4g/rengine-executor:$(print_pom_version) -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkustar . + docker build --no-cache -t wl4g/rengine-executor:$(print_pom_version) -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkustar . ;; -E|--executor-native) ## First of all, it should be built in full to prevent the dependent modules from being updated. @@ -469,7 +485,7 @@ case $1 in log "Building executor native docker image ..." cd ${BASE_DIR}/executor - docker build -t wl4g/rengine-executor-native:$(print_pom_version) -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkusnative . + docker build --no-cache -t wl4g/rengine-executor-native:$(print_pom_version) -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkusnative . cd .. ;; -u|--ui) @@ -479,6 +495,9 @@ case $1 in fi do_build_image_with_npm ui $(print_pom_version) "${BASE_DIR}/rengine-ui/tools/build/docker/Dockerfile.vue" ;; + -d|--initdb) + do_build_initdb + ;; -A|--all) POM_VERSION=${POM_VERSION:-$(print_pom_version)} if [ "$3" != "--skip-build" ]; then @@ -494,7 +513,7 @@ case $1 in wait do_dl_serve_stop - docker build -t wl4g/rengine-executor:${POM_VERSION} -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkustar + docker build --no-cache -t wl4g/rengine-executor:${POM_VERSION} -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkustar ### Not enabled for now, because it usually fails due to insufficient resources on the build machine. To build a native image, you should use the '-E' option alone. #${BASE_DIR}/mvnw install -f ${BASE_DIR}/executor/pom.xml \ @@ -504,9 +523,11 @@ case $1 in # -Dquarkus.native.container-build=true \ # -Dquarkus.native.container-runtime=docker # - #docker build -t wl4g/rengine-executor-native:${POM_VERSION} -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkusnative + #docker build --no-cache -t wl4g/rengine-executor-native:${POM_VERSION} -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkusnative do_build_image_with_npm ui $(print_pom_version) "${BASE_DIR}/rengine-ui/tools/build/docker/Dockerfile.vue" + + do_build_initdb ;; *) usages; exit 1 @@ -515,30 +536,34 @@ case $1 in push-image) case $2 in -a|--apiserver) - do_push_image "$3" "rengine-apiserver" + do_push_image "rengine-apiserver" ;; -c|--controller) - do_push_image "$3" "rengine-controller" + do_push_image "rengine-controller" ;; -j|--job) - do_push_image "$3" "rengine-job" + do_push_image "rengine-job" ;; -e|--executor) - do_push_image "$3" "rengine-executor" + do_push_image "rengine-executor" ;; -E|--executor-native) - do_push_image "$3" "rengine-executor-native" + do_push_image "rengine-executor-native" ;; -u|--ui) - do_push_image "$3" "rengine-ui" + do_push_image "rengine-ui" + ;; + -d|--initdb) + do_push_image "rengine-initdb" ;; -A|--all) - do_push_image "$3" "rengine-apiserver" & - do_push_image "$3" "rengine-controller" & - do_push_image "$3" "rengine-job" & - do_push_image "$3" "rengine-executor" & - do_push_image "$3" "rengine-executor-native" & - do_push_image "$3" "rengine-ui" & + do_push_image "rengine-apiserver" & + do_push_image "rengine-controller" & + do_push_image "rengine-job" & + do_push_image "rengine-executor" & + do_push_image "rengine-executor-native" & + do_push_image "rengine-ui" & + do_push_image "rengine-initdb" & wait ;; *) @@ -553,7 +578,7 @@ case $1 in do_build_maven "install -f ${BASE_DIR}/apiserver/pom.xml -Pbuild:tar:docker" & do_build_maven "install -f ${BASE_DIR}/controller/pom.xml -Pbuild:tar:docker" & do_build_maven "install -f ${BASE_DIR}/job/pom.xml -Pbuild:docker" & - docker build -t wl4g/rengine-executor:${POM_VERSION} -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkustar & + docker build --no-cache -t wl4g/rengine-executor:${POM_VERSION} -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkustar & wait ### Not enabled for now, because it usually fails due to insufficient resources on the build machine. To build a native image, you should use the '-E' option alone. @@ -564,16 +589,19 @@ case $1 in # -Dquarkus.native.container-build=true \ # -Dquarkus.native.container-runtime=docker # - #docker build -t wl4g/rengine-executor-native:${POM_VERSION} -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkusnative + #docker build --no-cache -t wl4g/rengine-executor-native:${POM_VERSION} -f ${BASE_DIR}/tools/build/docker/Dockerfile.quarkusnative do_build_image_with_npm ui ${POM_VERSION} "${BASE_DIR}/rengine-ui/tools/build/docker/Dockerfile.vue" - do_push_image "$2" "rengine-apiserver" - do_push_image "$2" "rengine-controller" - do_push_image "$2" "rengine-job" - do_push_image "$2" "rengine-executor" - do_push_image "$2" "rengine-executor-native" - do_push_image "$3" "rengine-ui" + do_build_initdb + + do_push_image "rengine-apiserver" + do_push_image "rengine-controller" + do_push_image "rengine-job" + do_push_image "rengine-executor" + do_push_image "rengine-executor-native" + do_push_image "rengine-ui" + do_push_image "rengine-initdb" ;; prune-image) do_prune_image diff --git a/tools/deploy/compose/docker-compose.yml b/tools/deploy/compose/docker-compose.yml index 4f90675b..8ac748cf 100644 --- a/tools/deploy/compose/docker-compose.yml +++ b/tools/deploy/compose/docker-compose.yml @@ -25,13 +25,17 @@ services: ## see:https://github.com/bitnami/containers/blob/main/bitnami/mongodb-sharded/docker-compose-multiple-shards.yml mongodb: image: docker.io/bitnami/mongodb:4.4.6 - command: "" + ## Note: Same problem with initializing rengine_init.js in helm values.yaml. + ## see:https://raw.githubusercontent.com/wl4g/rengine/master/tools/db/rengine_init.js?token=GHSAT0AAAAAAB4ATLINIBXFCKAGNEVCKZZAZCCEZDQ + ## see:https://gitee.com/wl4g/rengine/raw/master/tools/db/rengine_init.js + ## see:https://pkg.wl4g.com/public/rengine_init.js + #command: /opt/bitnami/scripts/mongodb/run.sh container_name: rengine_mongodb environment: - BITNAMI_DEBUG=true - ALLOW_EMPTY_PASSWORD=no - MONGODB_PRIMARY_HOST=mongodb:27017 - # - MONGODB_PRIMARY_ROOT_USER=default + # - MONGODB_PRIMARY_ROOT_USER=root - MONGODB_ADVERTISED_HOSTNAME=mongodb - MONGODB_REPLICA_SET_MODE=primary - MONGODB_REPLICA_SET_KEY=defaultReplicaSet @@ -41,12 +45,12 @@ services: - MONGODB_DISABLE_SYSTEM_LOG=no - MONGODB_DISABLE_JAVASCRIPT=no - MONGODB_SYSTEM_LOG_VERBOSITY=0 - #- MONGODB_INITIAL_PRIMARY_ROOT_USER=mongo - #- MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD=changeme - - MONGODB_USERNAME=default - - MONGODB_PASSWORD=changeme + # - MONGODB_INITIAL_PRIMARY_ROOT_USER=mongo + # - MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD=changeme + # - MONGODB_USERNAME=rengine + # - MONGODB_PASSWORD=changeme + # - MONGODB_DATABASE=rengine - MONGODB_ROOT_PASSWORD=changeme - - MONGODB_DATABASE=rengine restart: unless-stopped networks: - rengine_net @@ -73,7 +77,7 @@ services: - VCAP_APP_PORT=28081 - ME_CONFIG_BASICAUTH_USERNAME=admin - ME_CONFIG_BASICAUTH_PASSWORD=admin - #- ME_CONFIG_MONGODB_URL=mongodb://mongodb:27017/rengine + #- ME_CONFIG_MONGODB_URL=mongodb://root:changeme@mongodb:27017 - ME_CONFIG_MONGODB_SERVER=mongodb - ME_CONFIG_MONGODB_PORT=27017 #- ME_CONFIG_MONGODB_ADMINUSERNAME=mongodb @@ -278,7 +282,9 @@ services: ui: image: wl4g/rengine-ui:1.0.0 container_name: rengine_ui - #environment: + environment: + ## eg: rengine-apiserver.rengine.svc.cluster.local + - APISERVER=apiserver restart: unless-stopped networks: - rengine_net @@ -295,7 +301,7 @@ services: image: wl4g/rengine-apiserver:1.0.0 entrypoint: "/bin/bash" command: "-c \"cd /opt/apps/ecm/apiserver-package/apiserver-current && java -cp .:lib/* com.wl4g.rengine.service.deploy.RengineRootPasswordTool \ - --connectionString mongodb://default:changeme@mongodb:27017/rengine \ + --connectionString mongodb://root:changeme@mongodb:27017 \ --isClusterMode false \ --database rengine \ --rootPassword changeme\"" @@ -355,7 +361,7 @@ services: container_name: rengine_apiserver environment: # see:https://stackoverflow.com/questions/49767683/what-does-no-compatible-attachment-provider-is-available-mean - SPRING_ARTHAS_ENABLED=false - - SPRING_DATA_MONGODB_URI=mongodb://mongodb:27017/rengine + - SPRING_DATA_MONGODB_URI=mongodb://root:changeme@mongodb:27017 - SPRING_REDIS_PASSWORD=bitnami - SPRING_REDIS_CLUSTER_NODES=redis-node-0:6379,redis-node-1:6379,redis-node-2:6379,redis-node-3:6379,redis-node-4:6379,redis-node-5:6379 - MINIO_ENDPOINT=http://${NODE_IP}:9000 @@ -396,7 +402,7 @@ services: container_name: rengine_controller environment: - SPRING_ARTHAS_ENABLED=false - - SPRING_DATA_MONGODB_URI=mongodb://mongodb:27017/rengine + - SPRING_DATA_MONGODB_URI=mongodb://root:changeme@mongodb:27017 - SPRING_REDIS_PASSWORD=bitnami - SPRING_REDIS_CLUSTER_NODES=redis-node-0:6379,redis-node-1:6379,redis-node-2:6379,redis-node-3:6379,redis-node-4:6379,redis-node-5:6379 - MINIO_ENDPOINT=http://minio:9000 @@ -436,7 +442,7 @@ services: image: wl4g/rengine-executor-native:1.0.0 container_name: rengine_executor environment: - - QUARKUS_MONGODB_CONNECTION_STRING=mongodb://mongodb:27017/rengine + - QUARKUS_MONGODB_CONNECTION_STRING=mongodb://root:changeme@mongodb:27017 - QUARKUS_REDIS_PASSWORD=bitnami - QUARKUS_REDIS_HOSTS=redis://redis-node-0:6379,redis://redis-node-1:6379,redis://redis-node-2:6379,redis://redis-node-3:6379,redis://redis-node-4:6379,redis://redis-node-5:6379 - MINIO_ENDPOINT=http://minio:9000 diff --git a/tools/deploy/helm/rengine-stack/charts/apiserver/templates/configmap.yaml b/tools/deploy/helm/rengine-stack/charts/apiserver/templates/configmap.yaml index 0e7e317e..d0b28f85 100644 --- a/tools/deploy/helm/rengine-stack/charts/apiserver/templates/configmap.yaml +++ b/tools/deploy/helm/rengine-stack/charts/apiserver/templates/configmap.yaml @@ -68,13 +68,16 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} helm.sh/chart: {{ template "app.chart" . }} data: -{{- if not (empty .Values.agentConfigs.items)}} - {{- range $key, $value := .Values.agentConfigs.items}} +## Note: Environment variables are special configurations, first import global variables, +## then import local variables, local variables take precedence. +{{- if not (empty .Values.global.commonConfigs.agentConfigs.items) }} + {{- range $key, $value := .Values.global.commonConfigs.agentConfigs.items }} {{ $key | nindent 2 }}.config: |- {{ $value | nindent 4 }} {{- end}} -{{- else if not (empty .Values.global.commonConfigs.agentConfigs.items) }} - {{- range $key, $value := .Values.global.commonConfigs.agentConfigs.items}} +{{- end}} +{{- if not (empty .Values.agentConfigs.items) }} + {{- range $key, $value := .Values.agentConfigs.items}} {{ $key | nindent 2 }}.config: |- {{ $value | nindent 4 }} {{- end}} diff --git a/tools/deploy/helm/rengine-stack/charts/apiserver/templates/deployment-baseline.yaml b/tools/deploy/helm/rengine-stack/charts/apiserver/templates/deployment-baseline.yaml index edd6ff33..f0de34c2 100644 --- a/tools/deploy/helm/rengine-stack/charts/apiserver/templates/deployment-baseline.yaml +++ b/tools/deploy/helm/rengine-stack/charts/apiserver/templates/deployment-baseline.yaml @@ -65,7 +65,8 @@ spec: app.kubernetes.io/name: {{ template "app.name" . }} app.kubernetes.io/release: {{ .Release.Name }} ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.baselineTag | default .Chart.AppVersion }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} + app.kubernetes.io/canaryVersion: {{ $baselineTagPrefix | default .Chart.AppVersion }} spec: hostAliases: {{- range $name, $app := .Values.global.componentServices }} @@ -232,7 +233,7 @@ spec: mountPath: /etc/{{ template "app.name" . }}/ {{- end }} - {{- if or (not (empty .Values.agentConfigs.items.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items.items)) }} + {{- if or (not (empty .Values.agentConfigs.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items)) }} ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume - name: agentconfig-volume {{- if not (empty .Values.agentConfigs.items.mountPath) }} diff --git a/tools/deploy/helm/rengine-stack/charts/apiserver/templates/deployment-upgrade.yaml b/tools/deploy/helm/rengine-stack/charts/apiserver/templates/deployment-upgrade.yaml index c68be9ba..3a1ed92f 100644 --- a/tools/deploy/helm/rengine-stack/charts/apiserver/templates/deployment-upgrade.yaml +++ b/tools/deploy/helm/rengine-stack/charts/apiserver/templates/deployment-upgrade.yaml @@ -65,7 +65,8 @@ spec: app.kubernetes.io/name: {{ template "app.name" . }} app.kubernetes.io/release: {{ .Release.Name }} ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.upgradeTag | default .Chart.AppVersion }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} + app.kubernetes.io/canaryVersion: {{ $upgradeTagPrefix | default .Chart.AppVersion }} spec: hostAliases: {{- range $name, $app := .Values.global.componentServices }} @@ -232,7 +233,7 @@ spec: mountPath: /etc/{{ template "app.name" . }}/ {{- end }} - {{- if or (not (empty .Values.agentConfigs.items.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items.items)) }} + {{- if or (not (empty .Values.agentConfigs.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items)) }} ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume - name: agentconfig-volume {{- if not (empty .Values.agentConfigs.items.mountPath) }} diff --git a/tools/deploy/helm/rengine-stack/charts/apiserver/templates/istio.yaml b/tools/deploy/helm/rengine-stack/charts/apiserver/templates/istio.yaml index a35bfadb..d2365d95 100644 --- a/tools/deploy/helm/rengine-stack/charts/apiserver/templates/istio.yaml +++ b/tools/deploy/helm/rengine-stack/charts/apiserver/templates/istio.yaml @@ -113,6 +113,7 @@ spec: ## The primary business api routes. - route: {{- if not (empty .Values.image.baselineTag) }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} - destination: host: {{ template "app.name" . }}.{{ .Release.Namespace }}.svc.cluster.local port: @@ -125,9 +126,10 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.baselineTag }} + x-app-version: {{ $baselineTagPrefix }} {{- end }} {{- if not (empty .Values.image.upgradeTag) }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} - destination: host: {{ template "app.name" . }}.{{ .Release.Namespace }}.svc.cluster.local port: @@ -140,7 +142,7 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.upgradeTag }} + x-app-version: {{ $upgradeTagPrefix }} {{- end }} timeout: 10s ## Multiple matchers represent and operations. @@ -179,7 +181,8 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.baselineTag }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} + x-app-version: {{ $baselineTagPrefix }} ## see:https://istio.io/v1.14/docs/reference/config/networking/virtual-service/#TCPRoute {{- if .Values.governance.istio.ingress.tcp.enabled }} tcp: @@ -238,20 +241,22 @@ spec: ## see:https://istio.io/v1.14/docs/reference/config/networking/virtual-service/#Destination subsets: {{- if not (empty .Values.image.baselineTag) }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} - name: baseline labels: ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.baselineTag | default "tips:please:check:baselineTag" }} + app.kubernetes.io/canaryVersion: {{ $baselineTagPrefix | default "tips:please:check:baselineTag" }} trafficPolicy: loadBalancer: ## see:https://istio.io/v1.14/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings-SimpleLB simple: ROUND_ROBIN # UNSPECIFIED|RANDOM|PASSTHROUGH|LEAST_REQUEST|ROUND_ROBIN|LEAST_CONN {{- end }} {{- if not (empty .Values.image.upgradeTag) }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} - name: upgrade labels: ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.upgradeTag | default "tips:please:check:upgradeTag" }} + app.kubernetes.io/canaryVersion: {{ $upgradeTagPrefix | default "tips:please:check:upgradeTag" }} trafficPolicy: loadBalancer: ## see:https://istio.io/v1.14/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings-SimpleLB diff --git a/tools/deploy/helm/rengine-stack/charts/controller/templates/configmap.yaml b/tools/deploy/helm/rengine-stack/charts/controller/templates/configmap.yaml index 0e7e317e..d0b28f85 100644 --- a/tools/deploy/helm/rengine-stack/charts/controller/templates/configmap.yaml +++ b/tools/deploy/helm/rengine-stack/charts/controller/templates/configmap.yaml @@ -68,13 +68,16 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} helm.sh/chart: {{ template "app.chart" . }} data: -{{- if not (empty .Values.agentConfigs.items)}} - {{- range $key, $value := .Values.agentConfigs.items}} +## Note: Environment variables are special configurations, first import global variables, +## then import local variables, local variables take precedence. +{{- if not (empty .Values.global.commonConfigs.agentConfigs.items) }} + {{- range $key, $value := .Values.global.commonConfigs.agentConfigs.items }} {{ $key | nindent 2 }}.config: |- {{ $value | nindent 4 }} {{- end}} -{{- else if not (empty .Values.global.commonConfigs.agentConfigs.items) }} - {{- range $key, $value := .Values.global.commonConfigs.agentConfigs.items}} +{{- end}} +{{- if not (empty .Values.agentConfigs.items) }} + {{- range $key, $value := .Values.agentConfigs.items}} {{ $key | nindent 2 }}.config: |- {{ $value | nindent 4 }} {{- end}} diff --git a/tools/deploy/helm/rengine-stack/charts/controller/templates/deployment-baseline.yaml b/tools/deploy/helm/rengine-stack/charts/controller/templates/deployment-baseline.yaml index edd6ff33..f0de34c2 100644 --- a/tools/deploy/helm/rengine-stack/charts/controller/templates/deployment-baseline.yaml +++ b/tools/deploy/helm/rengine-stack/charts/controller/templates/deployment-baseline.yaml @@ -65,7 +65,8 @@ spec: app.kubernetes.io/name: {{ template "app.name" . }} app.kubernetes.io/release: {{ .Release.Name }} ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.baselineTag | default .Chart.AppVersion }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} + app.kubernetes.io/canaryVersion: {{ $baselineTagPrefix | default .Chart.AppVersion }} spec: hostAliases: {{- range $name, $app := .Values.global.componentServices }} @@ -232,7 +233,7 @@ spec: mountPath: /etc/{{ template "app.name" . }}/ {{- end }} - {{- if or (not (empty .Values.agentConfigs.items.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items.items)) }} + {{- if or (not (empty .Values.agentConfigs.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items)) }} ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume - name: agentconfig-volume {{- if not (empty .Values.agentConfigs.items.mountPath) }} diff --git a/tools/deploy/helm/rengine-stack/charts/controller/templates/deployment-upgrade.yaml b/tools/deploy/helm/rengine-stack/charts/controller/templates/deployment-upgrade.yaml index c68be9ba..3a1ed92f 100644 --- a/tools/deploy/helm/rengine-stack/charts/controller/templates/deployment-upgrade.yaml +++ b/tools/deploy/helm/rengine-stack/charts/controller/templates/deployment-upgrade.yaml @@ -65,7 +65,8 @@ spec: app.kubernetes.io/name: {{ template "app.name" . }} app.kubernetes.io/release: {{ .Release.Name }} ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.upgradeTag | default .Chart.AppVersion }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} + app.kubernetes.io/canaryVersion: {{ $upgradeTagPrefix | default .Chart.AppVersion }} spec: hostAliases: {{- range $name, $app := .Values.global.componentServices }} @@ -232,7 +233,7 @@ spec: mountPath: /etc/{{ template "app.name" . }}/ {{- end }} - {{- if or (not (empty .Values.agentConfigs.items.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items.items)) }} + {{- if or (not (empty .Values.agentConfigs.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items)) }} ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume - name: agentconfig-volume {{- if not (empty .Values.agentConfigs.items.mountPath) }} diff --git a/tools/deploy/helm/rengine-stack/charts/controller/templates/istio.yaml b/tools/deploy/helm/rengine-stack/charts/controller/templates/istio.yaml index a35bfadb..d2365d95 100644 --- a/tools/deploy/helm/rengine-stack/charts/controller/templates/istio.yaml +++ b/tools/deploy/helm/rengine-stack/charts/controller/templates/istio.yaml @@ -113,6 +113,7 @@ spec: ## The primary business api routes. - route: {{- if not (empty .Values.image.baselineTag) }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} - destination: host: {{ template "app.name" . }}.{{ .Release.Namespace }}.svc.cluster.local port: @@ -125,9 +126,10 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.baselineTag }} + x-app-version: {{ $baselineTagPrefix }} {{- end }} {{- if not (empty .Values.image.upgradeTag) }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} - destination: host: {{ template "app.name" . }}.{{ .Release.Namespace }}.svc.cluster.local port: @@ -140,7 +142,7 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.upgradeTag }} + x-app-version: {{ $upgradeTagPrefix }} {{- end }} timeout: 10s ## Multiple matchers represent and operations. @@ -179,7 +181,8 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.baselineTag }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} + x-app-version: {{ $baselineTagPrefix }} ## see:https://istio.io/v1.14/docs/reference/config/networking/virtual-service/#TCPRoute {{- if .Values.governance.istio.ingress.tcp.enabled }} tcp: @@ -238,20 +241,22 @@ spec: ## see:https://istio.io/v1.14/docs/reference/config/networking/virtual-service/#Destination subsets: {{- if not (empty .Values.image.baselineTag) }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} - name: baseline labels: ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.baselineTag | default "tips:please:check:baselineTag" }} + app.kubernetes.io/canaryVersion: {{ $baselineTagPrefix | default "tips:please:check:baselineTag" }} trafficPolicy: loadBalancer: ## see:https://istio.io/v1.14/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings-SimpleLB simple: ROUND_ROBIN # UNSPECIFIED|RANDOM|PASSTHROUGH|LEAST_REQUEST|ROUND_ROBIN|LEAST_CONN {{- end }} {{- if not (empty .Values.image.upgradeTag) }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} - name: upgrade labels: ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.upgradeTag | default "tips:please:check:upgradeTag" }} + app.kubernetes.io/canaryVersion: {{ $upgradeTagPrefix | default "tips:please:check:upgradeTag" }} trafficPolicy: loadBalancer: ## see:https://istio.io/v1.14/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings-SimpleLB diff --git a/tools/deploy/helm/rengine-stack/charts/executor/templates/configmap.yaml b/tools/deploy/helm/rengine-stack/charts/executor/templates/configmap.yaml index 0e7e317e..d0b28f85 100644 --- a/tools/deploy/helm/rengine-stack/charts/executor/templates/configmap.yaml +++ b/tools/deploy/helm/rengine-stack/charts/executor/templates/configmap.yaml @@ -68,13 +68,16 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} helm.sh/chart: {{ template "app.chart" . }} data: -{{- if not (empty .Values.agentConfigs.items)}} - {{- range $key, $value := .Values.agentConfigs.items}} +## Note: Environment variables are special configurations, first import global variables, +## then import local variables, local variables take precedence. +{{- if not (empty .Values.global.commonConfigs.agentConfigs.items) }} + {{- range $key, $value := .Values.global.commonConfigs.agentConfigs.items }} {{ $key | nindent 2 }}.config: |- {{ $value | nindent 4 }} {{- end}} -{{- else if not (empty .Values.global.commonConfigs.agentConfigs.items) }} - {{- range $key, $value := .Values.global.commonConfigs.agentConfigs.items}} +{{- end}} +{{- if not (empty .Values.agentConfigs.items) }} + {{- range $key, $value := .Values.agentConfigs.items}} {{ $key | nindent 2 }}.config: |- {{ $value | nindent 4 }} {{- end}} diff --git a/tools/deploy/helm/rengine-stack/charts/executor/templates/deployment-baseline.yaml b/tools/deploy/helm/rengine-stack/charts/executor/templates/deployment-baseline.yaml index edd6ff33..f0de34c2 100644 --- a/tools/deploy/helm/rengine-stack/charts/executor/templates/deployment-baseline.yaml +++ b/tools/deploy/helm/rengine-stack/charts/executor/templates/deployment-baseline.yaml @@ -65,7 +65,8 @@ spec: app.kubernetes.io/name: {{ template "app.name" . }} app.kubernetes.io/release: {{ .Release.Name }} ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.baselineTag | default .Chart.AppVersion }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} + app.kubernetes.io/canaryVersion: {{ $baselineTagPrefix | default .Chart.AppVersion }} spec: hostAliases: {{- range $name, $app := .Values.global.componentServices }} @@ -232,7 +233,7 @@ spec: mountPath: /etc/{{ template "app.name" . }}/ {{- end }} - {{- if or (not (empty .Values.agentConfigs.items.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items.items)) }} + {{- if or (not (empty .Values.agentConfigs.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items)) }} ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume - name: agentconfig-volume {{- if not (empty .Values.agentConfigs.items.mountPath) }} diff --git a/tools/deploy/helm/rengine-stack/charts/executor/templates/deployment-upgrade.yaml b/tools/deploy/helm/rengine-stack/charts/executor/templates/deployment-upgrade.yaml index c68be9ba..3a1ed92f 100644 --- a/tools/deploy/helm/rengine-stack/charts/executor/templates/deployment-upgrade.yaml +++ b/tools/deploy/helm/rengine-stack/charts/executor/templates/deployment-upgrade.yaml @@ -65,7 +65,8 @@ spec: app.kubernetes.io/name: {{ template "app.name" . }} app.kubernetes.io/release: {{ .Release.Name }} ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.upgradeTag | default .Chart.AppVersion }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} + app.kubernetes.io/canaryVersion: {{ $upgradeTagPrefix | default .Chart.AppVersion }} spec: hostAliases: {{- range $name, $app := .Values.global.componentServices }} @@ -232,7 +233,7 @@ spec: mountPath: /etc/{{ template "app.name" . }}/ {{- end }} - {{- if or (not (empty .Values.agentConfigs.items.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items.items)) }} + {{- if or (not (empty .Values.agentConfigs.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items)) }} ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume - name: agentconfig-volume {{- if not (empty .Values.agentConfigs.items.mountPath) }} diff --git a/tools/deploy/helm/rengine-stack/charts/executor/templates/istio.yaml b/tools/deploy/helm/rengine-stack/charts/executor/templates/istio.yaml index a35bfadb..d2365d95 100644 --- a/tools/deploy/helm/rengine-stack/charts/executor/templates/istio.yaml +++ b/tools/deploy/helm/rengine-stack/charts/executor/templates/istio.yaml @@ -113,6 +113,7 @@ spec: ## The primary business api routes. - route: {{- if not (empty .Values.image.baselineTag) }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} - destination: host: {{ template "app.name" . }}.{{ .Release.Namespace }}.svc.cluster.local port: @@ -125,9 +126,10 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.baselineTag }} + x-app-version: {{ $baselineTagPrefix }} {{- end }} {{- if not (empty .Values.image.upgradeTag) }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} - destination: host: {{ template "app.name" . }}.{{ .Release.Namespace }}.svc.cluster.local port: @@ -140,7 +142,7 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.upgradeTag }} + x-app-version: {{ $upgradeTagPrefix }} {{- end }} timeout: 10s ## Multiple matchers represent and operations. @@ -179,7 +181,8 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.baselineTag }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} + x-app-version: {{ $baselineTagPrefix }} ## see:https://istio.io/v1.14/docs/reference/config/networking/virtual-service/#TCPRoute {{- if .Values.governance.istio.ingress.tcp.enabled }} tcp: @@ -238,20 +241,22 @@ spec: ## see:https://istio.io/v1.14/docs/reference/config/networking/virtual-service/#Destination subsets: {{- if not (empty .Values.image.baselineTag) }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} - name: baseline labels: ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.baselineTag | default "tips:please:check:baselineTag" }} + app.kubernetes.io/canaryVersion: {{ $baselineTagPrefix | default "tips:please:check:baselineTag" }} trafficPolicy: loadBalancer: ## see:https://istio.io/v1.14/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings-SimpleLB simple: ROUND_ROBIN # UNSPECIFIED|RANDOM|PASSTHROUGH|LEAST_REQUEST|ROUND_ROBIN|LEAST_CONN {{- end }} {{- if not (empty .Values.image.upgradeTag) }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} - name: upgrade labels: ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.upgradeTag | default "tips:please:check:upgradeTag" }} + app.kubernetes.io/canaryVersion: {{ $upgradeTagPrefix | default "tips:please:check:upgradeTag" }} trafficPolicy: loadBalancer: ## see:https://istio.io/v1.14/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings-SimpleLB diff --git a/tools/deploy/helm/rengine-stack/charts/ui/templates/configmap.yaml b/tools/deploy/helm/rengine-stack/charts/ui/templates/configmap.yaml index 0e7e317e..d0b28f85 100644 --- a/tools/deploy/helm/rengine-stack/charts/ui/templates/configmap.yaml +++ b/tools/deploy/helm/rengine-stack/charts/ui/templates/configmap.yaml @@ -68,13 +68,16 @@ metadata: app.kubernetes.io/managed-by: {{ .Release.Service }} helm.sh/chart: {{ template "app.chart" . }} data: -{{- if not (empty .Values.agentConfigs.items)}} - {{- range $key, $value := .Values.agentConfigs.items}} +## Note: Environment variables are special configurations, first import global variables, +## then import local variables, local variables take precedence. +{{- if not (empty .Values.global.commonConfigs.agentConfigs.items) }} + {{- range $key, $value := .Values.global.commonConfigs.agentConfigs.items }} {{ $key | nindent 2 }}.config: |- {{ $value | nindent 4 }} {{- end}} -{{- else if not (empty .Values.global.commonConfigs.agentConfigs.items) }} - {{- range $key, $value := .Values.global.commonConfigs.agentConfigs.items}} +{{- end}} +{{- if not (empty .Values.agentConfigs.items) }} + {{- range $key, $value := .Values.agentConfigs.items}} {{ $key | nindent 2 }}.config: |- {{ $value | nindent 4 }} {{- end}} diff --git a/tools/deploy/helm/rengine-stack/charts/ui/templates/deployment-baseline.yaml b/tools/deploy/helm/rengine-stack/charts/ui/templates/deployment-baseline.yaml index e4f825b6..f0de34c2 100644 --- a/tools/deploy/helm/rengine-stack/charts/ui/templates/deployment-baseline.yaml +++ b/tools/deploy/helm/rengine-stack/charts/ui/templates/deployment-baseline.yaml @@ -65,7 +65,8 @@ spec: app.kubernetes.io/name: {{ template "app.name" . }} app.kubernetes.io/release: {{ .Release.Name }} ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.baselineTag | default .Chart.AppVersion }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} + app.kubernetes.io/canaryVersion: {{ $baselineTagPrefix | default .Chart.AppVersion }} spec: hostAliases: {{- range $name, $app := .Values.global.componentServices }} @@ -107,7 +108,7 @@ spec: {{- end }} volumes: - ## Pre-start script. + ## PreStart script. {{- if or (not (empty .Values.preStartScript)) (not (empty .Values.global.commonConfigs.preStartScript)) }} - name: pre-start-volume configMap: @@ -141,7 +142,7 @@ spec: {{- end}} {{- end}} - ## APP primary configuration. + ## Application core configuration. ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume {{- if or (not (empty .Values.appConfigs.items)) (not (empty .Values.global.commonConfigs.appConfigs.items)) }} - name: appconfig-volume @@ -232,7 +233,7 @@ spec: mountPath: /etc/{{ template "app.name" . }}/ {{- end }} - {{- if or (not (empty .Values.agentConfigs.items.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items.items)) }} + {{- if or (not (empty .Values.agentConfigs.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items)) }} ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume - name: agentconfig-volume {{- if not (empty .Values.agentConfigs.items.mountPath) }} @@ -258,7 +259,6 @@ spec: - name: appdata-volume mountPath: /opt/apps/ecm/{{ template "app.name" . }}-package/{{ template "app.name" . }}-current/data/ - - name: applog-volume mountPath: /opt/apps/ecm/{{ template "app.name" . }}-package/{{ template "app.name" . }}-current/log/ diff --git a/tools/deploy/helm/rengine-stack/charts/ui/templates/deployment-upgrade.yaml b/tools/deploy/helm/rengine-stack/charts/ui/templates/deployment-upgrade.yaml index c68be9ba..3a1ed92f 100644 --- a/tools/deploy/helm/rengine-stack/charts/ui/templates/deployment-upgrade.yaml +++ b/tools/deploy/helm/rengine-stack/charts/ui/templates/deployment-upgrade.yaml @@ -65,7 +65,8 @@ spec: app.kubernetes.io/name: {{ template "app.name" . }} app.kubernetes.io/release: {{ .Release.Name }} ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.upgradeTag | default .Chart.AppVersion }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} + app.kubernetes.io/canaryVersion: {{ $upgradeTagPrefix | default .Chart.AppVersion }} spec: hostAliases: {{- range $name, $app := .Values.global.componentServices }} @@ -232,7 +233,7 @@ spec: mountPath: /etc/{{ template "app.name" . }}/ {{- end }} - {{- if or (not (empty .Values.agentConfigs.items.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items.items)) }} + {{- if or (not (empty .Values.agentConfigs.items)) (not (empty .Values.global.commonConfigs.agentConfigs.items)) }} ## see:https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume - name: agentconfig-volume {{- if not (empty .Values.agentConfigs.items.mountPath) }} diff --git a/tools/deploy/helm/rengine-stack/charts/ui/templates/istio.yaml b/tools/deploy/helm/rengine-stack/charts/ui/templates/istio.yaml index a35bfadb..d2365d95 100644 --- a/tools/deploy/helm/rengine-stack/charts/ui/templates/istio.yaml +++ b/tools/deploy/helm/rengine-stack/charts/ui/templates/istio.yaml @@ -113,6 +113,7 @@ spec: ## The primary business api routes. - route: {{- if not (empty .Values.image.baselineTag) }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} - destination: host: {{ template "app.name" . }}.{{ .Release.Namespace }}.svc.cluster.local port: @@ -125,9 +126,10 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.baselineTag }} + x-app-version: {{ $baselineTagPrefix }} {{- end }} {{- if not (empty .Values.image.upgradeTag) }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} - destination: host: {{ template "app.name" . }}.{{ .Release.Namespace }}.svc.cluster.local port: @@ -140,7 +142,7 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.upgradeTag }} + x-app-version: {{ $upgradeTagPrefix }} {{- end }} timeout: 10s ## Multiple matchers represent and operations. @@ -179,7 +181,8 @@ spec: headers: response: add: - x-app-version: {{ .Values.image.baselineTag }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} + x-app-version: {{ $baselineTagPrefix }} ## see:https://istio.io/v1.14/docs/reference/config/networking/virtual-service/#TCPRoute {{- if .Values.governance.istio.ingress.tcp.enabled }} tcp: @@ -238,20 +241,22 @@ spec: ## see:https://istio.io/v1.14/docs/reference/config/networking/virtual-service/#Destination subsets: {{- if not (empty .Values.image.baselineTag) }} + {{- $baselineTagPrefix := (splitList "@sha256:" .Values.image.baselineTag) | first }} - name: baseline labels: ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.baselineTag | default "tips:please:check:baselineTag" }} + app.kubernetes.io/canaryVersion: {{ $baselineTagPrefix | default "tips:please:check:baselineTag" }} trafficPolicy: loadBalancer: ## see:https://istio.io/v1.14/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings-SimpleLB simple: ROUND_ROBIN # UNSPECIFIED|RANDOM|PASSTHROUGH|LEAST_REQUEST|ROUND_ROBIN|LEAST_CONN {{- end }} {{- if not (empty .Values.image.upgradeTag) }} + {{- $upgradeTagPrefix := (splitList "@sha256:" .Values.image.upgradeTag) | first }} - name: upgrade labels: ## for canary governance labels. - app.kubernetes.io/canaryVersion: {{ .Values.image.upgradeTag | default "tips:please:check:upgradeTag" }} + app.kubernetes.io/canaryVersion: {{ $upgradeTagPrefix | default "tips:please:check:upgradeTag" }} trafficPolicy: loadBalancer: ## see:https://istio.io/v1.14/zh/docs/reference/config/networking/destination-rule/#LoadBalancerSettings-SimpleLB diff --git a/tools/deploy/helm/rengine-stack/templates/NOTES.txt b/tools/deploy/helm/rengine-stack/templates/NOTES.txt index a821d9ae..e71f246e 100644 --- a/tools/deploy/helm/rengine-stack/templates/NOTES.txt +++ b/tools/deploy/helm/rengine-stack/templates/NOTES.txt @@ -16,7 +16,7 @@ openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -subj '/O=wl4g Inc./CN=*.{{ $domain }}' -keyout {{ $domain }}.key -out {{ $domain }}.crt kubectl create -n istio-system secret tls wl4g-credential --key={{ $domain }}.key --cert={{ $domain }}.crt -+ The access requests routed through Istio-ingressgateway using NodePort: ++ Try testing access requests routed through Istio-ingressgateway using NodePort: export nodeIP=$(ip a | grep -E '^[0-9]+: (em|eno|enp|ens|eth|wlp)+[0-9]' -A2 | grep inet | awk -F ' ' '{print $2}' | cut -f1 -d/ | head -1) export nodePort=$(kubectl -n istio-system get svc istio-ingressgateway -ojson | jq -r '.spec.ports[] | select (.name == "http2") | .nodePort') @@ -32,7 +32,21 @@ kubectl get secret -n {{ .Release.Namespace }} {{ $secretName }} -o jsonpath="{.data.initRootPassword}" | base64 -d; echo -+ Login with the password from step 4 and the username: '{{ $initUserName }}' ++ Generate local static DNS + +export UI_SVC_IP=$(kubectl -n rengine get svc/rengine-ui -o jsonpath="{.spec.clusterIP}") +export API_SVC_IP=$(kubectl -n rengine get svc/rengine-apiserver -o jsonpath="{.spec.clusterIP}") +export S3_SVC_IP=$(kubectl -n rengine get svc/rengine-minio -o jsonpath="{.spec.clusterIP}") + +sudo bash -c "cat << EOF >> /etc/hosts + +# Generate static dns to access the address of rengine. +${UI_SVC_IP} console.rengine.io +${API_SVC_IP} api.rengine.io +${S3_SVC_IP} s3.rengine.io +EOF" + ++ Login access to http://console.rengine.io + Here an example of what you should execution command-line on your next grayscale upgrade (canary): diff --git a/tools/deploy/helm/rengine-stack/templates/rengine_init.yaml b/tools/deploy/helm/rengine-stack/templates/rengine_init.yaml index 59e79eaa..784b5906 100644 --- a/tools/deploy/helm/rengine-stack/templates/rengine_init.yaml +++ b/tools/deploy/helm/rengine-stack/templates/rengine_init.yaml @@ -45,9 +45,8 @@ spec: command: - "/bin/bash" - "-c" - # Should using: mongodb://root:changeme@{{ .Release.Name }}-mongodb:27017/rengine ??? - "cd $APP_HOME && java -cp .:lib/* com.wl4g.rengine.service.deploy.RengineRootPasswordTool \ - --connectionString mongodb://{{ .Release.Name }}-mongodb:27017/rengine \ + --connectionString mongodb://root:changeme@{{ .Release.Name }}-mongodb:27017 \ --isClusterMode false \ --database rengine \ --rootPassword {{ $initRootPassword }}" diff --git a/tools/deploy/helm/rengine-stack/values.yaml b/tools/deploy/helm/rengine-stack/values.yaml index 8f3ca660..5940f707 100644 --- a/tools/deploy/helm/rengine-stack/values.yaml +++ b/tools/deploy/helm/rengine-stack/values.yaml @@ -99,13 +99,14 @@ ui: enabled: true image: repository: wl4g/rengine-ui - baselineTag: 1.0.0 + baselineTag: 1.0.1@sha256:e79b3c60b758d2c79ea78bafd30219bb2955bf9118b5b0f6990999983096391c #upgradeTag: latest - # command: ["sh", "-c", "ls -al /var/run/"] - command: [] + command: ["sh", "-c", "ls -al /etc/nginx/conf.d/"] + # command: [] - envConfigs: {} + envConfigs: + APISERVER: rengine-apiserver.rengine.svc.cluster.local agentConfigs: mountPath: "/etc/nginx/" @@ -189,7 +190,7 @@ global: # export SPRING_SLEUTH_OTEL_EXPORTER_JAEGER_ENDPOENT="http://jaeger-collector.jaeger.svc.cluster.local:14250" # ## # ## see:./service/src/main/resources/application-mongo.yaml - # export SPRING_DATA_MONGODB_URI="mongodb://rengine-mongodb:27017/rengine" + # export SPRING_DATA_MONGODB_URI="mongodb://root:changeme@rengine-mongodb:27017/rengine" # ## # ## see:./service/src/main/resources/application-redis.yaml # export SPRING_REDIS_CLUSTER_NODES="\ @@ -223,8 +224,8 @@ global: SPRING_SLEUTH_OTEL_EXPORTER_OTLP_ENDPOENT: "http://otlp-collector.otlp.svc.cluster.local:4317" SPRING_SLEUTH_OTEL_EXPORTER_JAEGER_ENDPOENT: "http://jaeger-collector.jaeger.svc.cluster.local:14250" ## see:./service/src/main/resources/application-mongo.yaml - #SPRING_DATA_MONGODB_URI: "mongodb://root:changeme@rengine-mongodb:27017/rengine" # ??? - SPRING_DATA_MONGODB_URI: "mongodb://rengine-mongodb:27017/rengine" + ## see:https://www.mongodb.com/community/forums/t/mongodb-authentication-failed-with-spring-data-uri/109256/13 + SPRING_DATA_MONGODB_URI: "mongodb://root:changeme@rengine-mongodb:27017/rengine?authSource=admin" ## see:./service/src/main/resources/application-redis.yaml #SPRING_REDIS_USERNAME: "default" SPRING_REDIS_PASSWORD: "changeme" @@ -240,7 +241,8 @@ global: ## RENGINE_CONTROLLER_ZOOKEEPER_SERVER_LISTS: "rengine-zookeeper:2181" ## see:./executor/src/main/resources/application.yaml - QUARKUS_MONGODB_CONNECTION_STRING: "mongodb://rengine-mongodb:27017/rengine" + ## see:https://www.mongodb.com/community/forums/t/mongodb-authentication-failed-with-spring-data-uri/109256/13 + QUARKUS_MONGODB_CONNECTION_STRING: "mongodb://root:changeme@rengine-mongodb:27017/rengine?authSource=admin" QUARKUS_REDIS_PASSWORD: "changeme" QUARKUS_REDIS_HOSTS: "\ redis://rengine-redis-cluster-0.rengine-redis-cluster-headless:6379,\ @@ -251,6 +253,10 @@ global: redis://rengine-redis-cluster-5.rengine-redis-cluster-headless:6379" QUARKUS_LOG_FILE_PATH: "/tmp/executor.log" ## + ## see:./service/src/main/resources/application-services.yaml + ## + RENGINE_SERVICES_UPLOAD_MINIO_ENDPOINT: "http://s3.rengine.io:9000" + ## ## see:./executor/src/main/resources/application.yaml and ./service/src/main/resources/application-minio.yaml ## MINIO_ENDPOINT: "http://rengine-minio:9000" @@ -724,28 +730,63 @@ jaeger: ## ------------------------------- (Internal) MongoDB Configuration. ---------------------------------- ## see:https://github.com/bitnami/charts/tree/main/bitnami/mongodb mongodb: + extraEnvVars: + - name: BITNAMI_DEBUG + value: "true" + - name: ALLOW_EMPTY_PASSWORD + value: "no" + # - name: MONGODB_PRIMARY_HOST + # value: "rengine-mongodb:27017" + # - name: "MONGODB_PRIMARY_ROOT_USER + # value: root + # - name: MONGODB_ADVERTISED_HOSTNAME + # value: rengine-mongodb + - name: MONGODB_REPLICA_SET_MODE + value: primary + - name: MONGODB_REPLICA_SET_KEY + value: defaultReplicaSet + - name: MONGODB_ENABLE_JOURNAL + value: "yes" + - name: MONGODB_ENABLE_IPV6 + value: "no" + - name: MONGODB_ENABLE_DIRECTORY_PER_DB + value: "no" + - name: MONGODB_DISABLE_SYSTEM_LOG + value: "no" + - name: MONGODB_DISABLE_JAVASCRIPT + value: "no" + - name: MONGODB_SYSTEM_LOG_VERBOSITY + value: "0" + # - name: MONGODB_INITIAL_PRIMARY_ROOT_USER + # value: mongo + # - name: MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD + # value: changeme + # - name: MONGODB_USERNAME + # value: rengine + # - name: MONGODB_PASSWORD + # value: changeme + # - name: MONGODB_DATABASE + # value: rengine + - name: MONGODB_ROOT_PASSWORD + value: changeme initContainers: - ## Initializing rengine database scripts. - - name: rengine-init-mongodb - image: busybox:1.28 + ## Rengine init DB. (Note: If the download fails, you can comment this init container, manually import the script) + - name: rengine-initdb + image: wl4g/rengine-initdb:1.0.0@sha256:949b31ba2891f45b3f7c1d45b3f778a5adc53f96787128d49cfaf435b4d2f56a imagePullPolicy: IfNotPresent - command: - - wget - - "-O" - - "/docker-entrypoint-initdb.d/rengine_init.js" - - https://raw.githubusercontent.com/wl4g/rengine/master/tools/db/rengine_init.js?token=GHSAT0AAAAAAB4ATLINKSZ7RSHXRT6IJ674ZCCD6XA + ## Note: Same problem with initializing rengine_init.js in docker compose yaml. + ## see:https://raw.githubusercontent.com/wl4g/rengine/master/tools/db/rengine_init.js?token=GHSAT0AAAAAAB4ATLINIBXFCKAGNEVCKZZAZCCEZDQ + ## see:https://gitee.com/wl4g/rengine/raw/master/tools/db/rengine_init.js + command: [ "cp", "/initdb/rengine_init.js", "/docker-entrypoint-initdb.d/" ] volumeMounts: - name: initdir mountPath: "/docker-entrypoint-initdb.d/" - extraVolumeMounts: - name: initdir - mountPath: "/docker-entrypoint-initdb.d/rengine_init.js" - + mountPath: "/docker-entrypoint-initdb.d/" extraVolumes: - name: initdir emptyDir: {} - auth: enabled: false rootUser: root @@ -753,7 +794,7 @@ mongodb: # databases: # - "rengine" # usernames: - # - rengine + # - "rengine" # passwords: # - "changeme"