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.

455 lines
11 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 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. BOOTSTRAP_OS: none
  44. RESOLVCONF_MODE: docker_dns
  45. LOG_LEVEL: "-vv"
  46. ETCD_DEPLOYMENT: "docker"
  47. KUBELET_DEPLOYMENT: "docker"
  48. MAGIC: "ci check this"
  49. .gce: &gce
  50. <<: *job
  51. <<: *docker_service
  52. cache:
  53. key: "$CI_BUILD_REF_NAME"
  54. paths:
  55. - downloads/
  56. - $HOME/.cache
  57. stage: deploy-gce
  58. before_script:
  59. - docker info
  60. - pip install ansible==2.1.3.0
  61. - pip install netaddr
  62. - pip install apache-libcloud==0.20.1
  63. - pip install boto==2.9.0
  64. - mkdir -p /.ssh
  65. - cp tests/ansible.cfg .
  66. - mkdir -p $HOME/.ssh
  67. - echo $PRIVATE_KEY | base64 -d > $HOME/.ssh/id_rsa
  68. - echo $GCE_PEM_FILE | base64 -d > $HOME/.ssh/gce
  69. - echo $GCE_CREDENTIALS > $HOME/.ssh/gce.json
  70. - chmod 400 $HOME/.ssh/id_rsa
  71. - ansible-playbook --version
  72. - cp tests/ansible.cfg .
  73. - export PYPATH=$([ $BOOTSTRAP_OS = none ] && echo /usr/bin/python || echo /opt/bin/python)
  74. script:
  75. - pwd
  76. - ls
  77. - echo ${PWD}
  78. - >
  79. ansible-playbook tests/cloud_playbooks/create-gce.yml -i tests/local_inventory/hosts.cfg -c local $LOG_LEVEL
  80. -e mode=${CLUSTER_MODE}
  81. -e test_id=${TEST_ID}
  82. -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  83. -e gce_project_id=${GCE_PROJECT_ID}
  84. -e gce_service_account_email=${GCE_ACCOUNT}
  85. -e gce_credentials_file=${HOME}/.ssh/gce.json
  86. -e cloud_image=${CLOUD_IMAGE}
  87. -e inventory_path=${PWD}/inventory/inventory.ini
  88. -e cloud_region=${CLOUD_REGION}
  89. # Create cluster
  90. - >
  91. ansible-playbook -i inventory/inventory.ini -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS
  92. -b --become-user=root -e cloud_provider=gce $LOG_LEVEL -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  93. --private-key=${HOME}/.ssh/id_rsa
  94. -e bootstrap_os=${BOOTSTRAP_OS}
  95. -e ansible_python_interpreter=${PYPATH}
  96. -e download_run_once=true
  97. -e download_localhost=true
  98. -e deploy_netchecker=true
  99. -e resolvconf_mode=${RESOLVCONF_MODE}
  100. -e local_release_dir=${PWD}/downloads
  101. -e etcd_deployment_type=${ETCD_DEPLOYMENT}
  102. -e kubelet_deployment_type=${KUBELET_DEPLOYMENT}
  103. cluster.yml
  104. # Tests Cases
  105. ## Test Master API
  106. - 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
  107. ## Ping the between 2 pod
  108. - 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
  109. ## Advanced DNS checks
  110. - 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
  111. after_script:
  112. - >
  113. ansible-playbook -i inventory/inventory.ini tests/cloud_playbooks/delete-gce.yml -c local $LOG_LEVEL
  114. -e mode=${CLUSTER_MODE}
  115. -e test_id=${TEST_ID}
  116. -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  117. -e gce_project_id=${GCE_PROJECT_ID}
  118. -e gce_service_account_email=${GCE_ACCOUNT}
  119. -e gce_credentials_file=${HOME}/.ssh/gce.json
  120. -e cloud_image=${CLOUD_IMAGE}
  121. -e inventory_path=${PWD}/inventory/inventory.ini
  122. -e cloud_region=${CLOUD_REGION}
  123. # Test matrix. Leave the comments for markup scripts.
  124. .coreos_calico_sep_variables: &coreos_calico_sep_variables
  125. # stage: deploy-gce-part1
  126. KUBE_NETWORK_PLUGIN: calico
  127. CLOUD_IMAGE: coreos-stable
  128. CLOUD_REGION: us-west1-b
  129. CLUSTER_MODE: separated
  130. BOOTSTRAP_OS: coreos
  131. RESOLVCONF_MODE: host_resolvconf # This is required as long as the CoreOS stable channel uses docker < 1.12
  132. .debian8_canal_ha_variables: &debian8_canal_ha_variables
  133. # stage: deploy-gce-part1
  134. KUBE_NETWORK_PLUGIN: canal
  135. CLOUD_IMAGE: debian-8-kubespray
  136. CLOUD_REGION: us-east1-b
  137. CLUSTER_MODE: ha
  138. .rhel7_weave_variables: &rhel7_weave_variables
  139. # stage: deploy-gce-part1
  140. KUBE_NETWORK_PLUGIN: weave
  141. CLOUD_IMAGE: rhel-7
  142. CLOUD_REGION: europe-west1-b
  143. CLUSTER_MODE: default
  144. .centos7_flannel_variables: &centos7_flannel_variables
  145. # stage: deploy-gce-part2
  146. KUBE_NETWORK_PLUGIN: flannel
  147. CLOUD_IMAGE: centos-7
  148. CLOUD_REGION: us-west1-a
  149. CLUSTER_MODE: default
  150. .debian8_calico_variables: &debian8_calico_variables
  151. # stage: deploy-gce-part2
  152. KUBE_NETWORK_PLUGIN: calico
  153. CLOUD_IMAGE: debian-8-kubespray
  154. CLOUD_REGION: us-central1-b
  155. CLUSTER_MODE: default
  156. .coreos_canal_variables: &coreos_canal_variables
  157. # stage: deploy-gce-part2
  158. KUBE_NETWORK_PLUGIN: canal
  159. CLOUD_IMAGE: coreos-stable
  160. CLOUD_REGION: us-east1-b
  161. CLUSTER_MODE: default
  162. BOOTSTRAP_OS: coreos
  163. RESOLVCONF_MODE: host_resolvconf # This is required as long as the CoreOS stable channel uses docker < 1.12
  164. .rhel7_canal_sep_variables: &rhel7_canal_sep_variables
  165. # stage: deploy-gce-special
  166. KUBE_NETWORK_PLUGIN: canal
  167. CLOUD_IMAGE: rhel-7
  168. CLOUD_REGION: us-east1-b
  169. CLUSTER_MODE: separated
  170. .ubuntu_weave_sep_variables: &ubuntu_weave_sep_variables
  171. # stage: deploy-gce-special
  172. KUBE_NETWORK_PLUGIN: weave
  173. CLOUD_IMAGE: ubuntu-1604-xenial
  174. CLOUD_REGION: us-central1-b
  175. CLUSTER_MODE: separated
  176. .centos7_calico_ha_variables: &centos7_calico_ha_variables
  177. # stage: deploy-gce-special
  178. KUBE_NETWORK_PLUGIN: calico
  179. CLOUD_IMAGE: centos-7
  180. CLOUD_REGION: europe-west1-b
  181. CLUSTER_MODE: ha
  182. .coreos_alpha_weave_ha_variables: &coreos_alpha_weave_ha_variables
  183. # stage: deploy-gce-special
  184. KUBE_NETWORK_PLUGIN: weave
  185. CLOUD_IMAGE: coreos-alpha
  186. CLOUD_REGION: us-west1-a
  187. CLUSTER_MODE: ha
  188. BOOTSTRAP_OS: coreos
  189. .ubuntu_rkt_sep_variables: &ubuntu_rkt_sep_variables
  190. # stage: deploy-gce-part1
  191. KUBE_NETWORK_PLUGIN: flannel
  192. CLOUD_IMAGE: ubuntu-1604-xenial
  193. CLOUD_REGION: us-central1-b
  194. CLUSTER_MODE: separated
  195. ETCD_DEPLOYMENT: rkt
  196. KUBELET_DEPLOYMENT: rkt
  197. # Builds for PRs only (premoderated by unit-tests step) and triggers (auto)
  198. coreos-calico-sep:
  199. stage: deploy-gce-part1
  200. <<: *job
  201. <<: *gce
  202. variables:
  203. <<: *gce_variables
  204. <<: *coreos_calico_sep_variables
  205. when: on_success
  206. except: ['triggers']
  207. only: [/^pr-.*$/]
  208. coreos-calico-sep-triggers:
  209. stage: deploy-gce-part1
  210. <<: *job
  211. <<: *gce
  212. variables:
  213. <<: *gce_variables
  214. <<: *coreos_calico_sep_variables
  215. when: on_success
  216. only: ['triggers']
  217. centos7-flannel:
  218. stage: deploy-gce-part2
  219. <<: *job
  220. <<: *gce
  221. variables:
  222. <<: *gce_variables
  223. <<: *centos7_flannel_variables
  224. when: on_success
  225. except: ['triggers']
  226. only: [/^pr-.*$/]
  227. centos7-flannel-triggers:
  228. stage: deploy-gce-part1
  229. <<: *job
  230. <<: *gce
  231. variables:
  232. <<: *gce_variables
  233. <<: *centos7_flannel_variables
  234. when: on_success
  235. only: ['triggers']
  236. ubuntu-weave-sep:
  237. stage: deploy-gce-special
  238. <<: *job
  239. <<: *gce
  240. variables:
  241. <<: *gce_variables
  242. <<: *ubuntu_weave_sep_variables
  243. when: on_success
  244. except: ['triggers']
  245. only: [/^pr-.*$/]
  246. ubuntu-weave-sep-triggers:
  247. stage: deploy-gce-part1
  248. <<: *job
  249. <<: *gce
  250. variables:
  251. <<: *gce_variables
  252. <<: *ubuntu_weave_sep_variables
  253. when: on_success
  254. only: ['triggers']
  255. # More builds for PRs/merges (manual) and triggers (auto)
  256. debian8-canal-ha:
  257. stage: deploy-gce-part1
  258. <<: *job
  259. <<: *gce
  260. variables:
  261. <<: *gce_variables
  262. <<: *debian8_canal_ha_variables
  263. when: manual
  264. except: ['triggers']
  265. only: ['master', /^pr-.*$/]
  266. debian8-canal-ha-triggers:
  267. stage: deploy-gce-part1
  268. <<: *job
  269. <<: *gce
  270. variables:
  271. <<: *gce_variables
  272. <<: *debian8_canal_ha_variables
  273. when: on_success
  274. only: ['triggers']
  275. rhel7-weave:
  276. stage: deploy-gce-part1
  277. <<: *job
  278. <<: *gce
  279. variables:
  280. <<: *gce_variables
  281. <<: *rhel7_weave_variables
  282. when: manual
  283. except: ['triggers']
  284. only: ['master', /^pr-.*$/]
  285. rhel7-weave-triggers:
  286. stage: deploy-gce-part1
  287. <<: *job
  288. <<: *gce
  289. variables:
  290. <<: *gce_variables
  291. <<: *rhel7_weave_variables
  292. when: on_success
  293. only: ['triggers']
  294. debian8-calico:
  295. stage: deploy-gce-part2
  296. <<: *job
  297. <<: *gce
  298. variables:
  299. <<: *gce_variables
  300. <<: *debian8_calico_variables
  301. when: manual
  302. except: ['triggers']
  303. only: ['master', /^pr-.*$/]
  304. debian8-calico-triggers:
  305. stage: deploy-gce-part1
  306. <<: *job
  307. <<: *gce
  308. variables:
  309. <<: *gce_variables
  310. <<: *debian8_calico_variables
  311. when: on_success
  312. only: ['triggers']
  313. coreos-canal:
  314. stage: deploy-gce-part2
  315. <<: *job
  316. <<: *gce
  317. variables:
  318. <<: *gce_variables
  319. <<: *coreos_canal_variables
  320. when: manual
  321. except: ['triggers']
  322. only: ['master', /^pr-.*$/]
  323. coreos-canal-triggers:
  324. stage: deploy-gce-part1
  325. <<: *job
  326. <<: *gce
  327. variables:
  328. <<: *gce_variables
  329. <<: *coreos_canal_variables
  330. when: on_success
  331. only: ['triggers']
  332. rhel7-canal-sep:
  333. stage: deploy-gce-special
  334. <<: *job
  335. <<: *gce
  336. variables:
  337. <<: *gce_variables
  338. <<: *rhel7_canal_sep_variables
  339. when: manual
  340. except: ['triggers']
  341. only: ['master', /^pr-.*$/,]
  342. rhel7-canal-sep-triggers:
  343. stage: deploy-gce-part1
  344. <<: *job
  345. <<: *gce
  346. variables:
  347. <<: *gce_variables
  348. <<: *rhel7_canal_sep_variables
  349. when: on_success
  350. only: ['triggers']
  351. centos7-calico-ha:
  352. stage: deploy-gce-special
  353. <<: *job
  354. <<: *gce
  355. variables:
  356. <<: *gce_variables
  357. <<: *centos7_calico_ha_variables
  358. when: manual
  359. except: ['triggers']
  360. only: ['master', /^pr-.*$/]
  361. centos7-calico-ha-triggers:
  362. stage: deploy-gce-part1
  363. <<: *job
  364. <<: *gce
  365. variables:
  366. <<: *gce_variables
  367. <<: *centos7_calico_ha_variables
  368. when: on_success
  369. only: ['triggers']
  370. # no triggers yet https://github.com/kubernetes-incubator/kargo/issues/613
  371. coreos-alpha-weave-ha:
  372. stage: deploy-gce-special
  373. <<: *job
  374. <<: *gce
  375. variables:
  376. <<: *gce_variables
  377. <<: *coreos_alpha_weave_ha_variables
  378. when: manual
  379. except: ['triggers']
  380. only: ['master', /^pr-.*$/]
  381. ubuntu-rkt-sep:
  382. stage: deploy-gce-part1
  383. <<: *job
  384. <<: *gce
  385. variables:
  386. <<: *gce_variables
  387. <<: *ubuntu_rkt_sep_variables
  388. when: manual
  389. except: ['triggers']
  390. only: ['master', /^pr-.*$/]
  391. # Premoderated with manual actions
  392. syntax-check:
  393. <<: *job
  394. stage: unit-tests
  395. before_script:
  396. - apt-get -y install jq
  397. script:
  398. - ansible-playbook -i inventory/local-tests.cfg -u root -e ansible_ssh_user=root -b --become-user=root cluster.yml -vvv --syntax-check
  399. - /bin/sh scripts/premoderator.sh
  400. except: ['triggers', 'master']
  401. tox-inventory-builder:
  402. stage: unit-tests
  403. <<: *job
  404. script:
  405. - pip install tox
  406. - cd contrib/inventory_builder && tox
  407. when: manual
  408. except: ['triggers', 'master']