微服务开发框架部署

在此之前,应该准备好Mysql、Harbor、Gitlab、Minio,Chartmuseum这些组件的信息。按以下搭建顺序进行搭建,请不要随意调整搭建顺序。以下验证部署是否成功如未特别说明则执行验证的环境为任意一台集群Master节点。
  • 如果您的主机性能或网络较差,建议您添加额外的参数以延长超时时间 —set preJob.timeout=1000 ,其中1000表示1000秒后超时。
部署成功后Choerodon平台默认登录名为admin,默认密码为admin。

添加Choerodon Chart仓库

  1. helm repo add c7n https://openchart.choerodon.com.cn/choerodon/c7n/
  2. helm repo update
0.19以前的base-service的数据库为iam_service,0.19以后更名为base_service,对于配置文件中是使用iam_service还是base_service遵从一下标准:如果是新安装的版本,就使用base_service,如果是升级上来的版本,原版本数据库使用的是什么数据库名称,配置文件中就配置对应的数据库名称

创建数据库

  • 编写参数配置文件 create-c7nfw-db.yaml
  1. env:
  2. MYSQL_HOST: c7n-mysql.c7n-system.svc
  3. MYSQL_PORT: "3306"
  4. MYSQL_USER: root
  5. MYSQL_PASS: password
  6. SQL_SCRIPT: |
  7. CREATE USER IF NOT EXISTS 'choerodon'@'%' IDENTIFIED BY 'password';
  8. CREATE DATABASE IF NOT EXISTS base_service DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  9. CREATE DATABASE IF NOT EXISTS manager_service DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  10. CREATE DATABASE IF NOT EXISTS asgard_service DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  11. CREATE DATABASE IF NOT EXISTS notify_service DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  12. GRANT ALL PRIVILEGES ON base_service.* TO choerodon@'%';
  13. GRANT ALL PRIVILEGES ON manager_service.* TO choerodon@'%';
  14. GRANT ALL PRIVILEGES ON asgard_service.* TO choerodon@'%';
  15. GRANT ALL PRIVILEGES ON notify_service.* TO choerodon@'%';
  16. FLUSH PRIVILEGES;
  • 执行安装
  1. helm install c7n/mysql-client \
  2. -f create-c7nfw-db.yaml \
  3. --version 0.1.0 \
  4. --name create-c7nfw-db \
  5. --namespace c7n-system

部署 register server

  1. env:
  2. open:
  3. REGISTER_SERVICE_NAMESPACE: c7n-system
  4. rbac:
  5. create: true
  6. service:
  7. enabled: true
  8. name: register-server
  • 执行安装
  1. helm install c7n/go-register-server \
  2. -f register-server.yaml \
  3. --name register-server \
  4. --version 0.20.2 \
  5. --namespace c7n-system
  • 验证部署

    • 验证命令
  1. curl $(kubectl get svc register-server -o jsonpath="{.spec.clusterIP}" -n c7n-system):8000/eureka/apps
  • 出现以下类似信息即为成功部署
  1. {
  2. "name": "go-register-server",
  3. "instance": [
  4. {
  5. "instanceId": "192.168.3.19:go-register-server:8000",
  6. "hostName": "192.168.3.19",
  7. "app": "go-register-server",
  8. "ipAddr": "192.168.3.19",
  9. "status": "UP",
  10. ...
  11. "metadata": {
  12. "VERSION": "0.20.2"
  13. },
  14. ...
  15. }
  16. ]
  17. }

