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.

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