Spinnaker 生产环境安装部署监控

开发 前端
本片给大家介绍Spinnaker 生产环境安装部署监控

[[347032]]

1. 架构分析

2.准备工作

2.1 启动Halyard容器

2.2 下载所需要的镜像

2.3 准备bom文件

3.Halyard配置管理

3.1.Halyard初始化配置

3.2 添加镜像仓库(harbor)和k8s集群账户

3.3 开启特性功能

3.4 配置JenkinsCI集成

3.5 配置GitHub/GitLab集成

4. 使用外部Redis集群

5. 使用SQL数据库

5.1 Clouddriver服务

5.2 Front50服务

5.3 Orca服务

6.部署

7. 其他设置

7.1 认证与授权

7.2 邮件通知

7.3 金丝雀分析

7.4 监控Spinnaker

1. 架构分析

Halyard + Kubernetes + Redis + MySQL57 + S3

redis: Gate、Orca、Clouddrive、Rosco、Igor、Fiat、Kayenta

S3:Front50 、Kayenta

数据持久化

  • Orca 、Clouddriver 默认安装使用redis存储数据,转换为使用SQL数据库存储。
  • Front50 默认安装使用s3持久化存储,转换为使用SQL数据库存储。
  • 使用k8s外部redis集群。

2.准备工作

  • 包含6个节点的redis集群(3主+3从)。
  • MySQL 5.7数据库。
  • 部署Minio用于S3存储。
  • 下载Halyard容器镜像。
  • 下载Spinnaker集群所需的容器镜像(阿里云)。
  • 下载BOM自定义安装所需的文件。

2.1 启动Halyard容器

 

也可以使用二进制安装。最好将halyard运行在一台配置好kubectl客户端的节点上。因为后续需要用到k8s集群账户信息。

  1. docker pull registry.cn-beijing.aliyuncs.com/spinnaker-cd/halyard:1.32.0 
  2. mkdir /root/.hal 
  3. docker run -itd --name halyard \ 
  4.   -v /root/.hal:/home/spinnaker/.hal \ 
  5.   -v /root/.kube:/home/spinnaker/.kube \ 
  6.   registry.cn-beijing.aliyuncs.com/spinnaker-cd/halyard:1.32.0 
  7.   
  8. ## 以root身份进入容器,修改配置文件 
  9. docker exec -it -u root halyard bash 
  10.   
  11. ## 修改spinnaker.config.input.gcs.enabled = false 。 
  12. vi /opt/halyard/config/halyard.yml 
  13.   
  14. spinnaker: 
  15.   artifacts: 
  16.     debian: https://dl.bintray.com/spinnaker-releases/debians 
  17.     docker: gcr.io/spinnaker-marketplace 
  18.   config: 
  19.     input: 
  20.       gcs: 
  21.         enabled: false 
  22.       writerEnabled: false 
  23.       bucket: halconfig 
  24.   
  25. ## 需要重启容器(如果此命令未重启,则需要退出容器然后 docker restart halyard) 
  26. hal shutdown 
  27.  
  28.  
  29. ## 启动 
  30.  
  31. docker start halyard 

2.2 下载所需要的镜像

 

所有的镜像已经通过GitHub Actions自动同步到阿里云镜像仓库。大家直接下载。registry.cn-beijing.aliyuncs.com/spinnaker-cd/ 为了方便可以直接运行脚本下载当前版本的所有镜像。

bom文件和下载镜像的脚本都在这个压缩包中,下载https://github.com/zeyangli/spinnaker-cd-install/actions

  1. # 上传到服务器(运行halyard容器的节点) 
  2. scp 1.22.1-Image-Script.zip root@master.zy.com:/root 
  3.  
  4. unzip 1.22.1-Image-Script.zip 
  5. cd 1.22.1 
  6. [root@master 1.22.1]# ls -a 
  7. .  ..  .boms  GetImages.sh  tagfile.txt 
  8.  
  9. ## .boms需要放到.hal目录下 
  10. ## GetImages.sh 镜像下载脚本 
  11. ## tagfile.txt 镜像标签 
  12.  
  13. sh -x GetImages.sh   
  14. chmod 777 -R .hal/ 
  15.  
  16. ## 等待镜像下载完成(这个脚本中做了ssh免密哦) 