部署 manager service

  • 若需了解项目详情及各项参数含义,请移步 choerodon/manager-service

  • 编写参数配置文件 manager-service.yaml

  1. env:
  2. open:
  3. CHOERODON_GATEWAY_DOMAIN: api.example.choerodon.io
  4. CHOERODON_SWAGGER_OAUTH_URL: http://api.example.choerodon.io/oauth/oauth/authorize
  5. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  6. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  7. SPRING_DATASOURCE_PASSWORD: password
  8. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  9. SPRING_DATASOURCE_USERNAME: choerodon
  10. SPRING_REDIS_DATABASE: 1
  11. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  12. SPRING_REDIS_PORT: 6379
  13. preJob:
  14. preInitDB:
  15. datasource:
  16. password: password
  17. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  18. username: choerodon
  • 部署服务
  1. helm install c7n/manager-service \
  2. -f manager-service.yaml \
  3. --name manager-service \
  4. --version 0.20.0 \
  5. --namespace c7n-system
  • 验证部署

    • 验证命令
  1. curl -s $(kubectl get po -n c7n-system -l choerodon.io/release=manager-service -o jsonpath="{.items[0].status.podIP}"):8964/actuator/health | jq -r .status
  • 出现以下类似信息即为成功部署
  1. UP

部署 asgard service

  • 若需了解项目详情及各项参数含义,请移步 choerodon/asgard-service

  • 编写参数配置文件 asgard-service.yaml

  1. env:
  2. open:
  3. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  4. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  5. SPRING_DATASOURCE_PASSWORD: password
  6. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/asgard_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  7. SPRING_DATASOURCE_USERNAME: choerodon
  8. SPRING_REDIS_DATABASE: 2
  9. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  10. SPRING_REDIS_PORT: 6379
  11. preJob:
  12. timeout: 1800
  13. preInitDB:
  14. datasource:
  15. password: password
  16. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/asgard_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  17. username: choerodon
  • 部署服务
  1. helm install c7n/asgard-service \
  2. -f asgard-service.yaml \
  3. --name asgard-service \
  4. --version 0.20.0 \
  5. --namespace c7n-system
  • 验证部署

    • 验证命令
  1. curl -s $(kubectl get po -n c7n-system -l choerodon.io/release=asgard-service -o jsonpath="{.items[0].status.podIP}"):18081/actuator/health | jq -r .status
  • 出现以下类似信息即为成功部署
  1. UP

部署 base service

  • 若需了解项目详情及各项参数含义,请移步 choerodon/base-service

  • 编写参数配置文件 base-service.yaml

  1. preJob:
  2. timeout: 1800
  3. preInitDB:
  4. datasource:
  5. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/base_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  6. username: choerodon
  7. password: password
  8. # 初始化数据库,更新数据的时候忽略的表或列
  9. # 在excel中有默认值的表,在初始化更新表时不想恢复到默认值,可进行设置
  10. exclusion: iam_user.hash_password,oauth_client.web_server_redirect_uri,oauth_ldap.server_address,oauth_ldap.object_class,iam_role.is_enabled,fd_organization.name
  11. env:
  12. open:
  13. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  14. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc/base_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  15. SPRING_DATASOURCE_USERNAME: choerodon
  16. SPRING_DATASOURCE_PASSWORD: password
  17. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  18. SPRING_REDIS_PORT: 6379
  19. SPRING_REDIS_DATABASE: 3
  20. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  21. CHOERODON_GATEWAY_URL: http://api.example.choerodon.io
  • 部署服务
  1. helm install c7n/base-service \
  2. -f base-service.yaml \
  3. --name base-service \
  4. --version 0.20.1 \
  5. --namespace c7n-system
  • 验证部署

    • 验证命令
  1. curl -s $(kubectl get po -n c7n-system -l choerodon.io/release=base-service -o jsonpath="{.items[0].status.podIP}"):8031/actuator/health | jq -r .status
  • 出现以下类似信息即为成功部署
  1. UP

部署 notify service

  • 若需了解项目详情及各项参数含义,请移步 choerodon/notify-service

  • 编写参数配置文件 notify-service.yaml

  1. env:
  2. open:
  3. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  4. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  5. SPRING_DATASOURCE_PASSWORD: password
  6. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/notify_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  7. SPRING_DATASOURCE_USERNAME: choerodon
  8. SPRING_REDIS_DATABASE: 4
  9. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  10. ingress:
  11. enabled: true
  12. host: notify.example.choerodon.io
  13. preJob:
  14. timeout: 1800
  15. preInitDB:
  16. datasource:
  17. password: password
  18. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/notify_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  19. username: choerodon
  20. service:
  21. enabled: true
  22. name: notify-service
  • 部署服务
  1. helm install c7n/notify-service \
  2. -f notify-service.yaml \
  3. --name notify-service \
  4. --version 0.20.3 \
  5. --namespace c7n-system
  • 验证部署

    • 验证命令
  1. curl -s $(kubectl get po -n c7n-system -l choerodon.io/release=notify-service -o jsonpath="{.items[0].status.podIP}"):18086/actuator/health | jq -r .status
  • 出现以下类似信息即为成功部署
  1. UP

