You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
6.6 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. stages:
  2. - unit-tests
  3. - deploy-gce-part1
  4. - deploy-gce-part2
  5. - deploy-gce-special
  6. variables:
  7. FAILFASTCI_NAMESPACE: 'kargo-ci'
  8. # DOCKER_HOST: tcp://localhost:2375
  9. ANSIBLE_FORCE_COLOR: "true"
  10. # asia-east1-a
  11. # asia-northeast1-a
  12. # europe-west1-b
  13. # us-central1-a
  14. # us-east1-b
  15. # us-west1-a
  16. before_script:
  17. - pip install ansible
  18. - pip install netaddr
  19. - pip install apache-libcloud==0.20.1
  20. - pip install boto==2.9.0
  21. - mkdir -p /.ssh
  22. - cp tests/ansible.cfg .
  23. .job: &job
  24. tags:
  25. - kubernetes
  26. - docker
  27. image: quay.io/ant31/kargo:master
  28. .docker_service: &docker_service
  29. services:
  30. - docker:dind
  31. .create_cluster: &create_cluster
  32. <<: *job
  33. <<: *docker_service
  34. .gce_variables: &gce_variables
  35. GCE_USER: travis
  36. SSH_USER: $GCE_USER
  37. TEST_ID: "$CI_PIPELINE_ID-$CI_BUILD_ID"
  38. CONTAINER_ENGINE: docker
  39. PRIVATE_KEY: $GCE_PRIVATE_KEY
  40. GS_ACCESS_KEY_ID: $GS_KEY
  41. GS_SECRET_ACCESS_KEY: $GS_SECRET
  42. ANSIBLE_KEEP_REMOTE_FILES: "1"
  43. CLUSTER_MODE: default
  44. BOOTSTRAP_OS: none
  45. LOG_LEVEL: "-vv"
  46. .gce: &gce
  47. <<: *job
  48. <<: *docker_service
  49. cache:
  50. key: "$CI_BUILD_REF_NAME"
  51. paths:
  52. - downloads/
  53. - $HOME/.cache
  54. stage: deploy-gce
  55. before_script:
  56. - docker info
  57. - pip install ansible==2.1.3.0
  58. - pip install netaddr
  59. - pip install apache-libcloud==0.20.1
  60. - pip install boto==2.9.0
  61. - mkdir -p /.ssh
  62. - cp tests/ansible.cfg .
  63. - mkdir -p $HOME/.ssh
  64. - echo $PRIVATE_KEY | base64 -d > $HOME/.ssh/id_rsa
  65. - echo $GCE_PEM_FILE | base64 -d > $HOME/.ssh/gce
  66. - echo $GCE_CREDENTIALS > $HOME/.ssh/gce.json
  67. - chmod 400 $HOME/.ssh/id_rsa
  68. - ansible-playbook --version
  69. - cp tests/ansible.cfg .
  70. - export PYPATH=$([ $BOOTSTRAP_OS = none ] && echo /usr/bin/python || echo /opt/bin/python)
  71. script:
  72. - pwd
  73. - ls
  74. - echo ${PWD}
  75. - >
  76. ansible-playbook tests/cloud_playbooks/create-gce.yml -i tests/local_inventory/hosts.cfg -c local $LOG_LEVEL
  77. -e mode=${CLUSTER_MODE}
  78. -e test_id=${TEST_ID}
  79. -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  80. -e gce_project_id=${GCE_PROJECT_ID}
  81. -e gce_service_account_email=${GCE_ACCOUNT}
  82. -e gce_credentials_file=${HOME}/.ssh/gce.json
  83. -e cloud_image=${CLOUD_IMAGE}
  84. -e inventory_path=${PWD}/inventory/inventory.ini
  85. -e cloud_region=${CLOUD_REGION}
  86. # Create cluster
  87. - >
  88. ansible-playbook -i inventory/inventory.ini -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS
  89. -b --become-user=root -e cloud_provider=gce $LOG_LEVEL -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  90. --private-key=${HOME}/.ssh/id_rsa
  91. -e bootstrap_os=${BOOTSTRAP_OS}
  92. -e ansible_python_interpreter=${PYPATH}
  93. -e download_run_once=true
  94. -e download_localhost=true
  95. -e deploy_netchecker=true
  96. -e local_release_dir=${PWD}/downloads
  97. cluster.yml
  98. # Tests Cases
  99. ## Test Master API
  100. - ansible-playbook -i inventory/inventory.ini -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root tests/testcases/010_check-apiserver.yml $LOG_LEVEL
  101. ## Ping the between 2 pod
  102. - ansible-playbook -i inventory/inventory.ini -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root tests/testcases/030_check-network.yml $LOG_LEVEL
  103. ## Advanced DNS checks
  104. - ansible-playbook -i inventory/inventory.ini -e ansible_python_interpreter=${PYPATH} -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root tests/testcases/040_check-network-adv.yml $LOG_LEVEL
  105. after_script:
  106. - >
  107. ansible-playbook -i inventory/inventory.ini tests/cloud_playbooks/delete-gce.yml -c local $LOG_LEVEL
  108. -e mode=${CLUSTER_MODE}
  109. -e test_id=${TEST_ID}
  110. -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  111. -e gce_project_id=${GCE_PROJECT_ID}
  112. -e gce_service_account_email=${GCE_ACCOUNT}
  113. -e gce_credentials_file=${HOME}/.ssh/gce.json
  114. -e cloud_image=${CLOUD_IMAGE}
  115. -e inventory_path=${PWD}/inventory/inventory.ini
  116. -e cloud_region=${CLOUD_REGION}
  117. coreos-calico-sep:
  118. stage: deploy-gce-part1
  119. <<: *job
  120. <<: *gce
  121. variables:
  122. <<: *gce_variables
  123. KUBE_NETWORK_PLUGIN: calico
  124. CLOUD_IMAGE: coreos-stable
  125. CLOUD_REGION: us-west1-b
  126. CLUSTER_MODE: separated
  127. BOOTSTRAP_OS: coreos
  128. when: on_success
  129. only: [/^pr-.*$/]
  130. debian8-canal-ha:
  131. stage: deploy-gce-part1
  132. <<: *job
  133. <<: *gce
  134. variables:
  135. <<: *gce_variables
  136. KUBE_NETWORK_PLUGIN: canal
  137. CLOUD_IMAGE: debian-8-kubespray
  138. CLOUD_REGION: us-east1-b
  139. CLUSTER_MODE: ha
  140. when: manual
  141. only: ['master', /^pr-.*$/]
  142. rhel7-weave:
  143. stage: deploy-gce-part1
  144. <<: *job
  145. <<: *gce
  146. variables:
  147. <<: *gce_variables
  148. KUBE_NETWORK_PLUGIN: weave
  149. CLOUD_IMAGE: rhel-7
  150. CLOUD_REGION: europe-west1-b
  151. CLUSTER_MODE: default
  152. when: manual
  153. only: ['master', /^pr-.*$/]
  154. centos7-flannel:
  155. stage: deploy-gce-part2
  156. <<: *job
  157. <<: *gce
  158. variables:
  159. <<: *gce_variables
  160. KUBE_NETWORK_PLUGIN: flannel
  161. CLOUD_IMAGE: centos-7
  162. CLOUD_REGION: us-west1-a
  163. CLUSTER_MODE: default
  164. when: on_success
  165. only: [/^pr-.*$/]
  166. debian8-calico:
  167. stage: deploy-gce-part2
  168. <<: *job
  169. <<: *gce
  170. variables:
  171. <<: *gce_variables
  172. KUBE_NETWORK_PLUGIN: calico
  173. CLOUD_IMAGE: debian-8-kubespray
  174. CLOUD_REGION: us-central1-b
  175. CLUSTER_MODE: default
  176. when: manual
  177. only: ['master', /^pr-.*$/]
  178. coreos-canal:
  179. stage: deploy-gce-part2
  180. <<: *job
  181. <<: *gce
  182. variables:
  183. <<: *gce_variables
  184. KUBE_NETWORK_PLUGIN: canal
  185. CLOUD_IMAGE: coreos-stable
  186. CLOUD_REGION: us-east1-b
  187. CLUSTER_MODE: default
  188. BOOTSTRAP_OS: coreos
  189. when: manual
  190. only: ['master', /^pr-.*$/]
  191. rhel7-canal-sep:
  192. stage: deploy-gce-special
  193. <<: *job
  194. <<: *gce
  195. variables:
  196. <<: *gce_variables
  197. KUBE_NETWORK_PLUGIN: canal
  198. CLOUD_IMAGE: rhel-7
  199. CLOUD_REGION: us-east1-b
  200. CLUSTER_MODE: separated
  201. when: manual
  202. only: ['master', /^pr-.*$/]
  203. ubuntu-weave-sep:
  204. stage: deploy-gce-special
  205. <<: *job
  206. <<: *gce
  207. variables:
  208. <<: *gce_variables
  209. KUBE_NETWORK_PLUGIN: weave
  210. CLOUD_IMAGE: ubuntu-1604-xenial
  211. CLOUD_REGION: us-central1-b
  212. CLUSTER_MODE: separated
  213. when: on_success
  214. only: [/^pr-.*$/]
  215. centos7-calico-ha:
  216. stage: deploy-gce-special
  217. <<: *job
  218. <<: *gce
  219. variables:
  220. <<: *gce_variables
  221. KUBE_NETWORK_PLUGIN: calico
  222. CLOUD_IMAGE: centos-7
  223. CLOUD_REGION: europe-west1-b
  224. CLUSTER_MODE: ha
  225. when: manual
  226. only: ['master', /^pr-.*$/]
  227. syntax-check:
  228. <<: *job
  229. stage: unit-tests
  230. script:
  231. - ansible-playbook -i inventory/local-tests.cfg -u root -e ansible_ssh_user=root -b --become-user=root cluster.yml -vvv --syntax-check