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.

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