tagfile.txt

  1. ## tagfile 
  2. [root@master 1.22.1]# cat tagfile.txt 
  3. echo:2.14.0-20200817170018 
  4. clouddriver:6.11.0-20200818115831 
  5. deck:3.3.0-20200818132306 
  6. fiat:1.13.0-20200817170018 
  7. front50:0.25.1-20200831095512 
  8. gate:1.18.1-20200825122721 
  9. igor:1.12.0-20200817200018 
  10. kayenta:0.17.0-20200817170018 
  11. orca:2.16.0-20200817170018 
  12. rosco:0.21.1-20200827112228 

GetImages.sh

  1. ## script 
  2. #!/bin/bash 
  3.  
  4. S_REGISTRY="gcr.io/spinnaker-marketplace" 
  5. T_REGISTRY="registry.cn-beijing.aliyuncs.com/spinnaker-cd" 
  6. NODES="node01.zy.com node02.zy.com" 
  7.  
  8. ## 下载镜像 
  9. function GetImages(){ 
  10.     echo -e "\033[43;34m =====GetImg===== \033[0m" 
  11.  
  12.     IMAGES=$( cat tagfile.txt) 
  13.  
  14.     for image in ${IMAGES} 
  15.     do 
  16.         for node in ${NODES} 
  17.         do 
  18.            echo  -e "\033[32m ${node} ---> pull ---> ${image} \033[0m" 
  19.            ssh ${node} "docker pull ${T_REGISTRY}/${image}" 
  20.            echo  -e "\033[32m ${node} ---> tag ---> ${image} \033[0m" 
  21.            ssh ${node} "docker tag ${T_REGISTRY}/${image} ${S_REGISTRY}/${image}" 
  22.         done 
  23.     done 
  24.     for node in ${NODES} 
  25.     do 
  26.        echo -e "\033[43;34m =====${node}===镜像信息===== \033[0m" 
  27.        ssh ${node} "docker images | grep 'spinnaker-marketplace' " 
  28.     done 
  29.  
  30.  
  31. GetImages 

2.3 准备bom文件

  1. [root@master 1.22.1]# mv .boms/ ~/.hal/ 
  2. [root@master 1.22.1]# cd ~/.hal/ 
  3. [root@master .hal]# cd .boms/ 
  4. [root@master .boms]# ls 
  5. bom  clouddriver  deck  echo  fiat  front50  gate  igor  kayenta  orca  rosco 
  6. [root@master .boms]# tree 
  7. ├── bom 
  8. │   ├── 1.19.4.yml 
  9. │   └── 1.22.1.yml 
  10. ├── clouddriver 
  11. │   ├── 6.11.0-20200818115831 
  12. │   │   └── clouddriver.yml 
  13. │   ├── 6.7.3-20200401190525 
  14. │   │   └── clouddriver.yml 
  15. │   └── clouddriver.yml 
  16. ├── deck 
  17. │   ├── 3.0.2-20200324040016 
  18. │   │   └── settings.js 
  19. │   ├── 3.3.0-20200818132306 
  20. │   │   └── settings.js 
  21. │   └── settings.js 
  22. ├── echo 
  23. │   ├── 2.11.2-20200401121252 
  24. │   │   └── echo.yml 
  25. │   ├── 2.14.0-20200817170018 
  26. │   │   └── echo.yml 
  27. │   └── echo.yml 
  28. ├── fiat 
  29. │   ├── 1.10.1-20200401121252 
  30. │   │   └── fiat.yml 
  31. │   ├── 1.13.0-20200817170018 
  32. │   │   └── fiat.yml 
  33. │   └── fiat.yml 
  34. ├── front50 
  35. │   ├── 0.22.1-20200401121252 
  36. │   │   └── front50.yml 
  37. │   ├── 0.25.1-20200831095512 
  38. │   │   └── front50.yml 
  39. │   └── front50.yml 
  40. ├── gate 
  41. │   ├── 1.15.1-20200403040016 
  42. │   │   └── gate.yml 
  43. │   ├── 1.18.1-20200825122721 
  44. │   │   └── gate.yml 
  45. │   └── gate.yml 
  46. ├── igor 
  47. │   ├── 1.12.0-20200817200018 
  48. │   │   └── igor.yml 
  49. │   ├── 1.9.2-20200401121252 
  50. │   │   └── igor.yml 
  51. │   └── igor.yml 
  52. ├── kayenta 
  53. │   ├── 0.14.0-20200304112817 
  54. │   │   └── kayenta.yml 
  55. │   ├── 0.17.0-20200817170018 
  56. │   │   └── kayenta.yml 
  57. │   └── kayenta.yml 
  58. ├── orca 
  59. │   ├── 2.13.2-20200401144746 
  60. │   │   └── orca.yml 
  61. │   ├── 2.16.0-20200817170018 
  62. │   │   └── orca.yml 
  63. │   └── orca.yml 
  64. └── rosco 
  65.     ├── 0.18.1-20200401121252 
  66.     │   ├── images.yml 
  67.     │   ├── packer 
  68.     │   │   ├── alicloud.json 
  69.     │   │   ├── alicloud-multi.json 
  70.     │   │   ├── aws-chroot.json 
  71.     │   │   ├── aws-ebs.json 
  72.     │   │   ├── aws-multi-chroot.json 
  73.     │   │   ├── aws-multi-ebs.json 
  74.     │   │   ├── aws-windows-2012-r2.json 
  75.     │   │   ├── azure-linux.json 
  76.     │   │   ├── azure-windows-2012-r2.json 
  77.     │   │   ├── docker.json 
  78.     │   │   ├── gce.json 
  79.     │   │   ├── huaweicloud.json 
  80.     │   │   ├── install_packages.sh 
  81.     │   │   ├── oci.json 
  82.     │   │   └── scripts 
  83.     │   │       ├── aws-windows-2012-configure-ec2service.ps1 
  84.     │   │       ├── aws-windows.userdata 
  85.     │   │       ├── windows-configure-chocolatey.ps1 
  86.     │   │       └── windows-install-packages.ps1 
  87.     │   └── rosco.yml 
  88.     ├── 0.21.1-20200827112228 
  89.     │   ├── images.yml 
  90.     │   ├── packer 
  91.     │   │   ├── alicloud.json 
  92.     │   │   ├── alicloud-multi.json 
  93.     │   │   ├── aws-chroot.json 
  94.     │   │   ├── aws-ebs.json 
  95.     │   │   ├── aws-multi-chroot.json 
  96.     │   │   ├── aws-multi-ebs.json 
  97.     │   │   ├── aws-windows-2012-r2.json 
  98.     │   │   ├── azure-linux.json 
  99.     │   │   ├── azure-windows-2012-r2.json 
  100.     │   │   ├── docker.json 
  101.     │   │   ├── gce.json 
  102.     │   │   ├── huaweicloud.json 
  103.     │   │   ├── install_packages.sh 
  104.     │   │   ├── oci.json 
  105.     │   │   └── scripts 
  106.     │   │       ├── aws-windows-2012-configure-ec2service.ps1 
  107.     │   │       ├── aws-windows.userdata 
  108.     │   │       ├── windows-configure-chocolatey.ps1 
  109.     │   │       └── windows-install-packages.ps1 
  110.     │   ├── README.md 
  111.     │   └── rosco.yml 
  112.     ├── images.yml 
  113.     ├── packer 
  114.     │   ├── alicloud.json 
  115.     │   ├── alicloud-multi.json 
  116.     │   ├── aws-chroot.json 
  117.     │   ├── aws-ebs.json 
  118.     │   ├── aws-multi-chroot.json 
  119.     │   ├── aws-multi-ebs.json 
  120.     │   ├── aws-windows-2012-r2.json 
  121.     │   ├── azure-linux.json 
  122.     │   ├── azure-windows-2012-r2.json 
  123.     │   ├── docker.json 
  124.     │   ├── gce.json 
  125.     │   ├── huaweicloud.json 
  126.     │   ├── install_packages.sh 
  127.     │   ├── oci.json 
  128.     │   └── scripts 
  129.     │       ├── aws-windows-2012-configure-ec2service.ps1 
  130.     │       ├── aws-windows.userdata 
  131.     │       ├── windows-configure-chocolatey.ps1 
  132.     │       └── windows-install-packages.ps1 
  133.     ├── README.md 
  134.     └── rosco.yml 
  135.  
  136. 37 directories, 91 files 

3.Halyard配置管理
docker exec -it halyard bash

  • Halyard初始化配置
  • 添加镜像仓库(Harbor)和K8s集群账户
  • 开启特性功能(pipeline-templates、artifacts、managed-pipeline-templates-v2-ui)
  • 配置JenkinsCI集成
  • 配置GitHub/GitLab集成

3.1.Halyard初始化配置

  1. # 设置Spinnaker版本,--version 指定版本 
  2. hal config version edit --version local:1.22.1 
  3.  
  4. # 设置时区 
  5. hal config edit --timezone Asia/Shanghai 
  6.  
  7. # 设置存储为s3(后面不用,但是必须配置bug) 
  8. hal config storage edit --type s3  --no-validate 
  9.      
  10. # 访问方式:设置deck与gate的域名 
  11. hal config security ui edit --override-base-url http://spinnaker.idevops.site 
  12. hal config security api edit --override-base-url http://spin-gate.idevops.site 

3.2 添加镜像仓库(harbor)和k8s集群账户

  1. hal config provider docker-registry enable --no-validate 
  2. hal config provider docker-registry account add my-harbor-registry \ 
  3.     --address http://192.168.1.200:8088 \ 
  4.     --username admin \ 
  5.     --password Harbor12345 
  6.  
  7. hal config provider kubernetes enable 
  8. hal config provider kubernetes account add default \ 
  9.     --docker-registries my-harbor-registry \ 
  10.     --context $(kubectl config current-context) \ 
  11.     --service-account true \ 
  12.     --omit-namespaces=kube-system,kube-public \ 
  13.     --provider-version v2 \ 
  14.     --no-validate 
  15.      
  16. # 部署方式,分布式部署,名称空间。 
  17. hal config deploy edit \ 
  18.     --account-name default \ 
  19.     --type distributed \ 
  20.     --location spinnaker  

3.3 开启特性功能

  1. ## 开启一些主要的功能(后期可以再追加) 
  2. hal config features edit --pipeline-templates true 
  3. hal config features edit --artifacts true 
  4. hal config features edit --managed-pipeline-templates-v2-ui true   

3.4 配置JenkinsCI集成

  1. # 配置Jenkins 
  2. hal config ci jenkins enable 
  3. ### JenkinsServer 需要用到账号和密码 
  4. hal config ci jenkins master add my-jenkins-master-01 \ 
  5.     --address http://jenkins.idevops.site \ 
  6.     --username admin \ 
  7.     --password admin 
  8. ### 启用csrf 
  9. hal config ci jenkins master edit my-jenkins-master-01 --csrf true 

3.5 配置GitHub/GitLab集成

  1. # GitHub 
  2. ## 参考:https://spinnaker.io/setup/artifacts/github/ 
  3. ## 创建token https://github.com/settings/tokens 
  4.  
  5. hal config artifact github enable 
  6.  
  7. hal config artifact github account add my-github-account \ 
  8.     --token 02eb8aa1c2cd67af305d1f606  \ 
  9.     --username zey 
  10.  
  11. # GitLab 
  12. ## https://spinnaker.io/setup/artifacts/gitlab/ 
  13. ## 创建一个个人的token(admin) 
  14. hal config artifact gitlab enable 
  15. hal config artifact gitlab account add my-gitlab-account \ 
  16.     --token qqHX8T4VTpozbnX 

4. 使用外部Redis集群

  1. ## service-settings 
  2. mkdir .hal/default/service-settings/ 
  3. vi .hal/default/service-settings/redis.yml 
  4.  
  5. overrideBaseUrl: redis://192.168.1.200:6379 
  6. skipLifeCycleManagement: true 
  7.  
  8.  
  9. ## profiles 
  10. ## /root/.hal/default/profiles 
  11. [root@master profiles]# ls 
  12. [root@master profiles]# vi gate-local.yml 
  13. redis: 
  14.     configuration: 
  15.          secure: 
  16.               true 

5. 使用SQL数据库
5.1 Clouddriver服务
创建数据库

  1. CREATE DATABASE `clouddriver` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 
  2.  
  3. GRANT 
  4.   SELECTINSERTUPDATEDELETECREATEEXECUTE, SHOW VIEW 
  5. ON `clouddriver`.* 
  6. TO 'clouddriver_service'@'%' IDENTIFIED BY 'clouddriver@spinnaker.com'
  7.  
  8.  
  9. GRANT 
  10.   SELECTINSERTUPDATEDELETECREATEDROPREFERENCESINDEXALTER, LOCK TABLES, EXECUTE, SHOW VIEW 
  11. ON `clouddriver`.* 
  12. TO 'clouddriver_migrate'@'%' IDENTIFIED BY 'clouddriver@spinnaker.com'

修改配置文件

  1. ## /root/.hal/default/profiles 
  2. bash-5.0$ cat clouddriver-local.yml 
  3. sql: 
  4.   enabled: true 
  5.   # read-only boolean toggles `SELECTor `DELETE` health checks for all pools. 
  6.   # Especially relevant for clouddriver-ro and clouddriver-ro-deck which can 
  7.   # target a SQL read replica in their default pools. 
  8.   read-onlyfalse 
  9.   taskRepository: 
  10.     enabled: true 
  11.   cache: 
  12.     enabled: true 
  13.     # These parameters were determined to be optimal via benchmark comparisons 
  14.     # in the Netflix production environment with Aurora. Setting these too low 
  15.     # or high may negatively impact performance. These values may be sub-optimal 
  16.     # in some environments. 
  17.     readBatchSize: 500 
  18.     writeBatchSize: 300 
  19.   scheduler: 
  20.     enabled: true 
  21.  
  22.   # Enable clouddriver-caching's clean up agent to periodically purge old 
  23.   # clusters and accounts. Set to true when using the Kubernetes provider. 
  24.   unknown-agent-cleanup-agent: 
  25.     enabled: false 
  26.  
  27.   connectionPools: 
  28.     default
  29.       # additional connection pool parameters are available here, 
  30.       # for more detail and to view defaults, see: 
  31.       # https://github.com/spinnaker/kork/blob/master/kork-sql/src/main/kotlin/com/netflix/spinnaker/kork/sql/config/ConnectionPoolProperties.kt 
  32.       defaulttrue 
  33.       jdbcUrl: jdbc:mysql://192.168.1.200:3306/clouddriver 
  34.       user: clouddriver_service 
  35.       password: clouddriver@spinnaker.com 
  36.     # The following tasks connection pool is optional. At Netflix, clouddriver 
  37.     # instances pointed to Aurora read replicas have a tasks pool pointed at the 
  38.     # master. Instances where the default pool is pointed to the master omit a 
  39.     # separate tasks pool. 
  40.     tasks: 
  41.       user: clouddriver_service 
  42.       jdbcUrl: jdbc:mysql://192.168.1.200:3306/clouddriver 
  43.       password: clouddriver@spinnaker.com 
  44.   migration: 
  45.     user: clouddriver_migrate 
  46.     jdbcUrl: jdbc:mysql://192.168.1.200:3306/clouddriver 
  47.     password: clouddriver@spinnaker.com 
  48.  
  49. redis: 
  50.   enabled: false 
  51.   cache: 
  52.     enabled: false 
  53.   scheduler: 
  54.     enabled: false 
  55.   taskRepository: 
  56.     enabled: false 

5.2 Front50服务
创建数据库

  1. CREATE DATABASE `front50` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 
  2.  
  3. GRANT SELECTINSERTUPDATEDELETECREATEEXECUTE, SHOW VIEW ON `front50`.*  TO 'front50_service'@'%' IDENTIFIED BY "front50@spinnaker.com"
  4.  
  5. GRANT SELECTINSERTUPDATEDELETECREATEDROPREFERENCESINDEXALTER, LOCK TABLES, EXECUTE, SHOW VIEW ON `front50`.* TO 'front50_migrate'@'%' IDENTIFIED BY "front50@spinnaker.com"

修改配置文件

  1. ## /root/.hal/default/profiles 
  2. bash-5.0$ cat front50-local.yml 
  3. spinnaker: 
  4.   s3: 
  5.     enabled: false 
  6. sql: 
  7.   enabled: true 
  8.   connectionPools: 
  9.     default
  10.       # additional connection pool parameters are available here, 
  11.       # for more detail and to view defaults, see: 
  12.       # https://github.com/spinnaker/kork/blob/master/kork-sql/src/main/kotlin/com/netflix/spinnaker/kork/sql/config/ConnectionPoolProperties.kt 
  13.       defaulttrue 
  14.       jdbcUrl: jdbc:mysql://192.168.1.200:3306/front50 
  15.       user: front50_service 
  16.       password: front50@spinnaker.com 
  17.   migration: 
  18.     user: front50_migrate 
  19.     jdbcUrl: jdbc:mysql://192.168.1.200:3306/front50 
  20.     password: front50@spinnaker.com 

5.3 Orca服务
创建数据库

  1. set tx_isolation = 'REPEATABLE-READ'
  2.  
  3. CREATE SCHEMA `orca` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 
  4.  
  5. GRANT  
  6. SELECTINSERTUPDATEDELETECREATEEXECUTE, SHOW VIEW 
  7. ON `orca`.*  
  8. TO 'orca_service'@'%' IDENTIFIED BY "orca@spinnaker.com" ; 
  9.  
  10. GRANT  
  11. SELECTINSERTUPDATEDELETECREATEDROPREFERENCESINDEXALTER, LOCK TABLES, EXECUTE, SHOW VIEW  
  12. ON `orca`.*  
  13. TO 'orca_migrate'@'%'  IDENTIFIED BY "orca@spinnaker.com" ; 

修改配置文件

  1. ## /root/.hal/default/profiles 
  2. bash-5.0$ cat orca-local.yml 
  3. sql: 
  4.   enabled: true 
  5.   connectionPool: 
  6.     jdbcUrl: jdbc:mysql://192.168.1.200:3306/orca 
  7.     user: orca_service 
  8.     password: orca@spinnaker.com 
  9.     connectionTimeout: 5000 
  10.     maxLifetime: 30000 
  11.     # MariaDB-specific: 
  12.     maxPoolSize: 50 
  13.   migration: 
  14.     jdbcUrl: jdbc:mysql://192.168.1.200:3306/orca 
  15.     user: orca_migrate 
  16.     password: orca@spinnaker.com 
  17.  
  18. # Ensure we're only using SQL for accessing execution state 
  19. executionRepository: 
  20.   sql: 
  21.     enabled: true 
  22.   redis: 
  23.     enabled: false 
  24.  
  25. # Reporting on active execution metrics will be handled by SQL 
  26. monitor: 
  27.   activeExecutions: 
  28.     redis: false 
  29.  
  30. # Use SQL for Orca's work queue 
  31. # Settings from Netflix and may require adjustment for your environment 
  32. Only validated with AWS Aurora MySQL 5.7 
  33. # Please PR if you have success with other databases 
  34. keiko: 
  35.   queue: 
  36.     sql: 
  37.       enabled: true 
  38.     redis: 
  39.       enabled: false 
  40.  
  41. queue: 
  42.   zombieCheck: 
  43.     enabled: true 
  44.   pendingExecutionService: 
  45.     sql: 
  46.       enabled: true 
  47.     redis: 
  48.       enabled: false 

6.部署

  1. hal deploy apply --no-validate 

创建Ingress访问

  1. apiVersion: extensions/v1beta1 
  2. kind: Ingress 
  3. metadata: 
  4.   name: spinnaker-service 
  5.   annotations: 
  6.     kubernetes.io/ingress.class: nginx 
  7. spec: 
  8.   rules: 
  9.   - host: spinnaker.idevops.site 
  10.     http: 
  11.      paths: 
  12.      - path: / 
  13.        backend: 
  14.           serviceName: spin-deck 
  15.           servicePort: 9000 
  16.   - host: spin-gate.idevops.site 
  17.     http: 
  18.       paths: 
  19.       - path: / 
  20.         backend: 
  21.           serviceName: spin-gate 
  22.           servicePort: 8084 
  23.   - host: spin-front50.idevops.site 
  24.     http: 
  25.       paths: 
  26.       - path: / 
  27.         backend: 
  28.           serviceName: spin-front50 
  29.           servicePort: 8080 
  30.   - host: spin-fiat.idevops.site 
  31.     http: 
  32.       paths: 
  33.       - path: / 
  34.         backend: 
  35.           serviceName: spin-fiat 
  36.           servicePort: 7003 

  1. kubectl create -f ingress.yml 

7. 其他设置
7.1 认证与授权
认证:LDAP、Oauth2
授权:LDAP、File
开启认证LDAP/OAuth2(两者二选一即可,推荐LDAP)

  1. # 开启LDAP认证 
  2. hal config security authn ldap edit \ 
  3.     --user-search-base 'ou=devops,dc=zy,dc=com' \ 
  4.     --url 'ldap://192.168.1.200:389' \ 
  5.     --user-search-filter 'cn={0}' \ 
  6.     --manager-dn 'cn=admin,dc=zy,dc=com' \ 
  7.     --manager-password '12345678' 
  8.   
  9. hal config security authn ldap enable 
  10.  
  11. ## --user-search-base  用户搜索的部分 
  12. ## --url    LDAP服务器 
  13. ## --user-search-filter  搜索用户DN时使用的过滤器 
  14. ## --manager-dn   LDAP管理器用户 
  15. ## --manager-password  LDAP管理器用户的密码 
  16.  
  17. # GitHub 
  18. ## 首先需要登录GitHub然后创建一个OAuth APP。 
  19. ## 参考官方:https://spinnaker.io/setup/security/authentication/oauth/github/ 
  20.  
  21. hal config security authn oauth2 edit --provider github \ 
  22.   --client-id 66826xxxxxxxxe0ecdbd7 \ 
  23.   --client-secret d834851134e80a9xxxxxxe371613f05bc26 
  24.  
  25. hal config security authn oauth2 enable 

授权管理

角色可以通过LDAP自定义也可以使用文件自定义。两者二选一。

通过LDAP组定义角色:例如我在LDAP中存在类型为groupOfUniqueName的组yunweizu。则关联这个组的所有用户的角色为yunweizu。后续添加权限则根据yunweizu授权。

通过文件自定义:编写一个静态的yaml文件,里面定义每个用户和其对应的角色。

  1. # 使用Yaml文件 
  2. ##如下配置设置user1为yunweizu、user2为demo。 
  3. users: 
  4.   - username: devops 
  5.     roles: 
  6.     - yunweizu 
  7.   - username: user2 
  8.     roles: 
  9.     - demo 
  10.      
  11. hal config security authz enable  
  12. hal config security authz file edit --file-path=$HOME/.hal/userrole.yaml  
  13. hal config security authz edit --type file 
  14.  
  15.  
  16. ## 授权(根据LDAP组进行授权) 
  17. hal config security authz ldap edit \ 
  18.     --url 'ldap://192.168.1.200:389/dc=zy,dc=com' \ 
  19.     --manager-dn 'cn=admin,dc=zy,dc=com' \ 
  20.     --manager-password '12345678' \ 
  21.     --user-dn-pattern 'cn={0}' \ 
  22.     --group-search-base 'ou=devops' \ 
  23.     --group-search-filter 'uniqueMember={0}' \ 
  24.     --group-role-attributes 'cn' \ 
  25.     --user-search-filter 'cn={0}’  
  26.          
  27.  hal config security authz edit --type ldap 
  28.  hal config security authz enable 

开启授权后可以设置哪些用户可以访问集群账户、镜像仓库、应用程序。

  1. ## 配置yunweizu和group02角色的用户可以使用default这个集群账户 
  2. hal config provider kubernetes account edit default \ 
  3. --add-read-permission yunweizu,group02  \ 
  4. --add-write-permission yunweizu 
  5.    
  6. ## 配置yunweizu角色的用户可以使用my-harbor-registry账户 
  7. hal config provider docker-registry account edit my-harbor-registry \ 
  8.     --read-permissions yunweizu \ 
  9.     --write-permissions yunweizu 

开启管道权限

  1. ~/.hal/default/profiles/orca-local.yml 
  2. tasks:  
  3.   useManagedServiceAccounts: true 
  4.  
  5. ~/.hal/default/profiles/settings-local.js 
  6. window.spinnakerSettings.feature.managedServiceAccounts = true

定义超级管理员

  1. vi ~/.hal/default/profiles/fiat-local.yml 
  2.  
  3. bash-5.0$ cat fiat-local.yml 
  4. fiat: 
  5.   admin: 
  6.     roles: 
  7.       - devops-admin   ## 指定的组 

7.2 邮件通知
.hal/default/profiles/echo-local.yml

  1. [root@master profiles]# cat echo-local.yml 
  2. mail: 
  3.   enabled: true 
  4.   from: 250642@qq.com 
  5. spring: 
  6.   mail: 
  7.     host: smtp.qq.com 
  8.     username: 25642@qq.com 
  9.     password: ubxijwaah 
  10.     protocol: smtp 
  11.     default-encoding: utf-8 
  12.     properties: 
  13.       mail: 
  14.         display: 
  15.           sendname: SpinnakerAdmin 
  16.         smtp: 
  17.           port: 465 
  18.           auth: true 
  19.           starttls: 
  20.             enable: true 
  21.             required: true 
  22.           ssl: 
  23.             enable: true 
  24.         transport: 
  25.           protocol: smtp 
  26.         debug: true 

.hal/default/profiles/settings-local.js

  1. window.spinnakerSettings.notifications.email.enabled = true

更新配置

  1. hal deploy apply --no-validate 

7.3 金丝雀分析
配置存储

  1. hal config canary enable  
  2.  
  3. ##aws s3  minio 创建一个bucket spinnaker-canary,赋予读写权限。 
  4. hal config canary aws enable 
  5. hal config canary aws account add my-canary  \ 
  6. --bucket spinnaker-canary \ 
  7. --endpoint http://minio.idevops.site \ 
  8. --access-key-id AKIAIOSFODNN7EXAMPLE \ 
  9. --secret-access-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY  
  10.  
  11. hal config canary edit --default-storage-account my-canary 
  12. hal config canary aws edit --s3-enabled true 

Prometheus集成

  1. ## prometheus 
  2. hal config canary prometheus enable 
  3.  
  4. ## 这里做了basic认证,无认证忽略username和password选项。 
  5. hal config canary prometheus account add my-prometheus \ 
  6. --base-url http://prometheus.idevops.site \ 
  7. --username admin \ 
  8. --password admin  
  9.  
  10. hal config canary edit --default-metrics-account my-prometheus 
  11. hal config canary edit --default-metrics-store prometheus 

  1. hal deploy apply --no-validate 

效果

7.4 监控Spinnaker

  1. hal config metric-stores prometheus enable 
  2. hal deploy apply --no-validate 
  3.  
  4. [root@master monitor]# kubectl get pod -n spinnaker 
  5. NAME                               READY   STATUS    RESTARTS   AGE 
  6. spin-clouddriver-7cd94f5b9-cn22r   2/2     Running   2          4h4m 
  7. spin-deck-684854fbd7-cb7wh         1/1     Running   1          4h4m 
  8. spin-echo-746b45ff98-kcz5m         2/2     Running   2          4h4m 
  9. spin-front50-66b4f9966-l6r4h       2/2     Running   2          4h4m 
  10. spin-gate-6788588dfc-q8cpt         2/2     Running   2          4h4m 
  11. spin-igor-6f6fbbbb75-4b4jd         2/2     Running   2          4h4m 
  12. spin-kayenta-64fddf7db9-j4pqg      2/2     Running   2          4h4m 
  13. spin-orca-d5c488b48-5q8sp          2/2     Running   2          4h4m 
  14. spin-rosco-5f4bcb754c-9kgl9        2/2     Running   2          4h4m 
  15.  
  16. # 通过describe可以看到POD中存在一个sidecar容器monitoring-daemon 
  17. kubectl describe pod spin-gate-6788588dfc-q8cpt -n spinnaker 
  18.      

正常运行后通过 podID:8008/prometheus_metrics获取度量数据,需要添加以下服务发现配置。

  1. # prometheus需要添加配置 
  2. - job_name: 'spinnaker-services' 
  3.   kubernetes_sd_configs: 
  4.   - role: pod 
  5.   metrics_path: "/prometheus_metrics" 
  6.   relabel_configs: 
  7.   - source_labels: [__meta_kubernetes_pod_label_app] 
  8.     action: keep 
  9.     regex: 'spin' 
  10.   - source_labels: [__meta_kubernetes_pod_container_name] 
  11.     action: keep 
  12.     regex: 'monitoring-daemon' 
  13.      
  14.      
  15. ## prometheus-operator 按照以下配置,其他方式忽略以下配置。 
  16. apiVersion: monitoring.coreos.com/v1 
  17. kind: ServiceMonitor 
  18. metadata: 
  19.   name: spinnaker-all-metrics 
  20.   labels: 
  21.     app: spin 
  22.     # this label is here to match the prometheus operator serviceMonitorSelector attribute 
  23.     # prometheus.prometheusSpec.serviceMonitorSelector 
  24.     # https://github.com/helm/charts/tree/master/stable/prometheus-operator 
  25.     release: prometheus-operator 
  26. spec: 
  27.   selector: 
  28.     matchLabels: 
  29.       app: spin 
  30.     namespaceSelector: 
  31.       anytrue 
  32.   endpoints: 
  33.   # "port" is string only"targetPort" is integer or string. 
  34.   - targetPort: 8008 
  35.     interval: 10s 
  36.     path: "/prometheus_metrics" 

打开prometheus页面,能够看到以下信息。

对接Grafana展示数据,Spinnaker官方提供了控制台模板。https://github.com/spinnaker/spinnaker-monitoring/tree/master/spinnaker-monitoring-third-party/third_party/prometheus

打开Grafana控制台,开始导入json模板。模板较多,创建一个文件夹管理。

 

 

 

责任编辑:姜华 来源: 今日头条
相关推荐

2019-08-08 08:00:00

深度学习机器学习神经网络

2013-09-30 09:40:37

VDI部署VDI

2020-10-17 09:48:55

Spinnaker实践

2020-11-26 08:46:52

Spinnaker

2020-11-10 08:00:00

机器学习技术科学

2022-02-09 15:44:20

RocketMQLinux系统

2012-02-07 09:56:06

无代理防毒产品

2021-09-29 07:47:49

Sentry 监控Environment事件数据

2022-09-01 08:50:22

kubernetes容器

2014-04-03 16:36:46

Ubuntu ServCacti服务器监控

2018-02-11 09:00:00

软件部署监控

2021-07-16 05:00:13

Environment开发生产

2017-09-30 08:55:14

AWSMongoDBGUI工具

2015-06-24 10:33:47

2022-09-04 21:17:03

高可用Linkerd

2019-07-07 08:02:05

AI人工智能智能监控

2011-03-29 13:25:10

Zabbix监控

2020-11-12 08:00:00

数据中心IT技术

2011-09-19 10:43:19

Nuget
点赞
收藏

51CTO技术栈公众号