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.

609 lines
15 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
8 years ago
  1. stages:
  2. - moderator
  3. - unit-tests
  4. - deploy-gce-part1
  5. - deploy-gce-part2
  6. - deploy-gce-special
  7. variables:
  8. FAILFASTCI_NAMESPACE: 'kargo-ci'
  9. # DOCKER_HOST: tcp://localhost:2375
  10. ANSIBLE_FORCE_COLOR: "true"
  11. # asia-east1-a
  12. # asia-northeast1-a
  13. # europe-west1-b
  14. # us-central1-a
  15. # us-east1-b
  16. # us-west1-a
  17. before_script:
  18. - pip install -r tests/requirements.txt
  19. - mkdir -p /.ssh
  20. .job: &job
  21. tags:
  22. - kubernetes
  23. - docker
  24. image: quay.io/ant31/kargo:master
  25. .docker_service: &docker_service
  26. services:
  27. - docker:dind
  28. .create_cluster: &create_cluster
  29. <<: *job
  30. <<: *docker_service
  31. .gce_variables: &gce_variables
  32. GCE_USER: travis
  33. SSH_USER: $GCE_USER
  34. TEST_ID: "$CI_PIPELINE_ID-$CI_BUILD_ID"
  35. CI_TEST_VARS: "./tests/files/${CI_JOB_NAME}.yml"
  36. CONTAINER_ENGINE: docker
  37. PRIVATE_KEY: $GCE_PRIVATE_KEY
  38. GS_ACCESS_KEY_ID: $GS_KEY
  39. GS_SECRET_ACCESS_KEY: $GS_SECRET
  40. CLOUD_MACHINE_TYPE: "g1-small"
  41. GCE_PREEMPTIBLE: "false"
  42. ANSIBLE_KEEP_REMOTE_FILES: "1"
  43. ANSIBLE_CONFIG: ./tests/ansible.cfg
  44. IDEMPOT_CHECK: "false"
  45. RESET_CHECK: "false"
  46. UPGRADE_TEST: "false"
  47. KUBEADM_ENABLED: "false"
  48. LOG_LEVEL: "-vv"
  49. MAGIC: "ci check this"
  50. .gce: &gce
  51. <<: *job
  52. <<: *docker_service
  53. cache:
  54. key: "$CI_BUILD_REF_NAME"
  55. paths:
  56. - downloads/
  57. - $HOME/.cache
  58. before_script:
  59. - docker info
  60. - pip install -r tests/requirements.txt
  61. - mkdir -p /.ssh
  62. - mkdir -p $HOME/.ssh
  63. - echo $PRIVATE_KEY | base64 -d > $HOME/.ssh/id_rsa
  64. - echo $GCE_PEM_FILE | base64 -d > $HOME/.ssh/gce
  65. - echo $GCE_CREDENTIALS > $HOME/.ssh/gce.json
  66. - chmod 400 $HOME/.ssh/id_rsa
  67. - ansible-playbook --version
  68. - export PYPATH=$([[ ! "$CI_JOB_NAME" =~ "coreos" ]] && echo /usr/bin/python || echo /opt/bin/python)
  69. - echo "CI_JOB_NAME is $CI_JOB_NAME"
  70. - echo "PYPATH is $PYPATH"
  71. script:
  72. - pwd
  73. - ls
  74. - echo ${PWD}
  75. - echo "${STARTUP_SCRIPT}"
  76. - >
  77. ansible-playbook tests/cloud_playbooks/create-gce.yml -i tests/local_inventory/hosts.cfg -c local
  78. ${LOG_LEVEL}
  79. -e gce_credentials_file=${HOME}/.ssh/gce.json
  80. -e gce_project_id=${GCE_PROJECT_ID}
  81. -e gce_service_account_email=${GCE_ACCOUNT}
  82. -e inventory_path=${PWD}/inventory/inventory.ini
  83. -e test_id=${TEST_ID}
  84. -e preemptible=$GCE_PREEMPTIBLE
  85. # Check out latest tag if testing upgrade
  86. # Uncomment when gitlab kargo repo has tags
  87. #- test "${UPGRADE_TEST}" != "false" && git fetch --all && git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
  88. - test "${UPGRADE_TEST}" != "false" && git checkout 72ae7638bcc94c66afa8620dfa4ad9a9249327ea
  89. # Checkout the CI vars file so it is available
  90. - test "${UPGRADE_TEST}" != "false" && git checkout "${CI_BUILD_REF}" tests/files/${CI_JOB_NAME}.yml
  91. # Create cluster
  92. - >
  93. ansible-playbook
  94. -i inventory/inventory.ini
  95. -b --become-user=root
  96. --private-key=${HOME}/.ssh/id_rsa
  97. -u $SSH_USER
  98. ${SSH_ARGS}
  99. ${LOG_LEVEL}
  100. -e @${CI_TEST_VARS}
  101. -e ansible_python_interpreter=${PYPATH}
  102. -e ansible_ssh_user=${SSH_USER}
  103. -e local_release_dir=${PWD}/downloads
  104. --limit "all:!fake_hosts"
  105. cluster.yml
  106. # Repeat deployment if testing upgrade
  107. - >
  108. if [ "${UPGRADE_TEST}" != "false" ]; then
  109. test "${UPGRADE_TEST}" == "basic" && PLAYBOOK="cluster.yml";
  110. test "${UPGRADE_TEST}" == "graceful" && PLAYBOOK="upgrade-cluster.yml";
  111. git checkout "${CI_BUILD_REF}";
  112. ansible-playbook
  113. -i inventory/inventory.ini
  114. -b --become-user=root
  115. --private-key=${HOME}/.ssh/id_rsa
  116. -u $SSH_USER
  117. ${SSH_ARGS}
  118. ${LOG_LEVEL}
  119. -e @${CI_TEST_VARS}
  120. -e ansible_python_interpreter=${PYPATH}
  121. -e ansible_ssh_user=${SSH_USER}
  122. -e local_release_dir=${PWD}/downloads
  123. --limit "all:!fake_hosts"
  124. $PLAYBOOK;
  125. fi
  126. # Tests Cases
  127. ## Test Master API
  128. - >
  129. 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 --limit "all:!fake_hosts" tests/testcases/010_check-apiserver.yml $LOG_LEVEL
  130. -e "{kubeadm_enabled: ${KUBEADM_ENABLED}}"
  131. ## Ping the between 2 pod
  132. - 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 --limit "all:!fake_hosts" tests/testcases/030_check-network.yml $LOG_LEVEL
  133. ## Advanced DNS checks
  134. - 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 --limit "all:!fake_hosts" tests/testcases/040_check-network-adv.yml $LOG_LEVEL
  135. ## Idempotency checks 1/5 (repeat deployment)
  136. - >
  137. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  138. ansible-playbook
  139. -i inventory/inventory.ini
  140. -b --become-user=root
  141. --private-key=${HOME}/.ssh/id_rsa
  142. -u $SSH_USER
  143. ${SSH_ARGS}
  144. ${LOG_LEVEL}
  145. -e @${CI_TEST_VARS}
  146. -e ansible_python_interpreter=${PYPATH}
  147. -e local_release_dir=${PWD}/downloads
  148. --limit "all:!fake_hosts"
  149. cluster.yml;
  150. fi
  151. ## Idempotency checks 2/5 (Advanced DNS checks)
  152. - >
  153. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  154. ansible-playbook
  155. -i inventory/inventory.ini
  156. -b --become-user=root
  157. --private-key=${HOME}/.ssh/id_rsa
  158. -u $SSH_USER
  159. ${SSH_ARGS}
  160. ${LOG_LEVEL}
  161. -e @${CI_TEST_VARS}
  162. --limit "all:!fake_hosts"
  163. tests/testcases/040_check-network-adv.yml $LOG_LEVEL;
  164. fi
  165. ## Idempotency checks 3/5 (reset deployment)
  166. - >
  167. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  168. ansible-playbook
  169. -i inventory/inventory.ini
  170. -b --become-user=root
  171. --private-key=${HOME}/.ssh/id_rsa
  172. -u $SSH_USER
  173. ${SSH_ARGS}
  174. ${LOG_LEVEL}
  175. -e @${CI_TEST_VARS}
  176. -e ansible_python_interpreter=${PYPATH}
  177. -e reset_confirmation=yes
  178. --limit "all:!fake_hosts"
  179. reset.yml;
  180. fi
  181. ## Idempotency checks 4/5 (redeploy after reset)
  182. - >
  183. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  184. ansible-playbook
  185. -i inventory/inventory.ini
  186. -b --become-user=root
  187. --private-key=${HOME}/.ssh/id_rsa
  188. -u $SSH_USER
  189. ${SSH_ARGS}
  190. ${LOG_LEVEL}
  191. -e @${CI_TEST_VARS}
  192. -e ansible_python_interpreter=${PYPATH}
  193. -e local_release_dir=${PWD}/downloads
  194. --limit "all:!fake_hosts"
  195. cluster.yml;
  196. fi
  197. ## Idempotency checks 5/5 (Advanced DNS checks)
  198. - >
  199. if [ "${IDEMPOT_CHECK}" = "true" -a "${RESET_CHECK}" = "true" ]; then
  200. ansible-playbook -i inventory/inventory.ini -e ansible_python_interpreter=${PYPATH}
  201. -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root
  202. --limit "all:!fake_hosts"
  203. tests/testcases/040_check-network-adv.yml $LOG_LEVEL;
  204. fi
  205. after_script:
  206. - >
  207. ansible-playbook -i inventory/inventory.ini tests/cloud_playbooks/delete-gce.yml -c local $LOG_LEVEL
  208. -e @${CI_TEST_VARS}
  209. -e test_id=${TEST_ID}
  210. -e gce_project_id=${GCE_PROJECT_ID}
  211. -e gce_service_account_email=${GCE_ACCOUNT}
  212. -e gce_credentials_file=${HOME}/.ssh/gce.json
  213. -e inventory_path=${PWD}/inventory/inventory.ini
  214. # Test matrix. Leave the comments for markup scripts.
  215. .coreos_calico_aio_variables: &coreos_calico_aio_variables
  216. # stage: deploy-gce-part1
  217. MOVED_TO_GROUP_VARS: "true"
  218. .ubuntu_canal_ha_variables: &ubuntu_canal_ha_variables
  219. # stage: deploy-gce-part1
  220. UPGRADE_TEST: "graceful"
  221. .centos_weave_kubeadm_variables: &centos_weave_kubeadm_variables
  222. # stage: deploy-gce-part1
  223. UPGRADE_TEST: "graceful"
  224. .ubuntu_canal_kubeadm_variables: &ubuntu_canal_kubeadm_variables
  225. # stage: deploy-gce-part1
  226. MOVED_TO_GROUP_VARS: "true"
  227. .rhel7_weave_variables: &rhel7_weave_variables
  228. # stage: deploy-gce-part1
  229. MOVED_TO_GROUP_VARS: "true"
  230. .centos7_flannel_addons_variables: &centos7_flannel_addons_variables
  231. # stage: deploy-gce-part2
  232. MOVED_TO_GROUP_VARS: "true"
  233. .debian8_calico_variables: &debian8_calico_variables
  234. # stage: deploy-gce-part2
  235. MOVED_TO_GROUP_VARS: "true"
  236. .coreos_canal_variables: &coreos_canal_variables
  237. # stage: deploy-gce-part2
  238. MOVED_TO_GROUP_VARS: "true"
  239. .rhel7_canal_sep_variables: &rhel7_canal_sep_variables
  240. # stage: deploy-gce-special
  241. MOVED_TO_GROUP_VARS: "true"
  242. .ubuntu_weave_sep_variables: &ubuntu_weave_sep_variables
  243. # stage: deploy-gce-special
  244. MOVED_TO_GROUP_VARS: "true"
  245. .centos7_calico_ha_variables: &centos7_calico_ha_variables
  246. # stage: deploy-gce-special
  247. MOVED_TO_GROUP_VARS: "true"
  248. .coreos_alpha_weave_ha_variables: &coreos_alpha_weave_ha_variables
  249. # stage: deploy-gce-special
  250. MOVED_TO_GROUP_VARS: "true"
  251. .ubuntu_rkt_sep_variables: &ubuntu_rkt_sep_variables
  252. # stage: deploy-gce-part1
  253. MOVED_TO_GROUP_VARS: "true"
  254. .ubuntu_vault_sep_variables: &ubuntu_vault_sep_variables
  255. # stage: deploy-gce-part1
  256. MOVED_TO_GROUP_VARS: "true"
  257. .ubuntu_flannel_variables: &ubuntu_flannel_variables
  258. # stage: deploy-gce-special
  259. MOVED_TO_GROUP_VARS: "true"
  260. # Builds for PRs only (premoderated by unit-tests step) and triggers (auto)
  261. coreos-calico-aio:
  262. stage: deploy-gce-part1
  263. <<: *job
  264. <<: *gce
  265. variables:
  266. <<: *gce_variables
  267. <<: *coreos_calico_aio_variables
  268. when: on_success
  269. except: ['triggers']
  270. only: [/^pr-.*$/]
  271. coreos-calico-sep-triggers:
  272. stage: deploy-gce-part1
  273. <<: *job
  274. <<: *gce
  275. variables:
  276. <<: *gce_variables
  277. <<: *coreos_calico_aio_variables
  278. when: on_success
  279. only: ['triggers']
  280. centos7-flannel-addons:
  281. stage: deploy-gce-part2
  282. <<: *job
  283. <<: *gce
  284. variables:
  285. <<: *gce_variables
  286. <<: *centos7_flannel_addons_variables
  287. when: on_success
  288. except: ['triggers']
  289. only: [/^pr-.*$/]
  290. centos7-flannel-addons-triggers:
  291. stage: deploy-gce-part1
  292. <<: *job
  293. <<: *gce
  294. variables:
  295. <<: *gce_variables
  296. <<: *centos7_flannel_addons_variables
  297. when: on_success
  298. only: ['triggers']
  299. ubuntu-weave-sep:
  300. stage: deploy-gce-special
  301. <<: *job
  302. <<: *gce
  303. variables:
  304. <<: *gce_variables
  305. <<: *ubuntu_weave_sep_variables
  306. when: on_success
  307. except: ['triggers']
  308. only: [/^pr-.*$/]
  309. ubuntu-weave-sep-triggers:
  310. stage: deploy-gce-part1
  311. <<: *job
  312. <<: *gce
  313. variables:
  314. <<: *gce_variables
  315. <<: *ubuntu_weave_sep_variables
  316. when: on_success
  317. only: ['triggers']
  318. # More builds for PRs/merges (manual) and triggers (auto)
  319. ubuntu-canal-ha:
  320. stage: deploy-gce-part1
  321. <<: *job
  322. <<: *gce
  323. variables:
  324. <<: *gce_variables
  325. <<: *ubuntu_canal_ha_variables
  326. when: manual
  327. except: ['triggers']
  328. only: ['master', /^pr-.*$/]
  329. ubuntu-canal-ha-triggers:
  330. stage: deploy-gce-part1
  331. <<: *job
  332. <<: *gce
  333. variables:
  334. <<: *gce_variables
  335. <<: *ubuntu_canal_ha_variables
  336. when: on_success
  337. only: ['triggers']
  338. ubuntu-canal-kubeadm:
  339. stage: deploy-gce-part1
  340. <<: *job
  341. <<: *gce
  342. variables:
  343. <<: *gce_variables
  344. <<: *ubuntu_canal_kubeadm_variables
  345. when: manual
  346. except: ['triggers']
  347. only: ['master', /^pr-.*$/]
  348. ubuntu-canal-kubeadm-triggers:
  349. stage: deploy-gce-part1
  350. <<: *job
  351. <<: *gce
  352. variables:
  353. <<: *gce_variables
  354. <<: *ubuntu_canal_kubeadm_variables
  355. when: on_success
  356. only: ['triggers']
  357. centos-weave-kubeadm:
  358. stage: deploy-gce-part1
  359. <<: *job
  360. <<: *gce
  361. variables:
  362. <<: *gce_variables
  363. <<: *centos_weave_kubeadm_variables
  364. when: manual
  365. except: ['triggers']
  366. only: ['master', /^pr-.*$/]
  367. centos-weave-kubeadm-triggers:
  368. stage: deploy-gce-part1
  369. <<: *job
  370. <<: *gce
  371. variables:
  372. <<: *gce_variables
  373. <<: *centos_weave_kubeadm_variables
  374. when: on_success
  375. only: ['triggers']
  376. rhel7-weave:
  377. stage: deploy-gce-part1
  378. <<: *job
  379. <<: *gce
  380. variables:
  381. <<: *gce_variables
  382. <<: *rhel7_weave_variables
  383. when: manual
  384. except: ['triggers']
  385. only: ['master', /^pr-.*$/]
  386. rhel7-weave-triggers:
  387. stage: deploy-gce-part1
  388. <<: *job
  389. <<: *gce
  390. variables:
  391. <<: *gce_variables
  392. <<: *rhel7_weave_variables
  393. when: on_success
  394. only: ['triggers']
  395. debian8-calico-upgrade:
  396. stage: deploy-gce-part2
  397. <<: *job
  398. <<: *gce
  399. variables:
  400. <<: *gce_variables
  401. <<: *debian8_calico_variables
  402. when: manual
  403. except: ['triggers']
  404. only: ['master', /^pr-.*$/]
  405. debian8-calico-triggers:
  406. stage: deploy-gce-part1
  407. <<: *job
  408. <<: *gce
  409. variables:
  410. <<: *gce_variables
  411. <<: *debian8_calico_variables
  412. when: on_success
  413. only: ['triggers']
  414. coreos-canal:
  415. stage: deploy-gce-part2
  416. <<: *job
  417. <<: *gce
  418. variables:
  419. <<: *gce_variables
  420. <<: *coreos_canal_variables
  421. when: manual
  422. except: ['triggers']
  423. only: ['master', /^pr-.*$/]
  424. coreos-canal-triggers:
  425. stage: deploy-gce-part1
  426. <<: *job
  427. <<: *gce
  428. variables:
  429. <<: *gce_variables
  430. <<: *coreos_canal_variables
  431. when: on_success
  432. only: ['triggers']
  433. rhel7-canal-sep:
  434. stage: deploy-gce-special
  435. <<: *job
  436. <<: *gce
  437. variables:
  438. <<: *gce_variables
  439. <<: *rhel7_canal_sep_variables
  440. when: manual
  441. except: ['triggers']
  442. only: ['master', /^pr-.*$/,]
  443. rhel7-canal-sep-triggers:
  444. stage: deploy-gce-part1
  445. <<: *job
  446. <<: *gce
  447. variables:
  448. <<: *gce_variables
  449. <<: *rhel7_canal_sep_variables
  450. when: on_success
  451. only: ['triggers']
  452. centos7-calico-ha:
  453. stage: deploy-gce-special
  454. <<: *job
  455. <<: *gce
  456. variables:
  457. <<: *gce_variables
  458. <<: *centos7_calico_ha_variables
  459. when: manual
  460. except: ['triggers']
  461. only: ['master', /^pr-.*$/]
  462. centos7-calico-ha-triggers:
  463. stage: deploy-gce-part1
  464. <<: *job
  465. <<: *gce
  466. variables:
  467. <<: *gce_variables
  468. <<: *centos7_calico_ha_variables
  469. when: on_success
  470. only: ['triggers']
  471. # no triggers yet https://github.com/kubernetes-incubator/kargo/issues/613
  472. coreos-alpha-weave-ha:
  473. stage: deploy-gce-special
  474. <<: *job
  475. <<: *gce
  476. variables:
  477. <<: *gce_variables
  478. <<: *coreos_alpha_weave_ha_variables
  479. when: manual
  480. except: ['triggers']
  481. only: ['master', /^pr-.*$/]
  482. ubuntu-rkt-sep:
  483. stage: deploy-gce-part1
  484. <<: *job
  485. <<: *gce
  486. variables:
  487. <<: *gce_variables
  488. <<: *ubuntu_rkt_sep_variables
  489. when: manual
  490. except: ['triggers']
  491. only: ['master', /^pr-.*$/]
  492. ubuntu-vault-sep:
  493. stage: deploy-gce-part1
  494. <<: *job
  495. <<: *gce
  496. variables:
  497. <<: *gce_variables
  498. <<: *ubuntu_vault_sep_variables
  499. when: manual
  500. except: ['triggers']
  501. only: ['master', /^pr-.*$/]
  502. ubuntu-flannel-sep:
  503. stage: deploy-gce-special
  504. <<: *job
  505. <<: *gce
  506. variables:
  507. <<: *gce_variables
  508. <<: *ubuntu_flannel_variables
  509. when: manual
  510. except: ['triggers']
  511. only: ['master', /^pr-.*$/]
  512. # Premoderated with manual actions
  513. ci-authorized:
  514. <<: *job
  515. stage: moderator
  516. before_script:
  517. - apt-get -y install jq
  518. script:
  519. - /bin/sh scripts/premoderator.sh
  520. except: ['triggers', 'master']
  521. syntax-check:
  522. <<: *job
  523. stage: unit-tests
  524. script:
  525. - ansible-playbook -i inventory/local-tests.cfg -u root -e ansible_ssh_user=root -b --become-user=root cluster.yml -vvv --syntax-check
  526. - ansible-playbook -i inventory/local-tests.cfg -u root -e ansible_ssh_user=root -b --become-user=root upgrade-cluster.yml -vvv --syntax-check
  527. - ansible-playbook -i inventory/local-tests.cfg -u root -e ansible_ssh_user=root -b --become-user=root reset.yml -vvv --syntax-check
  528. - ansible-playbook -i inventory/local-tests.cfg -u root -e ansible_ssh_user=root -b --become-user=root extra_playbooks/upgrade-only-k8s.yml -vvv --syntax-check
  529. except: ['triggers', 'master']
  530. yamllint:
  531. <<: *job
  532. stage: unit-tests
  533. script:
  534. - yamllint roles
  535. except: ['triggers', 'master']
  536. tox-inventory-builder:
  537. stage: unit-tests
  538. <<: *job
  539. script:
  540. - pip install tox
  541. - cd contrib/inventory_builder && tox
  542. when: manual
  543. except: ['triggers', 'master']