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.

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