微服务开发框架部署

在此之前,应该准备好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.19.0 \
  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.19.0"
  13. },
  14. ...
  15. }
  16. ]
  17. }

部署 base service

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

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

  1. preJob:
  2. timeout: 300
  3. preConfig:
  4. datasource:
  5. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true
  6. username: choerodon
  7. password: password
  8. preInitDB:
  9. datasource:
  10. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/base_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true
  11. username: choerodon
  12. password: password
  13. env:
  14. open:
  15. SPRING_CLOUD_CONFIG_ENABLED: true
  16. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  17. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc/base_service?useUnicode=true&characterEncoding=utf-8&useSSL=false&useInformationSchema=true&remarks=true
  18. SPRING_DATASOURCE_USERNAME: choerodon
  19. SPRING_DATASOURCE_PASSWORD: password
  20. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  21. SPRING_REDIS_PORT: 6379
  22. SPRING_REDIS_DATABASE: 6
  23. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  24. 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.19.0 \
  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

部署 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
  9. SPRING_DATASOURCE_USERNAME: choerodon
  10. SPRING_REDIS_DATABASE: 4
  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
  18. username: choerodon
  • 部署服务
  1. helm install c7n/manager-service \
  2. -f manager-service.yaml \
  3. --name manager-service \
  4. --version 0.19.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_ENABLED: true
  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/asgard_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  8. SPRING_DATASOURCE_USERNAME: choerodon
  9. SPRING_REDIS_DATABASE: 3
  10. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  11. SPRING_REDIS_PORT: 6379
  12. preJob:
  13. preConfig:
  14. datasource:
  15. password: password
  16. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  17. username: choerodon
  18. preInitDB:
  19. datasource:
  20. password: password
  21. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/asgard_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  22. username: choerodon
  • 部署服务
  1. helm install c7n/asgard-service \
  2. -f asgard-service.yaml \
  3. --name asgard-service \
  4. --version 0.19.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

部署 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_ENABLED: true
  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/notify_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  8. SPRING_DATASOURCE_USERNAME: choerodon
  9. SPRING_REDIS_DATABASE: 4
  10. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  11. ingress:
  12. enabled: true
  13. host: notify.example.choerodon.io
  14. preJob:
  15. preConfig:
  16. datasource:
  17. password: password
  18. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  19. username: choerodon
  20. preInitDB:
  21. datasource:
  22. password: password
  23. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/notify_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  24. username: choerodon
  25. service:
  26. enabled: true
  27. name: notify-service
  • 部署服务
  1. helm install c7n/notify-service \
  2. -f notify-service.yaml \
  3. --name notify-service \
  4. --version 0.19.0 \
  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_ENABLED: true
  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
  8. SPRING_DATASOURCE_USERNAME: choerodon
  9. SPRING_REDIS_DATABASE: 4
  10. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  11. SPRING_REDIS_PORT: 6379
  12. SPRING_CACHE_MULTI_L1_ENABLED: true
  13. SPRING_CACHE_MULTI_L2_ENABLED: false
  14. ingress:
  15. enabled: true
  16. host: api.example.choerodon.io
  17. preJob:
  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
  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.19.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_ENABLED: true
  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/base_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  9. SPRING_DATASOURCE_USERNAME: choerodon
  10. SPRING_REDIS_DATABASE: 6
  11. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  12. preJob:
  13. preConfig:
  14. datasource:
  15. password: password
  16. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  17. username: choerodon
  • 部署服务
  1. helm install c7n/oauth-server \
  2. -f oauth-server.yaml \
  3. --name oauth-server \
  4. --version 0.19.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_ACCESSKEY: admin
  5. MINIO_ENDPOINT: http://minio.example.choerodon.io
  6. MINIO_SECRETKEY: password
  7. SPRING_CLOUD_CONFIG_ENABLED: true
  8. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  9. preJob:
  10. preConfig:
  11. datasource:
  12. password: password
  13. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  14. username: choerodon
  • 部署服务
  1. helm install c7n/file-service \
  2. -f file-service.yaml \
  3. --name file-service \
  4. --version 0.19.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