部署 api gateway

  • 若需了解项目详情及各项参数含义,请移步 choerodon/api-gateway

  • 编写参数配置文件 api-gateway.yaml

  1. env:
  2. open:
  3. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  4. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  5. SPRING_DATASOURCE_PASSWORD: password
  6. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/base_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  7. SPRING_DATASOURCE_USERNAME: choerodon
  8. SPRING_REDIS_DATABASE: 5
  9. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  10. SPRING_REDIS_PORT: 6379
  11. SPRING_CACHE_MULTI_L1_ENABLED: true
  12. SPRING_CACHE_MULTI_L2_ENABLED: false
  13. ingress:
  14. enabled: true
  15. host: api.example.choerodon.io
  16. preJob:
  17. timeout: 1800
  18. preConfig:
  19. datasource:
  20. password: password
  21. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  22. username: choerodon
  23. service:
  24. enabled: true
  • 部署服务
  1. helm install c7n/api-gateway \
  2. -f api-gateway.yaml \
  3. --name api-gateway \
  4. --version 0.20.0 \
  5. --namespace c7n-system
  • 验证部署

    • 验证命令
  1. curl -s $(kubectl get po -n c7n-system -l choerodon.io/release=api-gateway -o jsonpath="{.items[0].status.podIP}"):8081/actuator/health | jq -r .status
  • 出现以下类似信息即为成功部署
  1. UP

部署 oauth server

  • 若需了解项目详情及各项参数含义,请移步 choerodon/oauth-server

  • 编写参数配置文件 oauth-server.yaml

  1. env:
  2. open:
  3. CHOERODON_DEFAULT_REDIRECT_URL: http://c7n.example.choerodon.io
  4. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  5. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  6. SPRING_DATASOURCE_PASSWORD: password
  7. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/base_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true&allowMultiQueries=true&serverTimezone=Asia/Shanghai
  8. SPRING_DATASOURCE_USERNAME: choerodon
  9. SPRING_REDIS_DATABASE: 6
  10. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  11. preJob:
  12. timeout: 1800
  • 部署服务
  1. helm install c7n/oauth-server \
  2. -f oauth-server.yaml \
  3. --name oauth-server \
  4. --version 0.20.0 \
  5. --namespace c7n-system
  • 验证部署

    • 验证命令
  1. curl -s $(kubectl get po -n c7n-system -l choerodon.io/release=oauth-server -o jsonpath="{.items[0].status.podIP}"):8021/actuator/health | jq -r .status
  • 出现以下类似信息即为成功部署
  1. UP

部署 file service

  • 若需了解项目详情及各项参数含义,请移步 choerodon/file-service

  • 编写参数配置文件 file-service.yaml

  1. env:
  2. open:
  3. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  4. MINIO_ENDPOINT: http://minio.example.choerodon.io
  5. MINIO_ACCESSKEY: AKIAIOSFODNN7EXAMPLE
  6. MINIO_SECRETKEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
  7. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  8. preJob:
  9. timeout: 1800
  • 部署服务
  1. helm install c7n/file-service \
  2. -f file-service.yaml \
  3. --name file-service \
  4. --version 0.20.0 \
  5. --namespace c7n-system
  • 验证部署

    • 验证命令
  1. curl -s $(kubectl get po -n c7n-system -l choerodon.io/release=file-service -o jsonpath="{.items[0].status.podIP}"):9091/actuator/health | jq -r .status
  • 出现以下类似信息即为成功部署
  1. UP