持续交付部署

在此之前,应该准备好Mysql、Harbor、Gitlab、Minio,Chartmuseum这些组件的信息。按以下搭建顺序进行搭建,请不要随意调整搭建顺序。

添加choerodon chart仓库

  1. helm repo add c7n https://openchart.choerodon.com.cn/choerodon/c7n/
  2. helm repo update

创建数据库

  • 编写参数配置文件 create-c7ncd-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 devops_service DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  9. CREATE DATABASE IF NOT EXISTS gitlab_service DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  10. CREATE DATABASE IF NOT EXISTS workflow_service DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  11. GRANT ALL PRIVILEGES ON devops_service.* TO choerodon@'%';
  12. GRANT ALL PRIVILEGES ON gitlab_service.* TO choerodon@'%';
  13. GRANT ALL PRIVILEGES ON workflow_service.* TO choerodon@'%';
  14. FLUSH PRIVILEGES;
  • 执行安装
  1. helm install c7n/mysql-client \
  2. -f create-c7ncd-db.yaml \
  3. --version 0.1.0 \
  4. --name create-c7ncd-db \
  5. --namespace c7n-system

部署devops service

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

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

  1. env:
  2. open:
  3. AGENT_CERTMANAGERURL: https://openchart.choerodon.com.cn/choerodon/infra/
  4. AGENT_REPOURL: https://openchart.choerodon.com.cn/choerodon/c7n/
  5. AGENT_SERVICEURL: ws://devops.example.choerodon.io/agent/
  6. AGENT_VERSION: 0.18.0
  7. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  8. SECURITY_IGNORED: /ci,/webhook,/v2/api-docs,/agent/**,/ws/**,/webhook/**
  9. SERVICES_GATEWAY_URL: http://api.example.choerodon.io
  10. SERVICES_GITLAB_PASSWORD: password
  11. SERVICES_GITLAB_PROJECTLIMIT: 100
  12. SERVICES_GITLAB_SSHURL: gitlab.example.choerodon.io:32222
  13. SERVICES_GITLAB_URL: http://gitlab.example.choerodon.io
  14. SERVICES_HARBOR_BASEURL: https://registry.example.choerodon.io
  15. SERVICES_HARBOR_INSECURESKIPTLSVERIFY: true
  16. SERVICES_HARBOR_PASSWORD: Harbor12345
  17. SERVICES_HARBOR_USERNAME: admin
  18. SERVICES_HELM_URL: http://chart.example.choerodon.io
  19. SPRING_CLOUD_CONFIG_ENABLED: true
  20. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  21. SPRING_DATASOURCE_PASSWORD: password
  22. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/devops_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  23. SPRING_DATASOURCE_USERNAME: choerodon
  24. SPRING_REDIS_DATABASE: 9
  25. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  26. TEMPLATE_URL: https://github.com/choerodon/choerodon-devops-templates.git
  27. TEMPLATE_VERSION: 0.17.0
  28. ingress:
  29. enabled: true
  30. host: devops.example.choerodon.io
  31. preJob:
  32. preConfig:
  33. datasource:
  34. password: password
  35. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  36. username: choerodon
  37. preInitDB:
  38. datasource:
  39. password: password
  40. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/devops_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  41. username: choerodon
  42. service:
  43. enabled: true
  • 部署服务
  1. helm install c7n/devops-service \
  2. -f devops-service.yaml \
  3. --name devops-service \
  4. --version 0.19.2 \
  5. --namespace c7n-system
  • 验证部署

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

部署 gitlab service

  • 若需了解项目详情及各项参数含义,请移步 choerodon/gitlab-service
  • 如何获取 GITLAB_PRIVATETOKEN 请查看这里
  • 编写参数配置文件 gitlab-service.yaml
  1. env:
  2. open:
  3. EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://register-server.c7n-system:8000/eureka/
  4. GITLAB_PRIVATETOKEN: Gitlab 中获取的 private token
  5. GITLAB_URL: http://gitlab.example.choerodon.io
  6. SPRING_CLOUD_CONFIG_ENABLED: true
  7. SPRING_CLOUD_CONFIG_URI: http://register-server.c7n-system:8000/
  8. SPRING_DATASOURCE_PASSWORD: password
  9. SPRING_DATASOURCE_URL: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/gitlab_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  10. SPRING_DATASOURCE_USERNAME: choerodon
  11. preJob:
  12. preConfig:
  13. datasource:
  14. password: password
  15. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  16. username: choerodon
  17. preInitDB:
  18. datasource:
  19. password: password
  20. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/gitlab_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  21. username: choerodon
  • 部署服务
  1. helm install c7n/gitlab-service \
  2. -f gitlab-service.yaml \
  3. --name gitlab-service \
  4. --version 0.19.0 \
  5. --namespace c7n-system
  • 验证部署

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

部署 workflow service

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

  • 编写参数配置文件 workflow-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/workflow_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  8. SPRING_DATASOURCE_USERNAME: choerodon
  9. SPRING_REDIS_DATABASE: 10
  10. SPRING_REDIS_HOST: c7n-redis.c7n-system.svc
  11. preJob:
  12. preConfig:
  13. datasource:
  14. password: password
  15. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/manager_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  16. username: choerodon
  17. preInitDB:
  18. datasource:
  19. password: password
  20. url: jdbc:mysql://c7n-mysql.c7n-system.svc:3306/workflow_service?useUnicode=true&characterEncoding=utf-8&useSSL=false
  21. username: choerodon
  • 部署服务
  1. helm install c7n/workflow-service \
  2. -f workflow-service.yaml \
  3. --name workflow-service \
  4. --version 0.19.0 \
  5. --namespace c7n-system
  • 验证部署

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