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.

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