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.

589 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. -e reset_confirmation=yes
  182. reset.yml;
  183. fi
  184. ## Idempotency checks 4/5 (redeploy after reset)
  185. - >
  186. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  187. ansible-playbook -i inventory/inventory.ini -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS
  188. -b --become-user=root -e cloud_provider=gce $LOG_LEVEL -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  189. --private-key=${HOME}/.ssh/id_rsa
  190. -e bootstrap_os=${BOOTSTRAP_OS}
  191. -e ansible_python_interpreter=${PYPATH}
  192. -e download_run_once=true
  193. -e download_localhost=true
  194. -e deploy_netchecker=true
  195. -e resolvconf_mode=${RESOLVCONF_MODE}
  196. -e local_release_dir=${PWD}/downloads
  197. -e etcd_deployment_type=${ETCD_DEPLOYMENT}
  198. -e kubelet_deployment_type=${KUBELET_DEPLOYMENT}
  199. cluster.yml;
  200. fi
  201. ## Idempotency checks 5/5 (Advanced DNS checks)
  202. - >
  203. if [ "${IDEMPOT_CHECK}" = "true" ]; then
  204. ansible-playbook -i inventory/inventory.ini -e ansible_python_interpreter=${PYPATH}
  205. -u $SSH_USER -e ansible_ssh_user=$SSH_USER $SSH_ARGS -b --become-user=root
  206. tests/testcases/040_check-network-adv.yml $LOG_LEVEL;
  207. fi
  208. after_script:
  209. - >
  210. ansible-playbook -i inventory/inventory.ini tests/cloud_playbooks/delete-gce.yml -c local $LOG_LEVEL
  211. -e mode=${CLUSTER_MODE}
  212. -e test_id=${TEST_ID}
  213. -e kube_network_plugin=${KUBE_NETWORK_PLUGIN}
  214. -e gce_project_id=${GCE_PROJECT_ID}
  215. -e gce_service_account_email=${GCE_ACCOUNT}
  216. -e gce_credentials_file=${HOME}/.ssh/gce.json
  217. -e cloud_image=${CLOUD_IMAGE}
  218. -e inventory_path=${PWD}/inventory/inventory.ini
  219. -e cloud_region=${CLOUD_REGION}
  220. # Test matrix. Leave the comments for markup scripts.
  221. .coreos_calico_sep_variables: &coreos_calico_sep_variables
  222. # stage: deploy-gce-part1
  223. KUBE_NETWORK_PLUGIN: calico
  224. CLOUD_IMAGE: coreos-stable-1235-6-0-v20170111
  225. CLOUD_REGION: us-west1-b
  226. CLUSTER_MODE: separate
  227. BOOTSTRAP_OS: coreos
  228. RESOLVCONF_MODE: host_resolvconf # This is required as long as the CoreOS stable channel uses docker < 1.12
  229. .debian8_canal_ha_variables: &debian8_canal_ha_variables
  230. # stage: deploy-gce-part1
  231. KUBE_NETWORK_PLUGIN: canal
  232. CLOUD_IMAGE: debian-8-kubespray
  233. CLOUD_REGION: us-east1-b
  234. UPGRADE_TEST: "true"
  235. CLUSTER_MODE: ha
  236. .rhel7_weave_variables: &rhel7_weave_variables
  237. # stage: deploy-gce-part1
  238. KUBE_NETWORK_PLUGIN: weave
  239. CLOUD_IMAGE: rhel-7
  240. CLOUD_REGION: europe-west1-b
  241. UPGRADE_TEST: "true"
  242. CLUSTER_MODE: default
  243. .centos7_flannel_variables: &centos7_flannel_variables
  244. # stage: deploy-gce-part2
  245. KUBE_NETWORK_PLUGIN: flannel
  246. CLOUD_IMAGE: centos-7
  247. CLOUD_REGION: us-west1-a
  248. CLUSTER_MODE: default
  249. .debian8_calico_variables: &debian8_calico_variables
  250. # stage: deploy-gce-part2
  251. KUBE_NETWORK_PLUGIN: calico
  252. CLOUD_IMAGE: debian-8-kubespray
  253. CLOUD_REGION: us-central1-b
  254. CLUSTER_MODE: default
  255. .coreos_canal_variables: &coreos_canal_variables
  256. # stage: deploy-gce-part2
  257. KUBE_NETWORK_PLUGIN: canal
  258. CLOUD_IMAGE: coreos-stable-1235-6-0-v20170111
  259. CLOUD_REGION: us-east1-b
  260. CLUSTER_MODE: default
  261. BOOTSTRAP_OS: coreos
  262. RESOLVCONF_MODE: host_resolvconf # This is required as long as the CoreOS stable channel uses docker < 1.12
  263. IDEMPOT_CHECK: "true"
  264. .rhel7_canal_sep_variables: &rhel7_canal_sep_variables
  265. # stage: deploy-gce-special
  266. KUBE_NETWORK_PLUGIN: canal
  267. CLOUD_IMAGE: rhel-7
  268. CLOUD_REGION: us-east1-b
  269. CLUSTER_MODE: separate
  270. .ubuntu_weave_sep_variables: &ubuntu_weave_sep_variables
  271. # stage: deploy-gce-special
  272. KUBE_NETWORK_PLUGIN: weave
  273. CLOUD_IMAGE: ubuntu-1604-xenial
  274. CLOUD_REGION: us-central1-b
  275. CLUSTER_MODE: separate
  276. IDEMPOT_CHECK: "false"
  277. .centos7_calico_ha_variables: &centos7_calico_ha_variables
  278. # stage: deploy-gce-special
  279. KUBE_NETWORK_PLUGIN: calico
  280. CLOUD_IMAGE: centos-7
  281. CLOUD_REGION: europe-west1-b
  282. CLUSTER_MODE: ha
  283. IDEMPOT_CHECK: "true"
  284. .coreos_alpha_weave_ha_variables: &coreos_alpha_weave_ha_variables
  285. # stage: deploy-gce-special
  286. KUBE_NETWORK_PLUGIN: weave
  287. CLOUD_IMAGE: coreos-alpha
  288. CLOUD_REGION: us-west1-a
  289. CLUSTER_MODE: ha
  290. BOOTSTRAP_OS: coreos
  291. .ubuntu_rkt_sep_variables: &ubuntu_rkt_sep_variables
  292. # stage: deploy-gce-part1
  293. KUBE_NETWORK_PLUGIN: flannel
  294. CLOUD_IMAGE: ubuntu-1604-xenial
  295. CLOUD_REGION: us-central1-b
  296. CLUSTER_MODE: separate
  297. ETCD_DEPLOYMENT: rkt
  298. KUBELET_DEPLOYMENT: rkt
  299. .ubuntu_vault_sep_variables: &ubuntu_vault_sep_variables
  300. # stage: deploy-gce-part1
  301. KUBE_NETWORK_PLUGIN: canal
  302. CERT_MGMT: vault
  303. CLOUD_IMAGE: ubuntu-1604-xenial
  304. CLOUD_REGION: us-central1-b
  305. CLUSTER_MODE: separate
  306. # Builds for PRs only (premoderated by unit-tests step) and triggers (auto)
  307. coreos-calico-sep:
  308. stage: deploy-gce-part1
  309. <<: *job
  310. <<: *gce
  311. variables:
  312. <<: *gce_variables
  313. <<: *coreos_calico_sep_variables
  314. when: on_success
  315. except: ['triggers']
  316. only: [/^pr-.*$/]
  317. coreos-calico-sep-triggers:
  318. stage: deploy-gce-part1
  319. <<: *job
  320. <<: *gce
  321. variables:
  322. <<: *gce_variables
  323. <<: *coreos_calico_sep_variables
  324. when: on_success
  325. only: ['triggers']
  326. centos7-flannel:
  327. stage: deploy-gce-part2
  328. <<: *job
  329. <<: *gce
  330. variables:
  331. <<: *gce_variables
  332. <<: *centos7_flannel_variables
  333. when: on_success
  334. except: ['triggers']
  335. only: [/^pr-.*$/]
  336. centos7-flannel-triggers:
  337. stage: deploy-gce-part1
  338. <<: *job
  339. <<: *gce
  340. variables:
  341. <<: *gce_variables
  342. <<: *centos7_flannel_variables
  343. when: on_success
  344. only: ['triggers']
  345. ubuntu-weave-sep:
  346. stage: deploy-gce-special
  347. <<: *job
  348. <<: *gce
  349. variables:
  350. <<: *gce_variables
  351. <<: *ubuntu_weave_sep_variables
  352. when: on_success
  353. except: ['triggers']
  354. only: [/^pr-.*$/]
  355. ubuntu-weave-sep-triggers:
  356. stage: deploy-gce-part1
  357. <<: *job
  358. <<: *gce
  359. variables:
  360. <<: *gce_variables
  361. <<: *ubuntu_weave_sep_variables
  362. when: on_success
  363. only: ['triggers']
  364. # More builds for PRs/merges (manual) and triggers (auto)
  365. debian8-canal-ha:
  366. stage: deploy-gce-part1
  367. <<: *job
  368. <<: *gce
  369. variables:
  370. <<: *gce_variables
  371. <<: *debian8_canal_ha_variables
  372. when: manual
  373. except: ['triggers']
  374. only: ['master', /^pr-.*$/]
  375. debian8-canal-ha-triggers:
  376. stage: deploy-gce-part1
  377. <<: *job
  378. <<: *gce
  379. variables:
  380. <<: *gce_variables
  381. <<: *debian8_canal_ha_variables
  382. when: on_success
  383. only: ['triggers']
  384. rhel7-weave:
  385. stage: deploy-gce-part1
  386. <<: *job
  387. <<: *gce
  388. variables:
  389. <<: *gce_variables
  390. <<: *rhel7_weave_variables
  391. when: manual
  392. except: ['triggers']
  393. only: ['master', /^pr-.*$/]
  394. rhel7-weave-triggers:
  395. stage: deploy-gce-part1
  396. <<: *job
  397. <<: *gce
  398. variables:
  399. <<: *gce_variables
  400. <<: *rhel7_weave_variables
  401. when: on_success
  402. only: ['triggers']
  403. debian8-calico:
  404. stage: deploy-gce-part2
  405. <<: *job
  406. <<: *gce
  407. variables:
  408. <<: *gce_variables
  409. <<: *debian8_calico_variables
  410. when: manual
  411. except: ['triggers']
  412. only: ['master', /^pr-.*$/]
  413. debian8-calico-triggers:
  414. stage: deploy-gce-part1
  415. <<: *job
  416. <<: *gce
  417. variables:
  418. <<: *gce_variables
  419. <<: *debian8_calico_variables
  420. when: on_success
  421. only: ['triggers']
  422. coreos-canal:
  423. stage: deploy-gce-part2
  424. <<: *job
  425. <<: *gce
  426. variables:
  427. <<: *gce_variables
  428. <<: *coreos_canal_variables
  429. when: manual
  430. except: ['triggers']
  431. only: ['master', /^pr-.*$/]
  432. coreos-canal-triggers:
  433. stage: deploy-gce-part1
  434. <<: *job
  435. <<: *gce
  436. variables:
  437. <<: *gce_variables
  438. <<: *coreos_canal_variables
  439. when: on_success
  440. only: ['triggers']
  441. rhel7-canal-sep:
  442. stage: deploy-gce-special
  443. <<: *job
  444. <<: *gce
  445. variables:
  446. <<: *gce_variables
  447. <<: *rhel7_canal_sep_variables
  448. when: manual
  449. except: ['triggers']
  450. only: ['master', /^pr-.*$/,]
  451. rhel7-canal-sep-triggers:
  452. stage: deploy-gce-part1
  453. <<: *job
  454. <<: *gce
  455. variables:
  456. <<: *gce_variables
  457. <<: *rhel7_canal_sep_variables
  458. when: on_success
  459. only: ['triggers']
  460. centos7-calico-ha:
  461. stage: deploy-gce-special
  462. <<: *job
  463. <<: *gce
  464. variables:
  465. <<: *gce_variables
  466. <<: *centos7_calico_ha_variables
  467. when: manual
  468. except: ['triggers']
  469. only: ['master', /^pr-.*$/]
  470. centos7-calico-ha-triggers:
  471. stage: deploy-gce-part1
  472. <<: *job
  473. <<: *gce
  474. variables:
  475. <<: *gce_variables
  476. <<: *centos7_calico_ha_variables
  477. when: on_success
  478. only: ['triggers']
  479. # no triggers yet https://github.com/kubernetes-incubator/kargo/issues/613
  480. coreos-alpha-weave-ha:
  481. stage: deploy-gce-special
  482. <<: *job
  483. <<: *gce
  484. variables:
  485. <<: *gce_variables
  486. <<: *coreos_alpha_weave_ha_variables
  487. when: manual
  488. except: ['triggers']
  489. only: ['master', /^pr-.*$/]
  490. ubuntu-rkt-sep:
  491. stage: deploy-gce-part1
  492. <<: *job
  493. <<: *gce
  494. variables:
  495. <<: *gce_variables
  496. <<: *ubuntu_rkt_sep_variables
  497. when: manual
  498. except: ['triggers']
  499. only: ['master', /^pr-.*$/]
  500. ubuntu-vault-sep:
  501. stage: deploy-gce-part1
  502. <<: *job
  503. <<: *gce
  504. variables:
  505. <<: *gce_variables
  506. <<: *ubuntu_vault_sep_variables
  507. when: manual
  508. except: ['triggers']
  509. only: ['master', /^pr-.*$/]
  510. # Premoderated with manual actions
  511. ci-authorized:
  512. <<: *job
  513. stage: moderator
  514. before_script:
  515. - apt-get -y install jq
  516. script:
  517. - /bin/sh scripts/premoderator.sh
  518. except: ['triggers', 'master']
  519. syntax-check:
  520. <<: *job
  521. stage: unit-tests
  522. script:
  523. - ansible-playbook -i inventory/local-tests.cfg -u root -e ansible_ssh_user=root -b --become-user=root cluster.yml -vvv --syntax-check
  524. except: ['triggers', 'master']
  525. tox-inventory-builder:
  526. stage: unit-tests
  527. <<: *job
  528. script:
  529. - pip install tox
  530. - cd contrib/inventory_builder && tox
  531. when: manual
  532. except: ['triggers', 'master']